From f09b3ddc4e0cd2f5ee5913357e6bba59f2246566 Mon Sep 17 00:00:00 2001 From: Vectorized Date: Wed, 6 Dec 2023 21:12:05 +0000 Subject: [PATCH] Rename PRESAVE -> PLATFORM_AIRDROP --- contracts/modules/SuperMinterV1_1.sol | 52 +++++++++---------- .../modules/interfaces/ISuperMinterV1_1.sol | 36 +++++++------ tests/modules/SuperMinterV1_1.t.sol | 18 +++---- 3 files changed, 56 insertions(+), 50 deletions(-) diff --git a/contracts/modules/SuperMinterV1_1.sol b/contracts/modules/SuperMinterV1_1.sol index 39b8a6da..172e6179 100644 --- a/contracts/modules/SuperMinterV1_1.sol +++ b/contracts/modules/SuperMinterV1_1.sol @@ -101,12 +101,12 @@ contract SuperMinterV1_1 is ISuperMinterV1_1, EIP712 { ); /** - * @dev For EIP-712 presave signature digest calculation. + * @dev For EIP-712 platform airdrop signature digest calculation. */ - bytes32 public constant PRESAVE_TYPEHASH = + bytes32 public constant PLATFORM_AIRDROP_TYPEHASH = // prettier-ignore keccak256( - "Presave(" + "PlatformAirdrop(" "address edition," "uint8 tier," "uint8 scheduleNum," @@ -138,9 +138,9 @@ contract SuperMinterV1_1 is ISuperMinterV1_1, EIP712 { uint8 public constant VERIFY_SIGNATURE = 2; /** - * @dev The Presave mint mode. + * @dev The platform airdrop mint mode. */ - uint8 public constant PRESAVE = 3; + uint8 public constant PLATFORM_AIRDROP = 3; /** * @dev The denominator of all BPS calculations. @@ -262,11 +262,11 @@ contract SuperMinterV1_1 is ISuperMinterV1_1, EIP712 { _validateSigner(c.signer); c.merkleRoot = bytes32(0); c.maxMintablePerAccount = type(uint32).max; - } else if (mode == PRESAVE) { + } else if (mode == PLATFORM_AIRDROP) { _validateSigner(c.signer); c.merkleRoot = bytes32(0); c.maxMintablePerAccount = type(uint32).max; - c.price = 0; // Presave mode doesn't have a price. + c.price = 0; // Platform airdrop mode doesn't have a price. } else { revert InvalidMode(); } @@ -341,7 +341,7 @@ contract SuperMinterV1_1 is ISuperMinterV1_1, EIP712 { uint8 mode = d.mode; if (mode == VERIFY_MERKLE) _verifyMerkle(d, p); else if (mode == VERIFY_SIGNATURE) _verifyAndClaimSignature(d, p); - else if (mode == PRESAVE) revert InvalidMode(); + else if (mode == PLATFORM_AIRDROP) revert InvalidMode(); _incrementMinted(mode, d, p); @@ -423,17 +423,17 @@ contract SuperMinterV1_1 is ISuperMinterV1_1, EIP712 { /** * @inheritdoc ISuperMinterV1_1 */ - function presave(Presave calldata p) public { + function platformAirdrop(PlatformAirdrop calldata p) public { MintData storage d = _getMintData(LibOps.packId(p.edition, p.tier, p.scheduleNum)); /* ------------------- CHECKS AND UPDATES ------------------- */ _requireMintOpen(d); - if (d.mode != PRESAVE) revert InvalidMode(); - _verifyAndClaimPresaveSignature(d, p); + if (d.mode != PLATFORM_AIRDROP) revert InvalidMode(); + _verifyAndClaimPlatfromAidropSignature(d, p); - _incrementPresaveMinted(d, p); + _incrementPlatformAirdropMinted(d, p); /* ------------------------- MINT --------------------------- */ @@ -446,7 +446,7 @@ contract SuperMinterV1_1 is ISuperMinterV1_1, EIP712 { } } - emit Presaved(p.edition, p.tier, p.scheduleNum, p.to, p.signedQuantity); + emit PlatformAirdropped(p.edition, p.tier, p.scheduleNum, p.to, p.signedQuantity); } // Per edition mint parameter setters: @@ -466,8 +466,8 @@ contract SuperMinterV1_1 is ISuperMinterV1_1, EIP712 { MintData storage d = _getMintData(mintId); // If the tier is GA and the `mode` is `VERIFY_SIGNATURE`, we'll use `gaPrice[platform]`. if (tier == GA_TIER && d.mode != VERIFY_SIGNATURE) revert NotConfigurable(); - // Presave mints will not have a price. - if (d.mode == PRESAVE) revert NotConfigurable(); + // Platform airdropped mints will not have a price. + if (d.mode == PLATFORM_AIRDROP) revert NotConfigurable(); d.price = price; emit PriceSet(edition, tier, scheduleNum, price); } @@ -566,8 +566,8 @@ contract SuperMinterV1_1 is ISuperMinterV1_1, EIP712 { if (tier == GA_TIER) revert NotConfigurable(); // Signature mints will have `type(uint32).max`. if (d.mode == VERIFY_SIGNATURE) revert NotConfigurable(); - // Presave mints will have `type(uint32).max`. - if (d.mode == PRESAVE) revert NotConfigurable(); + // Platform airdrops will have `type(uint32).max`. + if (d.mode == PLATFORM_AIRDROP) revert NotConfigurable(); _validateMaxMintablePerAccount(value); d.maxMintablePerAccount = value; emit MaxMintablePerAccountSet(edition, tier, scheduleNum, value); @@ -753,11 +753,11 @@ contract SuperMinterV1_1 is ISuperMinterV1_1, EIP712 { /** * @inheritdoc ISuperMinterV1_1 */ - function computePresaveDigest(Presave calldata p) public view returns (bytes32) { + function computePlatformAirdropDigest(PlatformAirdrop calldata p) public view returns (bytes32) { // prettier-ignore return _hashTypedData(keccak256(abi.encode( - PRESAVE_TYPEHASH, + PLATFORM_AIRDROP_TYPEHASH, p.edition, p.tier, p.scheduleNum, @@ -1119,9 +1119,9 @@ contract SuperMinterV1_1 is ISuperMinterV1_1, EIP712 { /** * @dev Increments the number minted in the mint and the number minted by the collector. * @param d The mint data storage pointer. - * @param p The presave parameters. + * @param p The platform airdrop parameters. */ - function _incrementPresaveMinted(MintData storage d, Presave calldata p) internal { + function _incrementPlatformAirdropMinted(MintData storage d, PlatformAirdrop calldata p) internal { unchecked { uint256 mintId = LibOps.packId(p.edition, p.tier, p.scheduleNum); uint256 toLength = p.to.length; @@ -1165,14 +1165,14 @@ contract SuperMinterV1_1 is ISuperMinterV1_1, EIP712 { } /** - * @dev Verify the presave signature, and mark the signed claim ticket as claimed. + * @dev Verify the platform airdrop signature, and mark the signed claim ticket as claimed. * @param d The mint data storage pointer. - * @param p The presave parameters. + * @param p The platform airdrop parameters. */ - function _verifyAndClaimPresaveSignature(MintData storage d, Presave calldata p) internal { - // Unlike regular signature mints, presave mints only used `signedQuantity`. + function _verifyAndClaimPlatfromAidropSignature(MintData storage d, PlatformAirdrop calldata p) internal { + // Unlike regular signature mints, platform airdrops only use `signedQuantity`. address signer = _effectiveSigner(d); - if (!SignatureCheckerLib.isValidSignatureNowCalldata(signer, computePresaveDigest(p), p.signature)) + if (!SignatureCheckerLib.isValidSignatureNowCalldata(signer, computePlatformAirdropDigest(p), p.signature)) revert InvalidSignature(); if (block.timestamp > p.signedDeadline) revert SignatureExpired(); uint256 mintId = LibOps.packId(p.edition, p.tier, p.scheduleNum); diff --git a/contracts/modules/interfaces/ISuperMinterV1_1.sol b/contracts/modules/interfaces/ISuperMinterV1_1.sol index b6ee8359..f600a99e 100644 --- a/contracts/modules/interfaces/ISuperMinterV1_1.sol +++ b/contracts/modules/interfaces/ISuperMinterV1_1.sol @@ -87,9 +87,9 @@ interface ISuperMinterV1_1 is IERC165 { } /** - * @dev A struct containing the arguments for presave. + * @dev A struct containing the arguments for platformAirdrop. */ - struct Presave { + struct PlatformAirdrop { // The mint ID. address edition; // The tier of the mint. @@ -241,7 +241,7 @@ interface ISuperMinterV1_1 is IERC165 { bytes32 affiliateMerkleRoot; // The Merkle root hash, required if `mode` is `VERIFY_MERKLE`. bytes32 merkleRoot; - // The signer address, required if `mode` is `VERIFY_SIGNATURE` or `PRESAVE`. + // The signer address, required if `mode` is `VERIFY_SIGNATURE` or `PLATFORM_AIRDROP`. // This value will be the platform signer instead if it is configured to be `address(1)`. address signer; // Whether the platform signer is being used instead @@ -363,14 +363,20 @@ interface ISuperMinterV1_1 is IERC165 { ); /** - * @dev Emitted when tokens are minted for presave. + * @dev Emitted when tokens are platform airdropped. * @param edition The address of the Sound Edition. * @param tier The tier. * @param scheduleNum The edition-tier schedule number. * @param to The recipients of the tokens minted. * @param signedQuantity The amount of tokens per address. */ - event Presaved(address indexed edition, uint8 tier, uint8 scheduleNum, address[] to, uint32 signedQuantity); + event PlatformAirdropped( + address indexed edition, + uint8 tier, + uint8 scheduleNum, + address[] to, + uint32 signedQuantity + ); /** * @dev Emitted when the platform fee configuration for `tier` is updated. @@ -589,10 +595,10 @@ interface ISuperMinterV1_1 is IERC165 { function mintTo(MintTo calldata p) external payable; /** - * @dev Performs a presave mint. - * @param p The presave parameters. + * @dev Performs a platform airdrop. + * @param p The platform airdrop parameters. */ - function presave(Presave calldata p) external; + function platformAirdrop(PlatformAirdrop calldata p) external; /** * @dev Sets the price of the mint. @@ -796,10 +802,10 @@ interface ISuperMinterV1_1 is IERC165 { function MINT_TO_TYPEHASH() external pure returns (bytes32); /** - * @dev The EIP-712 typehash for presave mints. + * @dev The EIP-712 typehash for platform airdrop mints. * @return The constant value. */ - function PRESAVE_TYPEHASH() external pure returns (bytes32); + function PLATFORM_AIRDROP_TYPEHASH() external pure returns (bytes32); /** * @dev The default mint mode. @@ -820,10 +826,10 @@ interface ISuperMinterV1_1 is IERC165 { function VERIFY_SIGNATURE() external pure returns (uint8); /** - * @dev The mint mode for presave. + * @dev The mint mode for platform airdrop. * @return The constant value. */ - function PRESAVE() external pure returns (uint8); + function PLATFORM_AIRDROP() external pure returns (uint8); /** * @dev The denominator used in BPS fee calculations. @@ -884,11 +890,11 @@ interface ISuperMinterV1_1 is IERC165 { function computeMintToDigest(MintTo calldata p) external view returns (bytes32); /** - * @dev Returns the EIP-712 digest of the mint-to data for presave mints. - * @param p The presave parameters. + * @dev Returns the EIP-712 digest of the mint-to data for platform airdrops. + * @param p The platform airdrop parameters. * @return The computed value. */ - function computePresaveDigest(Presave calldata p) external view returns (bytes32); + function computePlatformAirdropDigest(PlatformAirdrop calldata p) external view returns (bytes32); /** * @dev Returns the total price and fees for the mint. diff --git a/tests/modules/SuperMinterV1_1.t.sol b/tests/modules/SuperMinterV1_1.t.sol index a21d0644..c5df5634 100644 --- a/tests/modules/SuperMinterV1_1.t.sol +++ b/tests/modules/SuperMinterV1_1.t.sol @@ -256,7 +256,7 @@ contract SuperMinterV1_1Tests is TestConfigV2_1 { } } - function test_presave(uint256) public { + function test_platformAirdrop(uint256) public { (address signer, uint256 privateKey) = _randomSigner(); ISuperMinterV1_1.MintCreation memory c; @@ -267,12 +267,12 @@ contract SuperMinterV1_1Tests is TestConfigV2_1 { c.tier = uint8(_random() % 2); c.endTime = uint32(block.timestamp + 1000); c.maxMintablePerAccount = uint32(_random()); // Doesn't matter, will be auto set to max. - c.mode = sm.PRESAVE(); + c.mode = sm.PLATFORM_AIRDROP(); c.signer = signer; assertEq(sm.createEditionMint(c), 0); unchecked { - ISuperMinterV1_1.Presave memory p; + ISuperMinterV1_1.PlatformAirdrop memory p; p.edition = address(edition); p.tier = c.tier; p.scheduleNum = 0; @@ -285,16 +285,16 @@ contract SuperMinterV1_1Tests is TestConfigV2_1 { } LibSort.sort(p.to); LibSort.uniquifySorted(p.to); - p.signature = _generatePresaveSignature(p, privateKey); + p.signature = _generatePlatformAirdropSignature(p, privateKey); uint256 expectedMinted = p.signedQuantity * p.to.length; if (expectedMinted > c.maxMintable) { vm.expectRevert(ISuperMinterV1_1.ExceedsMintSupply.selector); - sm.presave(p); + sm.platformAirdrop(p); return; } - sm.presave(p); + sm.platformAirdrop(p); assertEq(sm.mintInfo(address(edition), p.tier, p.scheduleNum).minted, expectedMinted); for (uint256 i; i < p.to.length; ++i) { assertEq(edition.balanceOf(p.to[i]), p.signedQuantity); @@ -302,7 +302,7 @@ contract SuperMinterV1_1Tests is TestConfigV2_1 { } vm.expectRevert(ISuperMinterV1_1.SignatureAlreadyUsed.selector); - sm.presave(p); + sm.platformAirdrop(p); } } @@ -1038,11 +1038,11 @@ contract SuperMinterV1_1Tests is TestConfigV2_1 { signature = abi.encodePacked(r, s, v); } - function _generatePresaveSignature(ISuperMinterV1_1.Presave memory p, uint256 privateKey) + function _generatePlatformAirdropSignature(ISuperMinterV1_1.PlatformAirdrop memory p, uint256 privateKey) internal returns (bytes memory signature) { - bytes32 digest = sm.computePresaveDigest(p); + bytes32 digest = sm.computePlatformAirdropDigest(p); (uint8 v, bytes32 r, bytes32 s) = vm.sign(privateKey, digest); signature = abi.encodePacked(r, s, v); }