Contract 0d99a45805a84959350f12fb7655ea90ba21767170f9516028ea9853600f0b24

← Back to Index 📥 Download WASM

Meta

cliver 28.0.0#300aaf69ab100536678bdb641428b06f06b318ea
rssdk_spec_shaking 2
rssdkver 27.0.2#45d378a6cb4a026d23fc7286b6ee3add9c9dd0b9
rsver 1.98.1

Instances

  • CCX7CZKKBMZ7HACOPBK7SHJLKRBDLQQGRNIVCCPUSHRYS7OZ37YTKIG7

Interface

Called whenever tokens are created on a wallet.

This function calls all modules registered for the Created hook. A module rejects the mint by panicking, which reverts the whole operation; otherwise it updates its own state as needed.

Arguments

  • e - Access to the Soroban environment.
  • to - Snapshot of the receiver, as of before the mint.
  • amount - The amount of tokens involved in the minting.
  • token - The address of the contract that is performing the minting.
fn created(
    env: soroban_sdk::Env,
    to: AccountSnapshot,
    amount: i128,
    token: soroban_sdk::Address,
)

Returns Some(index) if the account has the specified role, where index is the position of the account for that role, and can be used to query [AccessControl::get_role_member()]. Returns None if the account does not have the specified role.

Arguments

  • e - Access to Soroban environment.
  • account - The account to check.
  • role - The role to check for.
fn has_role(
    env: soroban_sdk::Env,
    account: soroban_sdk::Address,
    role: soroban_sdk::Symbol,
) -> Option

Called whenever tokens are destroyed from a wallet.

This function calls all modules registered for the Destroyed hook. A module rejects the burn by panicking, which reverts the whole operation; otherwise it updates its own state as needed.

Arguments

  • e - Access to the Soroban environment.
  • from - Snapshot of the burned wallet, as of before the burn.
  • amount - The amount of tokens involved in the burn.
  • token - The address of the token contract that is performing the burn.
fn destroyed(
    env: soroban_sdk::Env,
    from: AccountSnapshot,
    amount: i128,
    token: soroban_sdk::Address,
)

Returns the admin account.

Arguments

  • e - Access to Soroban environment.
fn get_admin(env: soroban_sdk::Env) -> Option
fn bind_token(
    env: soroban_sdk::Env,
    token: soroban_sdk::Address,
    operator: soroban_sdk::Address,
)

Grants a role to an account.

Arguments

  • e - Access to Soroban environment.
  • account - The account to grant the role to.
  • role - The role to grant.
  • caller - The address of the caller, must be the admin or have the RoleAdmin for the role.

Errors

  • [AccessControlError::Unauthorized] - If the caller does not have enough privileges.
  • [AccessControlError::MaxRolesExceeded] - If adding a new role would exceed the maximum allowed number of roles.

Events

  • topics - ["role_granted", role: Symbol, account: Address]
  • data - [caller: Address]
fn grant_role(
    env: soroban_sdk::Env,
    account: soroban_sdk::Address,
    role: soroban_sdk::Symbol,
    caller: soroban_sdk::Address,
)
fn bind_tokens(
    env: soroban_sdk::Env,
    tokens: soroban_sdk::Vec,
    operator: soroban_sdk::Address,
)

Revokes a role from an account. To revoke the caller's own role, use [AccessControl::renounce_role()] instead.

Arguments

  • e - Access to Soroban environment.
  • account - The account to revoke the role from.
  • role - The role to revoke.
  • caller - The address of the caller, must be the admin or has the RoleAdmin for the role.

Errors

  • [AccessControlError::Unauthorized] - If the caller does not have enough privileges.
  • [AccessControlError::RoleNotHeld] - If the account doesn't have the role.
  • [AccessControlError::RoleIsEmpty] - If the role has no members.

Events

  • topics - ["role_revoked", role: Symbol, account: Address]
  • data - [caller: Address]
fn revoke_role(
    env: soroban_sdk::Env,
    account: soroban_sdk::Address,
    role: soroban_sdk::Symbol,
    caller: soroban_sdk::Address,
)

Called whenever tokens are transferred from one wallet to another.

This function calls all modules registered for the Transferred hook. A module rejects the transfer by panicking, which reverts the whole operation; otherwise it updates its own state as needed.

Arguments

  • e - Access to the Soroban environment.
  • from - Snapshot of the sender, as of before the transfer.
  • to - Snapshot of the receiver, as of before the transfer.
  • amount - The amount of tokens involved in the transfer.
  • kind - Who initiated the transfer and under what authority; see [TransferKind].
  • token - The address of the token contract that is performing the transfer.
fn transferred(
    env: soroban_sdk::Env,
    from: AccountSnapshot,
    to: AccountSnapshot,
    amount: i128,
    kind: TransferKind,
    token: soroban_sdk::Address,
)
fn unbind_token(
    env: soroban_sdk::Env,
    token: soroban_sdk::Address,
    operator: soroban_sdk::Address,
)
fn __constructor(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    manager: soroban_sdk::Address,
)
fn add_module_to(
    env: soroban_sdk::Env,
    hook: ComplianceHook,
    module: soroban_sdk::Address,
    operator: soroban_sdk::Address,
)

Returns all currently bound token addresses.

Arguments

  • e - The Soroban environment
fn linked_tokens(env: soroban_sdk::Env) -> soroban_sdk::Vec

Allows an account to renounce a role assigned to itself. Users can only renounce roles for their own account.

Arguments

  • e - Access to Soroban environment.
  • role - The role to renounce.
  • caller - The address of the caller, must be the account that has the role.

