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

Limited use bug in permissioning #684

Open
SlayerAnsh opened this issue Dec 3, 2024 · 1 comment
Open

Limited use bug in permissioning #684

SlayerAnsh opened this issue Dec 3, 2024 · 1 comment
Labels
bug Something isn't working permissioning

Comments

@SlayerAnsh
Copy link
Contributor

Describe the bug
Limited use in permissioning consumes two usage

Error Code
NA

To Reproduce
Steps to reproduce the behavior:

  1. Set limited use to 1 for mint in cw721
  2. Try to mint (It will error)
  3. Set limited use to 2 for any mint
  4. Try to mint (Success)
  5. Checking remaining usage returns 0 indicated 2 uses were consumed in 1 action

Expected behavior
Only 1 usage should be used

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • Chain

Additional context
Here Limited use permission is consumed for one action. But later its also consumed in execute_mint. This is causing consumption of 2 uses and error if there is only 1 usage allowed

@SlayerAnsh SlayerAnsh added bug Something isn't working permissioning labels Dec 3, 2024
@joemonem
Copy link
Contributor

Seems that the issue's been resolved?

let minter = ANDR_MINTER
            .load($ctx.deps.storage)?
            .get_raw_address(&$ctx.deps.as_ref())?;

        let is_minter = $ctx.info.sender == minter.as_str();
        // We check if the sender is the minter before checking if they have the mint permission
        // to prevent consuming unnecessary limited permission usage.
        let has_mint_permission = is_minter
            || is_context_permissioned(
                &mut $ctx.deps,
                &$ctx.info,
                &$ctx.env,
                &$ctx.amp_ctx,
                MINT_ACTION,
            )?;

cc: @crnbarr93

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working permissioning
Projects
None yet
Development

No branches or pull requests

2 participants