From 212ca09ad9bc607a37b68e70ca4b670cd2d11606 Mon Sep 17 00:00:00 2001 From: Andres Adjimann Date: Wed, 20 Nov 2024 13:48:03 -0300 Subject: [PATCH] fix: remove amount from signatures --- .../avatar/contracts/nft-collection/NFTCollection.sol | 4 ++-- .../nft-collection/NFTCollectionSignature.sol | 7 +------ .../avatar/nft-collection/NFTCollection.fixtures.ts | 11 ++--------- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/packages/avatar/contracts/nft-collection/NFTCollection.sol b/packages/avatar/contracts/nft-collection/NFTCollection.sol index 922ddc689c..be32dda49d 100644 --- a/packages/avatar/contracts/nft-collection/NFTCollection.sol +++ b/packages/avatar/contracts/nft-collection/NFTCollection.sol @@ -289,7 +289,7 @@ INFTCollection * by the allowedToExecuteMint contract * @custom:event {Transfer} * @param wallet minting wallet - * @param amount number of token to mint + * @param amount number of token to mint (not included in the signature, the user can chose the amount) * @param waveIndex the index of the wave used to mint * @param signatureId signing signature ID * @param signature signing signature value @@ -308,7 +308,7 @@ INFTCollection if (_msgSender() != address($.allowedToExecuteMint)) { revert ERC721InvalidSender(_msgSender()); } - _checkAndSetWaveMintSignature(wallet, amount, waveIndex, signatureId, signature); + _checkAndSetWaveMintSignature(wallet, waveIndex, signatureId, signature); WaveData storage waveData = _getWaveData(waveIndex); _doMint(waveData, wallet, amount); } diff --git a/packages/avatar/contracts/nft-collection/NFTCollectionSignature.sol b/packages/avatar/contracts/nft-collection/NFTCollectionSignature.sol index 163ec54839..84aca0d9c8 100644 --- a/packages/avatar/contracts/nft-collection/NFTCollectionSignature.sol +++ b/packages/avatar/contracts/nft-collection/NFTCollectionSignature.sol @@ -127,21 +127,19 @@ abstract contract NFTCollectionSignature { * @notice checks that the provided signature is valid, while also taking into * consideration the provided address and signatureId. * @param wallet address to be used in validating the signature - * @param amount number of token to mint * @param waveIndex the index of the wave that is used to mint * @param signatureId signing signature ID * @param signature signing signature value */ function _checkAndSetWaveMintSignature( address wallet, - uint256 amount, uint256 waveIndex, uint256 signatureId, bytes calldata signature ) internal { NFTCollectionSignatureStorage storage $ = _getNFTCollectionSignatureStorage(); if ($.signatureIds[signatureId] != SignatureType.Unused - || _getWaveMintSignature(wallet, amount, waveIndex, signatureId, address(this), block.chainid, signature) != $.signAddress) { + || _getWaveMintSignature(wallet, waveIndex, signatureId, address(this), block.chainid, signature) != $.signAddress) { revert InvalidSignature(signatureId); } $.signatureIds[signatureId] = SignatureType.WaveMint; @@ -302,7 +300,6 @@ abstract contract NFTCollectionSignature { /** * @notice validate a mint signature that includes a waveIndex * @param wallet wallet that was used in signature generation - * @param amount number of token to mint * @param waveIndex the index of the wave that is used to mint * @param signatureId id of signature * @param contractAddress contract address that was used in signature generation @@ -312,7 +309,6 @@ abstract contract NFTCollectionSignature { */ function _getWaveMintSignature( address wallet, - uint256 amount, uint256 waveIndex, uint256 signatureId, address contractAddress, @@ -327,7 +323,6 @@ abstract contract NFTCollectionSignature { keccak256( abi.encode( wallet, - amount, waveIndex, signatureId, contractAddress, diff --git a/packages/avatar/test/avatar/nft-collection/NFTCollection.fixtures.ts b/packages/avatar/test/avatar/nft-collection/NFTCollection.fixtures.ts index 4811bd3a30..19e4b66e80 100644 --- a/packages/avatar/test/avatar/nft-collection/NFTCollection.fixtures.ts +++ b/packages/avatar/test/avatar/nft-collection/NFTCollection.fixtures.ts @@ -184,15 +184,8 @@ function setupWaveSign(contract: Contract, raffleSignWallet: Signer) { destinationWallet = await destinationWallet.getAddress(); } const hashedData = ethers.AbiCoder.defaultAbiCoder().encode( - ['address', 'uint256', 'uint256', 'uint256', 'address', 'uint256'], - [ - destinationWallet, - amount, - waveIndex, - signatureId, - contractAddress, - chainId, - ] + ['address', 'uint256', 'uint256', 'address', 'uint256'], + [destinationWallet, waveIndex, signatureId, contractAddress, chainId] ); // https://docs.ethers.org/v6/migrating/ return signerWallet.signMessage(