Skip to content

Commit

Permalink
Add ERC721CMRoyalties
Browse files Browse the repository at this point in the history
  • Loading branch information
channing-magiceden committed Feb 24, 2024
1 parent dfbec62 commit b4a9b46
Show file tree
Hide file tree
Showing 12 changed files with 392 additions and 92 deletions.
18 changes: 12 additions & 6 deletions contracts/ERC721CM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ contract ERC721CM is IERC721M, ERC721ACQueryable, Ownable, ReentrancyGuard {
if (i >= 1) {
if (
newStages[i].startTimeUnixSeconds <
newStages[i - 1].endTimeUnixSeconds + _timestampExpirySeconds
newStages[i - 1].endTimeUnixSeconds +
_timestampExpirySeconds
) {
revert InsufficientStageTimeGap();
}
Expand Down Expand Up @@ -365,7 +366,7 @@ contract ERC721CM is IERC721M, ERC721ACQueryable, Ownable, ReentrancyGuard {
bytes32[] calldata proof,
uint64 timestamp,
bytes calldata signature
) virtual external payable nonReentrant {
) external payable virtual nonReentrant {
_mintInternal(qty, msg.sender, proof, timestamp, signature);
}

Expand Down Expand Up @@ -417,7 +418,8 @@ contract ERC721CM is IERC721M, ERC721ACQueryable, Ownable, ReentrancyGuard {
stage = _mintStages[activeStage];

// Check value if minting with ETH
if (_mintCurrency == address(0) && msg.value < stage.price * qty) revert NotEnoughValue();
if (_mintCurrency == address(0) && msg.value < stage.price * qty)
revert NotEnoughValue();

// Check stage supply if applicable
if (stage.maxStageSupply > 0) {
Expand Down Expand Up @@ -450,7 +452,11 @@ contract ERC721CM is IERC721M, ERC721ACQueryable, Ownable, ReentrancyGuard {
}

if (_mintCurrency != address(0)) {
IERC20(_mintCurrency).safeTransferFrom(msg.sender, address(this), stage.price * qty);
IERC20(_mintCurrency).safeTransferFrom(
msg.sender,
address(this),
stage.price * qty
);
}

_stageMintedCountsPerWallet[activeStage][to] += qty;
Expand Down Expand Up @@ -552,7 +558,7 @@ contract ERC721CM is IERC721M, ERC721ACQueryable, Ownable, ReentrancyGuard {
*/
function setContractURI(string calldata uri) external onlyOwner {
_contractURI = uri;
}
}

/**
* @dev Returns data hash for the given minter, qty and timestamp.
Expand Down Expand Up @@ -646,4 +652,4 @@ contract ERC721CM is IERC721M, ERC721ACQueryable, Ownable, ReentrancyGuard {
function _requireCallerIsContractOwner() internal view virtual override {
_checkOwner();
}
}
}
19 changes: 14 additions & 5 deletions contracts/ERC721CMBasicRoyalties.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ contract ERC721CMBasicRoyalties is ERC721CM, BasicRoyalties {
uint64 timestampExpirySeconds,
address mintCurrency,
address royaltyReceiver,
uint96 royaltyFeeNumerator)
uint96 royaltyFeeNumerator
)
ERC721CM(
collectionName,
collectionSymbol,
Expand All @@ -28,10 +29,18 @@ contract ERC721CMBasicRoyalties is ERC721CM, BasicRoyalties {
globalWalletLimit,
cosigner,
timestampExpirySeconds,
mintCurrency)
BasicRoyalties(royaltyReceiver, royaltyFeeNumerator) {}
mintCurrency
)
BasicRoyalties(royaltyReceiver, royaltyFeeNumerator)
{}

function supportsInterface(bytes4 interfaceId) public view virtual override(ERC2981, ERC721ACQueryable, IERC721A) returns (bool) {
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC2981, ERC721ACQueryable, IERC721A)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
}
}
46 changes: 46 additions & 0 deletions contracts/ERC721CMRoyalties.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

import {ERC2981, UpdatableRoyalties} from "./royalties/UpdatableRoyalties.sol";
import {ERC721CM, ERC721ACQueryable, IERC721A} from "./ERC721CM.sol";

/**
* @title ERC721CMRoyalties
*/
contract ERC721CMRoyalties is ERC721CM, UpdatableRoyalties {
constructor(
string memory collectionName,
string memory collectionSymbol,
string memory tokenURISuffix,
uint256 maxMintableSupply,
uint256 globalWalletLimit,
address cosigner,
uint64 timestampExpirySeconds,
address mintCurrency,
address royaltyReceiver,
uint96 royaltyFeeNumerator
)
ERC721CM(
collectionName,
collectionSymbol,
tokenURISuffix,
maxMintableSupply,
globalWalletLimit,
cosigner,
timestampExpirySeconds,
mintCurrency
)
UpdatableRoyalties(royaltyReceiver, royaltyFeeNumerator)
{}

function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC2981, ERC721ACQueryable, IERC721A)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
}
Loading

0 comments on commit b4a9b46

Please sign in to comment.