pub struct AccessControlSpec;Implementations§
Source§impl AccessControlSpec
impl AccessControlSpec
Sourcepub const fn spec_xdr_has_role() -> [u8; 444]
pub const fn spec_xdr_has_role() -> [u8; 444]
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.
Source§impl AccessControlSpec
impl AccessControlSpec
Sourcepub const fn spec_xdr_get_existing_roles() -> [u8; 332]
pub const fn spec_xdr_get_existing_roles() -> [u8; 332]
Source§impl AccessControlSpec
impl AccessControlSpec
Sourcepub const fn spec_xdr_get_role_member_count() -> [u8; 264]
pub const fn spec_xdr_get_role_member_count() -> [u8; 264]
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.
Source§impl AccessControlSpec
impl AccessControlSpec
Sourcepub const fn spec_xdr_get_role_member() -> [u8; 704]
pub const fn spec_xdr_get_role_member() -> [u8; 704]
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.
Source§impl AccessControlSpec
impl AccessControlSpec
Sourcepub const fn spec_xdr_get_role_admin() -> [u8; 260]
pub const fn spec_xdr_get_role_admin() -> [u8; 260]
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.
Source§impl AccessControlSpec
impl AccessControlSpec
Sourcepub const fn spec_xdr_get_admin() -> [u8; 120]
pub const fn spec_xdr_get_admin() -> [u8; 120]
Source§impl AccessControlSpec
impl AccessControlSpec
Sourcepub const fn spec_xdr_grant_role() -> [u8; 664]
pub const fn spec_xdr_grant_role() -> [u8; 664]
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 theRoleAdminfor therole.
§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]
Source§impl AccessControlSpec
impl AccessControlSpec
Sourcepub const fn spec_xdr_revoke_role() -> [u8; 784]
pub const fn spec_xdr_revoke_role() -> [u8; 784]
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 theRoleAdminfor therole.
§Errors
AccessControlError::Unauthorized- If thecallerdoes not have enough privileges.AccessControlError::RoleNotHeld- If theaccountdoesn’t have the role.AccessControlError::RoleIsEmpty- If the role has no members.
§Events
- topics -
["role_revoked", role: Symbol, account: Address] - data -
[caller: Address]
Source§impl AccessControlSpec
impl AccessControlSpec
Sourcepub const fn spec_xdr_renounce_role() -> [u8; 608]
pub const fn spec_xdr_renounce_role() -> [u8; 608]
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 thecallerdoesn’t have the role.AccessControlError::RoleIsEmpty- If the role has no members.
§Events
- topics -
["role_revoked", role: Symbol, account: Address] - data -
[caller: Address]
Source§impl AccessControlSpec
impl AccessControlSpec
Sourcepub const fn spec_xdr_accept_admin_transfer() -> [u8; 1068]
pub const fn spec_xdr_accept_admin_transfer() -> [u8; 1068]
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. Iflive_until_ledgeris0, the pending transfer is cancelled.live_until_ledgerargument 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 providednewaddress.AccessControlError::AdminNotSet- If admin account is not set.
§Events
- topics -
["admin_transfer_initiated", current_admin: Address] - data -
[new_admin: Address, live_until_ledger: u32]
§Notes
- Authorization for the current admin is required.
Source§impl AccessControlSpec
impl AccessControlSpec
Sourcepub const fn spec_xdr_transfer_admin_role() -> [u8; 488]
pub const fn spec_xdr_transfer_admin_role() -> [u8; 488]
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.
Source§impl AccessControlSpec
impl AccessControlSpec
Sourcepub const fn spec_xdr_set_role_admin() -> [u8; 524]
pub const fn spec_xdr_set_role_admin() -> [u8; 524]
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.
Source§impl AccessControlSpec
impl AccessControlSpec
Sourcepub const fn spec_xdr_renounce_admin() -> [u8; 540]
pub const fn spec_xdr_renounce_admin() -> [u8; 540]
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.
Auto Trait Implementations§
impl Freeze for AccessControlSpec
impl RefUnwindSafe for AccessControlSpec
impl Send for AccessControlSpec
impl Sync for AccessControlSpec
impl Unpin for AccessControlSpec
impl UnwindSafe for AccessControlSpec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for C
impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for C
type Error = E
fn compare( &self, a: &(T, U, V, W), b: &(T, U, V, W), ) -> Result<Ordering, <C as Compare<(T, U, V, W)>>::Error>
Source§impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for C
impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for C
type Error = E
fn compare( &self, a: &(T, U, V, W, X), b: &(T, U, V, W, X), ) -> Result<Ordering, <C as Compare<(T, U, V, W, X)>>::Error>
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more