Contract 49e1153e35206d1b1ec54ef3f68818716a8fa80cb470596396ba50803e601681

← Back to Index 📥 Download WASM

Meta

cliver 25.1.0#
rssdkver 25.1.0#86c50a1ea4f87b40add3064ff9df95c7553565c5
rsver 1.93.0

Instances

  • CC6ET3MMN4UTFBEYRNEKK7DHV3HLDV2UVSTAOLWDKEKKNBUPFFP3T3C3

Interface

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

Cancels a scheduled operation.

Arguments

  • e - Access to Soroban environment.
  • operation_id - The unique identifier of the operation to cancel.
  • canceller - The address cancelling the operation (must have canceller role).

Notes

  • Authorization for canceller is required.
  • The canceller must have the CANCELLER_ROLE.
fn cancel_op(
    env: soroban_sdk::Env,
    operation_id: soroban_sdk::BytesN<32>,
    canceller: soroban_sdk::Address,
)

Returns the admin account.

Arguments

  • e - Access to Soroban environment.
fn get_admin(env: soroban_sdk::Env) -> Option

Executes a scheduled operation that is ready.

Note: This function is only for executing operations on external contracts. For self-administration operations (where target is this timelock contract), call the admin function directly instead.

Arguments

  • e - Access to Soroban environment.
  • target - The target contract address.
  • function - The function name to invoke.
  • args - The arguments to pass to the function.
  • predecessor - The predecessor operation ID.
  • salt - Salt for uniqueness.
  • executor - The address executing the operation (must have executor role if configured).

Returns

The return value from the executed operation.

Notes

  • If executors are configured (EXECUTOR_ROLE has members), authorization for executor is required and the executor must have the EXECUTOR_ROLE.
  • If no executors are configured, anyone can execute ready operations.
fn execute_op(
    env: soroban_sdk::Env,
    target: soroban_sdk::Address,
    function: soroban_sdk::Symbol,
    args: soroban_sdk::Vec,
    predecessor: soroban_sdk::BytesN<32>,
    salt: soroban_sdk::BytesN<32>,
    executor: Option,
) -> soroban_sdk::Val

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,
)

Revokes a role from an account. To revoke your own role, please 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,
)

Schedules an operation for execution after a delay.

Arguments

  • e - Access to Soroban environment.
  • target - The target contract address.
  • function - The function name to invoke.
  • args - The arguments to pass to the function.
  • predecessor - The predecessor operation ID (use all zeros for none).
  • salt - Salt for uniqueness (use all zeros for default).
  • delay - The delay in seconds before the operation can be executed.
  • proposer - The address proposing the operation (must have proposer role).

Returns

The unique identifier (hash) of the scheduled operation.

Notes

  • Authorization for proposer is required.
  • The proposer must have the PROPOSER_ROLE.
  • The delay must be >= the minimum delay.
fn schedule_op(
    env: soroban_sdk::Env,
    target: soroban_sdk::Address,
    function: soroban_sdk::Symbol,
    args: soroban_sdk::Vec,
    predecessor: soroban_sdk::BytesN<32>,
    salt: soroban_sdk::BytesN<32>,
    delay: u32,
    proposer: soroban_sdk::Address,
) -> soroban_sdk::BytesN<32>

Custom authorization check for self-administration operations.

This enables the timelock contract to execute operations on itself when the admin is set to the contract's own address. Unlike external operations which use execute_op, self-administration operations are executed by calling the admin function directly (e.g., update_delay, grant_role).

The __check_auth implementation validates that:

  • The operation targets the timelock contract itself
  • The operation was properly scheduled and is ready for execution
  • The predecessor and salt match the scheduled operation
  • The executor (if any) has role and has authorized the invocation

The caller must construct an OperationMeta signature containing the predecessor and salt values that were used when scheduling the operation, allowing this function to validate and mark the operation as executed.

fn __check_auth(
    env: soroban_sdk::Env,
    signature_payload: soroban_sdk::BytesN<32>,
    context_meta: soroban_sdk::Vec,
    auth_contexts: soroban_sdk::Vec,
) -> Result<(), soroban_sdk::Error>

Updates the minimum delay for future operations.

Arguments

  • e - Access to Soroban environment.
  • new_delay - The new minimum delay in seconds.

Notes

  • Authorization for admin is required.
  • This function should typically be called through the timelock itself (self-administration) to ensure transparency.
fn update_delay(env: soroban_sdk::Env, new_delay: u32)

Initializes the timelock controller.

Arguments

  • e - Access to Soroban environment.
  • min_delay - Initial minimum delay in seconds for operations.
  • proposers - Accounts to be granted proposer and canceller roles.
  • executors - Accounts to be granted executor role.
  • admin - Optional account to be granted a bootstrap role for initial setup. The contract itself is always the admin (self-administration).

Notes

  • The contract itself is always the admin.
  • Proposers are automatically granted the canceller role.
  • If an external admin is provided, they receive the bootstrap role that can manage proposer/executor/canceller roles and should renounce it after initial configuration.
fn __constructor(
    env: soroban_sdk::Env,
    min_delay: u32,
    proposers: soroban_sdk::Vec,
    executors: soroban_sdk::Vec,
    admin: Option,
)

Executes a ready batch of operations.

Note: This function is only for executing operations on external contracts. For self-administration operations, call the admin function directly instead.

Arguments

  • e - Access to Soroban environment.
  • targets - The target contract addresses.
  • functions - The function names to invoke.
  • args_list - The arguments for each function.
  • predecessor - The predecessor operation ID.
  • salt - Salt for uniqueness.
  • executor - The address executing the operation (must have executor role if configured).