Errors

  • [AccessControlError::RoleNotHeld] - If the caller doesn't have the role.
  • [AccessControlError::RoleIsEmpty] - If the role has no members.

Events

  • topics - ["role_revoked", role: Symbol, account: Address]
  • data - [caller: Address]
fn renounce_role(
    env: soroban_sdk::Env,
    role: soroban_sdk::Symbol,
    caller: soroban_sdk::Address,
)

Returns the admin role for a specific role. If no admin role is explicitly set, returns None.

Arguments

  • e - Access to Soroban environment.
  • role - The role to query the admin role for.
fn get_role_admin(
    env: soroban_sdk::Env,
    role: soroban_sdk::Symbol,
) -> Option

Allows the current admin to renounce their role, making the contract permanently admin-less. This is useful for decentralization purposes or when the admin role is no longer needed. Once the admin is renounced, it cannot be reinstated.

Arguments

  • e - Access to Soroban environment.

Errors

  • [AccessControlError::AdminNotSet] - If no admin account is set.

Events

  • topics - ["admin_renounced", admin: Address]
  • data - []

Notes

  • Authorization for the current admin is required.
fn renounce_admin(env: soroban_sdk::Env)

Sets admin_role as the admin role of role.

Arguments

  • e - Access to Soroban environment.
  • role - The role to set the admin for.
  • admin_role - The new admin role.

Events

  • topics - ["role_admin_changed", role: Symbol]
  • data - [previous_admin_role: Symbol, new_admin_role: Symbol]

Errors

  • [AccessControlError::AdminNotSet] - If admin account is not set.

Notes

  • Authorization for the current admin is required.
fn set_role_admin(
    env: soroban_sdk::Env,
    role: soroban_sdk::Symbol,
    admin_role: soroban_sdk::Symbol,
)

Returns the account at the specified index for a given role.

A function to get all members of a role is not provided because that would be unbounded. To enumerate all members of a role, use [AccessControl::get_role_member_count()] to get the total number of members and then use [AccessControl::get_role_member()] to retrieve each member one by one.

Arguments

  • e - Access to Soroban environment.
  • role - The role to query.
  • index - The index of the account to retrieve.

Errors

  • [AccessControlError::IndexOutOfBounds] - If the index is out of bounds for the role's member list.
fn get_role_member(
    env: soroban_sdk::Env,
    role: soroban_sdk::Symbol,
    index: u32,
) -> soroban_sdk::Address

Returns a vector containing all existing roles. Defaults to empty vector if no roles exist.

Arguments

  • e - Access to Soroban environment.

Notes

This function returns all roles that currently have at least one member. The maximum number of roles is limited by [MAX_ROLES].

fn get_existing_roles(env: soroban_sdk::Env) -> soroban_sdk::Vec
fn remove_module_from(
    env: soroban_sdk::Env,
    hook: ComplianceHook,
    module: soroban_sdk::Address,
    operator: soroban_sdk::Address,
)

Initiates the admin role transfer. Admin privileges for the current admin are not revoked until the recipient accepts the transfer. Overrides the previous pending transfer if there is one.

Arguments

  • e - Access to Soroban environment.
  • new_admin - The account to transfer the admin privileges to.
  • live_until_ledger - The ledger number at which the pending transfer expires. If live_until_ledger is 0, the pending transfer is cancelled. live_until_ledger argument is implicitly bounded by the maximum allowed TTL extension for a temporary storage entry and specifying a higher value will cause the code to panic.

Errors

  • [crate::role_transfer::RoleTransferError::NoPendingTransfer] - If trying to cancel a transfer that doesn't exist.
  • [crate::role_transfer::RoleTransferError::InvalidLiveUntilLedger] - If the specified ledger is in the past.
  • [crate::role_transfer::RoleTransferError::InvalidPendingAccount] - If the specified pending account is not the same as the provided new address.
fn transfer_admin_role(
    env: soroban_sdk::Env,
    new_admin: soroban_sdk::Address,
    live_until_ledger: u32,
)

Gets all modules registered for a specific hook type.

Arguments

  • e - Access to the Soroban environment.
  • hook - The hook type to query.

Returns

A vector of module addresses registered for the specified hook.

fn get_modules_for_hook(
    env: soroban_sdk::Env,
    hook: ComplianceHook,
) -> soroban_sdk::Vec

Checks if a module is registered for a specific hook type.

Arguments

  • e - Access to the Soroban environment.
  • hook - The hook type to check.
  • module - The address of the module to check.

Returns

true if the module is registered for the hook, false otherwise.

fn is_module_registered(
    env: soroban_sdk::Env,
    hook: ComplianceHook,
    module: soroban_sdk::Address,
) -> bool

Completes the 2-step admin transfer.

Arguments

  • e - Access to Soroban environment.

Events

  • topics - ["admin_transfer_completed", new_admin: Address]
  • data - [previous_admin: Address]

Errors

  • [crate::role_transfer::RoleTransferError::NoPendingTransfer] - If there is no pending transfer to accept.
  • [AccessControlError::AdminNotSet] - If admin account is not set.
fn accept_admin_transfer(env: soroban_sdk::Env)

Returns the total number of accounts that have the specified role. If the role does not exist, returns 0.

Arguments

  • e - Access to Soroban environment.
  • role - The role to get the count for.
fn get_role_member_count(env: soroban_sdk::Env, role: soroban_sdk::Symbol) -> u32

Imports

WebAssembly Text (WAT) ▶