Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Downsize 721CM and 721M #127

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 6 additions & 62 deletions contracts/ERC721CM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ contract ERC721CM is IERC721M, ERC721ACQueryable, Ownable, ReentrancyGuard {
// Whether this contract is mintable.
bool private _mintable;

// Whether base URI is permanent. Once set, base URI is immutable.
bool private _baseURIPermanent;

// Specify how long a signature from cosigner is valid for, recommend 300 seconds.
uint64 private _timestampExpirySeconds;

Expand Down Expand Up @@ -161,12 +158,9 @@ contract ERC721CM is IERC721M, ERC721ACQueryable, Ownable, ReentrancyGuard {
* ]
*/
function setStages(MintStageInfo[] calldata newStages) external onlyOwner {
uint256 originalSize = _mintStages.length;
for (uint256 i = 0; i < originalSize; i++) {
_mintStages.pop();
}
delete _mintStages;

for (uint256 i = 0; i < newStages.length; i++) {
for (uint256 i = 0; i < newStages.length;) {
if (i >= 1) {
if (
newStages[i].startTimeUnixSeconds <
Expand Down Expand Up @@ -199,6 +193,8 @@ contract ERC721CM is IERC721M, ERC721ACQueryable, Ownable, ReentrancyGuard {
newStages[i].startTimeUnixSeconds,
newStages[i].endTimeUnixSeconds
);

unchecked { ++i; }
}
}

Expand Down Expand Up @@ -288,50 +284,6 @@ contract ERC721CM is IERC721M, ERC721ACQueryable, Ownable, ReentrancyGuard {
return (_mintStages[index], walletMinted, stageMinted);
}

/**
* @dev Updates info for one stage specified by index (starting from 0).
*/
function updateStage(
uint256 index,
uint80 price,
uint32 walletLimit,
bytes32 merkleRoot,
uint24 maxStageSupply,
uint64 startTimeUnixSeconds,
uint64 endTimeUnixSeconds
) external onlyOwner {
if (index >= _mintStages.length) revert InvalidStage();
if (index >= 1) {
if (
startTimeUnixSeconds <
_mintStages[index - 1].endTimeUnixSeconds +
_timestampExpirySeconds
) {
revert InsufficientStageTimeGap();
}
}
_assertValidStartAndEndTimestamp(
startTimeUnixSeconds,
endTimeUnixSeconds
);
_mintStages[index].price = price;
_mintStages[index].walletLimit = walletLimit;
_mintStages[index].merkleRoot = merkleRoot;
_mintStages[index].maxStageSupply = maxStageSupply;
_mintStages[index].startTimeUnixSeconds = startTimeUnixSeconds;
_mintStages[index].endTimeUnixSeconds = endTimeUnixSeconds;

emit UpdateStage(
index,
price,
walletLimit,
merkleRoot,
maxStageSupply,
startTimeUnixSeconds,
endTimeUnixSeconds
);
}

/**
* @dev Returns mint currency address.
*/
Expand Down Expand Up @@ -512,19 +464,10 @@ contract ERC721CM is IERC721M, ERC721ACQueryable, Ownable, ReentrancyGuard {
* @dev Sets token base URI.
*/
function setBaseURI(string calldata baseURI) external onlyOwner {
if (_baseURIPermanent) revert CannotUpdatePermanentBaseURI();
_currentBaseURI = baseURI;
emit SetBaseURI(baseURI);
}

/**
* @dev Sets token base URI permanent. Cannot revert.
*/
function setBaseURIPermanent() external onlyOwner {
_baseURIPermanent = true;
emit PermanentBaseURI(_currentBaseURI);
}

/**
* @dev Sets token URI suffix. e.g. ".json".
*/
Expand Down Expand Up @@ -614,13 +557,14 @@ contract ERC721CM is IERC721M, ERC721ACQueryable, Ownable, ReentrancyGuard {
function getActiveStageFromTimestamp(
uint64 timestamp
) public view returns (uint256) {
for (uint256 i = 0; i < _mintStages.length; i++) {
for (uint256 i = 0; i < _mintStages.length;) {
if (
timestamp >= _mintStages[i].startTimeUnixSeconds &&
timestamp < _mintStages[i].endTimeUnixSeconds
) {
return i;
}
unchecked { ++i; }
}
revert InvalidStage();
}
Expand Down
53 changes: 0 additions & 53 deletions contracts/ERC721M.sol
Original file line number Diff line number Diff line change
Expand Up @@ -284,50 +284,6 @@ contract ERC721M is IERC721M, ERC721AQueryable, Ownable, ReentrancyGuard {
return (_mintStages[index], walletMinted, stageMinted);
}

/**
* @dev Updates info for one stage specified by index (starting from 0).
*/
function updateStage(
uint256 index,
uint80 price,
uint32 walletLimit,
bytes32 merkleRoot,
uint24 maxStageSupply,
uint64 startTimeUnixSeconds,
uint64 endTimeUnixSeconds
) external onlyOwner {
if (index >= _mintStages.length) revert InvalidStage();
if (index >= 1) {
if (
startTimeUnixSeconds <
_mintStages[index - 1].endTimeUnixSeconds +
_timestampExpirySeconds
) {
revert InsufficientStageTimeGap();
}
}
_assertValidStartAndEndTimestamp(
startTimeUnixSeconds,
endTimeUnixSeconds
);
_mintStages[index].price = price;
_mintStages[index].walletLimit = walletLimit;
_mintStages[index].merkleRoot = merkleRoot;
_mintStages[index].maxStageSupply = maxStageSupply;
_mintStages[index].startTimeUnixSeconds = startTimeUnixSeconds;
_mintStages[index].endTimeUnixSeconds = endTimeUnixSeconds;

emit UpdateStage(
index,
price,
walletLimit,
merkleRoot,
maxStageSupply,
startTimeUnixSeconds,
endTimeUnixSeconds
);
}

/**
* @dev Returns mint currency address.
*/
Expand Down Expand Up @@ -508,19 +464,10 @@ contract ERC721M is IERC721M, ERC721AQueryable, Ownable, ReentrancyGuard {
* @dev Sets token base URI.
*/
function setBaseURI(string calldata baseURI) external onlyOwner {
if (_baseURIPermanent) revert CannotUpdatePermanentBaseURI();
_currentBaseURI = baseURI;
emit SetBaseURI(baseURI);
}

/**
* @dev Sets token base URI permanent. Cannot revert.
*/
function setBaseURIPermanent() external onlyOwner {
_baseURIPermanent = true;
emit PermanentBaseURI(_currentBaseURI);
}

/**
* @dev Sets token URI suffix. e.g. ".json".
*/
Expand Down
2 changes: 0 additions & 2 deletions contracts/IERC721M.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import "erc721a/contracts/extensions/IERC721AQueryable.sol";

interface IERC721M is IERC721AQueryable {
error CannotIncreaseMaxMintableSupply();
error CannotUpdatePermanentBaseURI();
error CosignerNotSet();
error CrossmintAddressNotSet();
error CrossmintOnly();
Expand Down Expand Up @@ -56,7 +55,6 @@ interface IERC721M is IERC721AQueryable {
event SetBaseURI(string baseURI);
event SetTimestampExpirySeconds(uint64 expiry);
event SetMintCurrency(address mintCurrency);
event PermanentBaseURI(string baseURI);
event Withdraw(uint256 value);
event WithdrawERC20(address mintCurrency, uint256 value);

Expand Down
Loading
Loading