Skip to content

Over-guarded minting methods #66

@boyswan

Description

@boyswan

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions