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

fix: Improve mint limit check in LimitedMintPerAddress #492

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

VolodymyrBg
Copy link

Description

Modified the _requireMintNotOverLimitAndUpdate function in LimitedMintPerAddress.sol to check the mint limit before updating the counter. This prevents unnecessary state changes when the transaction would revert due to exceeding the limit.

Changes:

  • Calculate new mint count before updating state
  • Check limit against calculated value
  • Update state only if limit check passes
  • Provide more accurate error message with attempted mint count

Motivation and Context

The previous implementation updated the state before checking the limit, which could lead to unnecessary state changes in case of a revert. This change makes the contract more gas efficient and provides better error reporting.

Benefits:

  • More gas efficient - no state changes if limit would be exceeded
  • Better error messages - shows attempted mint count rather than partially updated state
  • Follows check-effects-interactions pattern
  • More predictable behavior

Does this change the ABI/API?

  • This changes the ABI/API

No ABI changes - this is an internal implementation improvement.

What tests did you add/modify to account for these changes

Existing tests continue to pass as the external behavior remains the same. The change only affects internal implementation details and error reporting.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New module / feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I added a changeset to account for this change

Reviewer Checklist:

  • My review includes a symposis of the changes and potential issues
  • The code style is enforced
  • There are no risky / concerning changes / additions to the PR

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.

1 participant