Skip to content

Commit

Permalink
add setStatesAndMint() function
Browse files Browse the repository at this point in the history
  • Loading branch information
miquelcabot committed Nov 9, 2023
1 parent 9f2b067 commit 6c2a49c
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions contracts/MasaDynamicASBT.sol
Expand Up @@ -46,6 +46,11 @@ contract MasaDynamicASBT is MasaSBTAuthority, MasaSBTDynamic, ReentrancyGuard {

/* ========== RESTRICTED FUNCTIONS ====================================== */

/// @notice Sets the state of an account
/// @dev The caller must have the MINTER role
/// @param account Address of the account to set the state
/// @param state Name of the state to set
/// @param value Value of the state to set
function setState(
address account,
string memory state,
Expand All @@ -54,6 +59,11 @@ contract MasaDynamicASBT is MasaSBTAuthority, MasaSBTDynamic, ReentrancyGuard {
_setState(account, state, value);
}

/// @notice Sets the state of a token
/// @dev The caller must have the MINTER role
/// @param tokenId TokenId of the token to set the state
/// @param state Name of the state to set
/// @param value Value of the state to set
function setState(
uint256 tokenId,
string memory state,
Expand Down Expand Up @@ -102,6 +112,24 @@ contract MasaDynamicASBT is MasaSBTAuthority, MasaSBTDynamic, ReentrancyGuard {
return _mintWithCounter(paymentMethod, to);
}

/// @notice Sets some states of an account and mints
/// @dev The caller must have the MINTER role
/// @param paymentMethod Address of token that user want to pay
/// @param to The address to mint the SBT to
/// @param states Names of the state to set
/// @return The SBT ID of the newly minted SBT
function setStatesAndMint(
address paymentMethod,
address to,
string[] memory states
) external onlyRole(MINTER_ROLE) returns (uint256) {
for (uint256 i = 0; i < states.length; i++) {
_setState(to, states[i], true);
}

return _mintWithCounter(paymentMethod, to);
}

/* ========== MUTATIVE FUNCTIONS ======================================== */

/* ========== VIEWS ===================================================== */
Expand Down

0 comments on commit 6c2a49c

Please sign in to comment.