Returns

The return values from the executed operations.

fn execute_batch(
    env: soroban_sdk::Env,
    targets: soroban_sdk::Vec,
    functions: soroban_sdk::Vec,
    args_list: soroban_sdk::Vec>,
    predecessor: soroban_sdk::BytesN<32>,
    salt: soroban_sdk::BytesN<32>,
    executor: Option,
) -> soroban_sdk::Vec

Returns the minimum delay in seconds required for operations.

fn get_min_delay(env: soroban_sdk::Env) -> u32

Returns the timestamp at which an operation becomes ready.

Arguments

  • e - Access to Soroban environment.
  • operation_id - The unique identifier of the operation.

Returns

The timestamp (in seconds) when the operation becomes ready. Returns 0 if the operation doesn't exist or is done.

fn get_timestamp(env: soroban_sdk::Env, operation_id: soroban_sdk::BytesN<32>) -> u64

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

Computes the unique identifier for an operation.

Arguments

  • e - Access to Soroban environment.
  • target - The target contract address.
  • function - The function name to invoke.
  • args - The arguments to pass to the function.
  • predecessor - The predecessor operation ID.
  • salt - Salt for uniqueness.

Returns

The unique identifier (hash) for the operation.

fn hash_operation(
    env: soroban_sdk::Env,
    target: soroban_sdk::Address,
    function: soroban_sdk::Symbol,
    args: soroban_sdk::Vec,
    predecessor: soroban_sdk::BytesN<32>,
    salt: soroban_sdk::BytesN<32>,
) -> soroban_sdk::BytesN<32>

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)

Schedules a batch of operations for execution after a delay.

Arguments

  • e - Access to Soroban environment.
  • targets - The target contract addresses.
  • functions - The function names to invoke.
  • args_list - The arguments for each function.
  • predecessor - The predecessor operation ID (use all zeros for none).
  • salt - Salt for uniqueness (use all zeros for default).
  • delay - The delay in seconds before the operations can be executed.
  • proposer - The address proposing the operation (must have proposer role).

Returns

The unique identifier (hash) of the scheduled batch.

Notes

  • Authorization for proposer is required.
  • The proposer must have the PROPOSER_ROLE.
  • The delay must be >= the minimum delay.
fn schedule_batch(
    env: soroban_sdk::Env,
    targets: soroban_sdk::Vec,
    functions: soroban_sdk::Vec,
    args_list: soroban_sdk::Vec>,
    predecessor: soroban_sdk::BytesN<32>,
    salt: soroban_sdk::BytesN<32>,
    delay: u32,
    proposer: soroban_sdk::Address,
) -> soroban_sdk::BytesN<32>

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.

We do not provide a function to get all the members of a role, since that would be unbounded. If you need to enumerate all the members of a role, you can use [AccessControl::get_role_member_count()] to get the total number of members and then use [AccessControl::get_role_member()] to get 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 whether an operation exists (scheduled or done).

Arguments

  • e - Access to Soroban environment.
  • operation_id - The unique identifier of the operation.

Returns

true if the operation exists, false otherwise.

fn operation_exists(
    env: soroban_sdk::Env,
    operation_id: soroban_sdk::BytesN<32>,
) -> bool

Returns whether an operation has been executed.

Arguments

  • e - Access to Soroban environment.
  • operation_id - The unique identifier of the operation.

Returns

true if the operation has been executed, false otherwise.

fn is_operation_done(
    env: soroban_sdk::Env,
    operation_id: soroban_sdk::BytesN<32>,
) -> bool

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

Returns whether an operation is ready for execution.

Arguments

  • e - Access to Soroban environment.
  • operation_id - The unique identifier of the operation.

Returns

true if the operation is ready, false otherwise.

fn is_operation_ready(
    env: soroban_sdk::Env,
    operation_id: soroban_sdk::BytesN<32>,
) -> bool

Returns the current state of an operation.

Arguments

  • e - Access to Soroban environment.
  • operation_id - The unique identifier of the operation.

Returns

The current state: Unset, Waiting, Ready, or Done.

fn get_operation_state(
    env: soroban_sdk::Env,
    operation_id: soroban_sdk::BytesN<32>,
) -> OperationState

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 transfer_admin_role(
    env: soroban_sdk::Env,
    new_admin: soroban_sdk::Address,
    live_until_ledger: u32,
)

Computes the unique identifier for a batch of operations.

Arguments

  • e - Access to Soroban environment.
  • targets - The target contract addresses.
  • functions - The function names to invoke.
  • args_list - The arguments for each function.
  • predecessor - The predecessor operation ID.
  • salt - Salt for uniqueness.

Returns

The unique identifier (hash) for the batch.

fn hash_operation_batch(
    env: soroban_sdk::Env,
    targets: soroban_sdk::Vec,
    functions: soroban_sdk::Vec,
    args_list: soroban_sdk::Vec>,
    predecessor: soroban_sdk::BytesN<32>,
    salt: soroban_sdk::BytesN<32>,
) -> soroban_sdk::BytesN<32>

Returns whether an operation is pending (waiting or ready).

Arguments

  • e - Access to Soroban environment.
  • operation_id - The unique identifier of the operation.

Returns

true if the operation is pending, false otherwise.

fn is_operation_pending(
    env: soroban_sdk::Env,
    operation_id: soroban_sdk::BytesN<32>,
) -> bool

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 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) ▶