Skip to content

Commit

Permalink
Make mintTo and platformAirdrop return fromTokenId, use airdrop in pl…
Browse files Browse the repository at this point in the history
…atformAirdrop
  • Loading branch information
Vectorized committed Dec 7, 2023
1 parent ee342c1 commit 679aee9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion contracts/core/SoundEditionV2_1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ contract SoundEditionV2_1 is ISoundEditionV2_1, ERC721AQueryableUpgradeable, ERC
uint8 tier,
address[] calldata to,
uint256 quantity
) external payable onlyRolesOrOwner(ADMIN_ROLE) returns (uint256 fromTokenId) {
) external payable onlyRolesOrOwner(ADMIN_ROLE | MINTER_ROLE) returns (uint256 fromTokenId) {
uint32 fromTierTokenIdIndex;
unchecked {
// Multiplication overflow is not possible due to the max block gas limit.
Expand Down
18 changes: 7 additions & 11 deletions contracts/modules/SuperMinterV1_1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ contract SuperMinterV1_1 is ISuperMinterV1_1, EIP712 {
/**
* @inheritdoc ISuperMinterV1_1
*/
function mintTo(MintTo calldata p) public payable {
function mintTo(MintTo calldata p) public payable returns (uint256 fromTokenId) {
MintData storage d = _getMintData(LibOps.packId(p.edition, p.tier, p.scheduleNum));

/* ------------------- CHECKS AND UPDATES ------------------- */
Expand Down Expand Up @@ -410,12 +410,14 @@ contract SuperMinterV1_1 is ISuperMinterV1_1, EIP712 {
l.unitPrice = f.unitPrice;

emit Minted(p.edition, p.tier, p.scheduleNum, p.to, l, p.attributionId);

return l.fromTokenId;
}

/**
* @inheritdoc ISuperMinterV1_1
*/
function platformAirdrop(PlatformAirdrop calldata p) public {
function platformAirdrop(PlatformAirdrop calldata p) public returns (uint256 fromTokenId) {
MintData storage d = _getMintData(LibOps.packId(p.edition, p.tier, p.scheduleNum));

/* ------------------- CHECKS AND UPDATES ------------------- */
Expand All @@ -429,16 +431,10 @@ contract SuperMinterV1_1 is ISuperMinterV1_1, EIP712 {

/* ------------------------- MINT --------------------------- */

unchecked {
ISoundEditionV2_1 edition = ISoundEditionV2_1(p.edition);

uint256 toLength = p.to.length;
for (uint256 i; i != toLength; ++i) {
edition.mint(p.tier, p.to[i], p.signedQuantity);
}
}
ISoundEditionV2_1 edition = ISoundEditionV2_1(p.edition);
fromTokenId = edition.airdrop(p.tier, p.to, p.signedQuantity);

emit PlatformAirdropped(p.edition, p.tier, p.scheduleNum, p.to, p.signedQuantity);
emit PlatformAirdropped(p.edition, p.tier, p.scheduleNum, p.to, p.signedQuantity, fromTokenId);
}

// Per edition mint parameter setters:
Expand Down
10 changes: 7 additions & 3 deletions contracts/modules/interfaces/ISuperMinterV1_1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,15 @@ interface ISuperMinterV1_1 is IERC165 {
* @param scheduleNum The edition-tier schedule number.
* @param to The recipients of the tokens minted.
* @param signedQuantity The amount of tokens per address.
* @param fromTokenId The first token ID minted.
*/
event PlatformAirdropped(
address indexed edition,
uint8 tier,
uint8 scheduleNum,
address[] to,
uint32 signedQuantity
uint32 signedQuantity,
uint256 fromTokenId
);

/**
Expand Down Expand Up @@ -570,14 +572,16 @@ interface ISuperMinterV1_1 is IERC165 {
/**
* @dev Performs a mint.
* @param p The mint-to parameters.
* @return fromTokenId The first token ID minted.
*/
function mintTo(MintTo calldata p) external payable;
function mintTo(MintTo calldata p) external payable returns (uint256 fromTokenId);

/**
* @dev Performs a platform airdrop.
* @param p The platform airdrop parameters.
* @return fromTokenId The first token ID minted.
*/
function platformAirdrop(PlatformAirdrop calldata p) external;
function platformAirdrop(PlatformAirdrop calldata p) external returns (uint256 fromTokenId);

/**
* @dev Sets the price of the mint.
Expand Down
2 changes: 1 addition & 1 deletion tests/modules/SuperMinterV1_1.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ contract SuperMinterV1_1Tests is TestConfigV2_1 {
p.edition = address(edition);
p.tier = c.tier;
p.scheduleNum = 0;
p.to = new address[](_bound(_random(), 0, 8));
p.to = new address[](_bound(_random(), 1, 8));
p.signedQuantity = uint32(_bound(_random(), 1, 8));
p.signedClaimTicket = uint32(_bound(_random(), 0, type(uint32).max));
p.signedDeadline = type(uint32).max;
Expand Down

0 comments on commit 679aee9

Please sign in to comment.