Skip to content

Commit

Permalink
fix: remove amount from signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
Andres Adjimann committed Dec 3, 2024
1 parent a268b9b commit 212ca09
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
4 changes: 2 additions & 2 deletions packages/avatar/contracts/nft-collection/NFTCollection.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -312,7 +309,6 @@ abstract contract NFTCollectionSignature {
*/
function _getWaveMintSignature(
address wallet,
uint256 amount,
uint256 waveIndex,
uint256 signatureId,
address contractAddress,
Expand All @@ -327,7 +323,6 @@ abstract contract NFTCollectionSignature {
keccak256(
abi.encode(
wallet,
amount,
waveIndex,
signatureId,
contractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

1 comment on commit 212ca09

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage for this commit

90.36%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
packages/avatar/contracts/avatar
   AvatarCollection.sol74.25%56.56%73.81%90.37%285, 329–337, 339–340, 345, 403–407, 425, 442, 459, 483–487, 491–492, 495, 526, 537, 545, 545–546, 565, 599, 621, 631, 712, 732, 745, 745, 745, 763, 763, 765, 774, 774, 776, 786, 786–787, 797, 797–798, 809, 809–810, 823, 832, 861–862, 992–993, 996, 999
   CollectionAccessControl.sol60.87%53.33%63.64%67.86%120, 130–131, 140, 150–151, 161–162, 162, 162, 164–165, 167, 173, 173–174, 185, 192, 192–194, 98–99
   ERC721BurnMemoryEnumerableUpgradeable.sol93.33%75%100%100%62, 75
packages/avatar/contracts/common
   IERC4906.sol100%100%100%100%
   IERC5313.sol100%100%100%100%
packages/avatar/contracts/common/BaseWithStorage/ERC2771
   ERC2771HandlerUpgradeable.sol44.44%25%60%44.44%22, 26, 29, 38, 38, 38–39, 41
packages/avatar/contracts/common/OperatorFilterer
   IOperatorFilterRegistry.sol100%100%100%100%
   UpdatableOperatorFiltererUpgradeable.sol11.11%10%25%9.52%18, 23–24, 24, 24–25, 27, 27, 27–28, 30, 38, 38, 38, 42, 42, 42–44, 46, 46, 46–47, 50, 55, 55, 55–56, 56, 56–57, 60, 68, 68, 68–69, 71
packages/avatar/contracts/nft-collection
   ERC2771HandlerUpgradeable.sol100%100%100%100%
   ERC721BurnMemoryUpgradeable.sol100%100%100%100%
   INFTCollection.sol100%100%100%100%
   NFTCollection.sol99.76%99.28%100%100%303
   NFTCollectionSignature.sol100%100%100%100%
   UpdatableOperatorFiltererUpgradeable.sol100%100%100%100%
packages/avatar/contracts/proxy
   CollectionFactory.sol86.59%89.06%75%87.50%149, 230, 293, 362–366, 368, 385, 402, 410, 410–411, 423, 423–424
   CollectionProxy.sol88.24%50%100%100%55, 70
packages/avatar/contracts/raffle
   DanceFight.sol75%50%100%100%20
   FistOfTheNorthStar.sol75%50%100%100%20
   GenericRaffle.sol67.92%52.22%62.07%84.95%178, 189–195, 225–229, 252–259, 266–267, 270, 288, 288–289, 289, 289–290, 308, 381, 390, 409, 409–410, 419, 419, 421, 430, 430, 432, 442, 442–443, 453, 453–454, 465, 465–466, 566, 575, 626–627, 630, 633
   HellsKitchen.sol75%50%100%100%20
   MadBalls.sol75%50%100%100%20
   ParisHilton.sol75%50%100%100%20
   Rabbids.sol75%50%100%100%20

Please sign in to comment.