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

Over-guarded minting methods #66

Open
boyswan opened this issue Apr 19, 2023 · 1 comment
Open

Over-guarded minting methods #66

boyswan opened this issue Apr 19, 2023 · 1 comment

Comments

@boyswan
Copy link
Contributor

boyswan commented Apr 19, 2023

Currently we set access control on minting trait methods by default, protecting methods from unauthorized access.

#[modifiers(only_role(CONTRIBUTOR))]
default fn mint(&mut self, to: AccountId, token_id: Id) -> Result<()> {
    self._check_amount(1)?;
    self._mint_to(to, token_id)?;
    Ok(())
}

However this means the guarded methods cannot be used from within a user-facing method of the contract, for example:

// ...Rmrk contract

#[ink(message, payable)]
pub fn public_mint_example(&mut self) -> Result<()> {
    // minting logic
    Minting::mint(self, Self::env().caller());
}

In this case, mint can only be called by a contributor. The only way around this is to call it from another contract which has been granted the contributor role.

Some possible solutions are:

  • Guards are not provided, and is up to the user to implement by overriding methods
  • Move all logic from the minting traits into Internal and making Internal trait public. Allows user flexibility but feels like a bit of a leak.
@boyswan boyswan changed the title Guarded minting methods Over-guarded minting methods Apr 19, 2023
@boyswan
Copy link
Contributor Author

boyswan commented Apr 20, 2023

This issue is also exacerbated by the removal of mint_many in the core implementation in #65.

In order to mint multiple tokens in a single transaction, a user will need to call mint in a for-loop, which would be multiple cross-contract calls and very expensive.

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

No branches or pull requests

1 participant