Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use _numberMinted on edition instead of tally on minter #233

Merged

Conversation

vigneshka
Copy link
Contributor

No description provided.

@linear
Copy link

linear bot commented Sep 19, 2022

PRO-398 maxMintablePerAccount checks against a global minted tally

Currently, we have

mapping(address => mapping(uint256 => mapping(address => uint256))) public mintedTallies;

in each minter that is incremented and checked

We have a block where this tally is checked to revert when the MaxPerAccount it hit

unchecked {
            uint256 userMintedBalance = mintedTallies[edition][mintId][msg.sender];
            // Check the additional quantity does not exceed the set maximum.
            // If `quantity` is large enough to cause an overflow,
            // `_mint` will give an out of gas error.
            uint256 tally = userMintedBalance + quantity;
            if (tally > data.maxMintablePerAccount) revert ExceedsMaxPerAccount();
            // Update the minted tally for this account
            mintedTallies[edition][mintId][msg.sender] = tally;
        }

We currently enforce a separate MaxPerAccount per minter. Aka if you have a limit of 1 for a merkle drop and a limit of 5 on the range edition minter, the user would be able to mint 6 total.

Instead, we want to change this so the cap is enforced against a global cap. If the user has minted 1 on the merkle drop, they would be able to mint 4 more on the public sale.

We can do this by exposing _numberMinted() in 721a and referencing that in the minter. Can delete the storage write to mintedTallies in each minter and save gas per mint.

@changeset-bot
Copy link

changeset-bot bot commented Sep 19, 2022

🦋 Changeset detected

Latest commit: e87b73f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@soundxyz/sound-protocol Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov
Copy link

codecov bot commented Sep 19, 2022

Codecov Report

Merging #233 (e87b73f) into master (c768a43) will decrease coverage by 0.13%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #233      +/-   ##
==========================================
- Coverage   85.95%   85.81%   -0.14%     
==========================================
  Files          12       12              
  Lines         413      409       -4     
  Branches       59       59              
==========================================
- Hits          355      351       -4     
  Misses         51       51              
  Partials        7        7              
Impacted Files Coverage Δ
contracts/core/SoundEditionV1.sol 97.60% <100.00%> (+0.03%) ⬆️
contracts/modules/EditionMaxMinter.sol 100.00% <100.00%> (ø)
contracts/modules/MerkleDropMinter.sol 97.14% <100.00%> (-0.16%) ⬇️
contracts/modules/RangeEditionMinter.sol 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@vigneshka vigneshka merged commit 06dc842 into master Sep 19, 2022
@vigneshka vigneshka deleted the vignesh/pro-398-maxmintableperaccount-checks-against-a branch September 19, 2022 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants