pub struct AccessControl { /* private fields */ }
Expand description
State of an AccessControl
contract.
Implementations§
Source§impl AccessControl
impl AccessControl
Sourcepub const DEFAULT_ADMIN_ROLE: [u8; 32]
pub const DEFAULT_ADMIN_ROLE: [u8; 32]
The default admin role. [0; 32]
by default.
Sourcepub fn _set_role_admin(&mut self, role: B256, new_admin_role: B256)
pub fn _set_role_admin(&mut self, role: B256, new_admin_role: B256)
Sourcepub fn _check_role(&self, role: B256, account: Address) -> Result<(), Error>
pub fn _check_role(&self, role: B256, account: Address) -> Result<(), Error>
Checks if account
has been granted role
.
§Arguments
&self
- Read access to the contract’s state.role
- The role identifier.account
- The account to check for membership.
§Errors
Error::UnauthorizedAccount
- Ifmsg::sender
has not been grantedrole
.
Sourcepub fn _grant_role(&mut self, role: B256, account: Address) -> bool
pub fn _grant_role(&mut self, role: B256, account: Address) -> bool
Sourcepub fn _revoke_role(&mut self, role: B256, account: Address) -> bool
pub fn _revoke_role(&mut self, role: B256, account: Address) -> bool
Trait Implementations§
Source§impl ConstructorGuard for AccessControl
impl ConstructorGuard for AccessControl
Source§impl HostAccess for AccessControl
impl HostAccess for AccessControl
Source§impl IAccessControl for AccessControl
impl IAccessControl for AccessControl
Source§fn get_role_admin(&self, role: B256) -> B256
fn get_role_admin(&self, role: B256) -> B256
Returns the admin role that controls
role
. See
IAccessControl::grant_role
and IAccessControl::revoke_role
. Read moreSource§fn renounce_role(
&mut self,
role: B256,
confirmation: Address,
) -> Result<(), Self::Error>
fn renounce_role( &mut self, role: B256, confirmation: Address, ) -> Result<(), Self::Error>
Revokes
role
from the calling account. Read moreSource§fn interface_id() -> FixedBytes<4>where
Self: Sized,
fn interface_id() -> FixedBytes<4>where
Self: Sized,
Solidity interface id associated with IAccessControl trait.
Computed as a XOR of selectors for each function in the trait.
Source§impl IErc165 for AccessControl
impl IErc165 for AccessControl
Source§fn supports_interface(&self, interface_id: FixedBytes<4>) -> bool
fn supports_interface(&self, interface_id: FixedBytes<4>) -> bool
Source§fn interface_id() -> FixedBytes<4>where
Self: Sized,
fn interface_id() -> FixedBytes<4>where
Self: Sized,
Solidity interface id associated with IErc165 trait.
Computed as a XOR of selectors for each function in the trait.
Source§impl<S> Router<S> for AccessControl
impl<S> Router<S> for AccessControl
Source§type Storage = AccessControl
type Storage = AccessControl
The type the
TopLevelStorage
borrows into. Usually just Self
.Source§fn route(storage: &mut S, selector: u32, input: &[u8]) -> Option<ArbResult>
fn route(storage: &mut S, selector: u32, input: &[u8]) -> Option<ArbResult>
Tries to find and execute a method for the given selector, returning
None
if none is found.
Routes add via #[inherit]
will only execute if no match is found among Self
.
This means that it is possible to override a method by redefining it in Self
.Source§fn fallback(storage: &mut S, input: &[u8]) -> Option<ArbResult>
fn fallback(storage: &mut S, input: &[u8]) -> Option<ArbResult>
Called when no receive function is defined.
If no #[fallback] function is defined in the contract, then any transactions that do not
match a selector will revert.
A fallback function may have two different implementations. It can be either declared
without any input or output, or with bytes input calldata and bytes output. If a user
defines a fallback function with no input or output, then this method will be called
and the underlying user-defined function will simply be invoked with no input.
A fallback function can be declared as payable. If not payable, then any transactions
that trigger a fallback with value attached will revert.
Source§fn receive(storage: &mut S) -> Option<Result<(), Vec<u8>>>
fn receive(storage: &mut S) -> Option<Result<(), Vec<u8>>>
Receive function for this contract. Called when no calldata is provided.
A receive function may not be defined, in which case this method will return None.
Receive functions are always payable, take in no inputs, and return no outputs.
If defined, they will always be called when a transaction does not send any
calldata, regardless of the transaction having a value attached.
Source§fn constructor(storage: &mut S, input: &[u8]) -> Option<ArbResult>
fn constructor(storage: &mut S, input: &[u8]) -> Option<ArbResult>
The router_entrypoint calls the constructor when the selector is CONSTRUCTOR_SELECTOR.
The implementation should: decode the calldata and pass the parameters to the user-defined
constructor; and call internal::constructor_guard to ensure it is only executed once.
Since each constructor has its own set of parameters, this function won’t call the
constructors for inherited structs automatically. Instead, the user-defined function should
call the base classes constructors.
A constructor function can be declared as payable. If not payable, then any transactions
that trigger the constructor with value attached will revert.
Source§impl<S> Router<S, dyn IAccessControl<Error = Error>> for AccessControl
impl<S> Router<S, dyn IAccessControl<Error = Error>> for AccessControl
Source§type Storage = AccessControl
type Storage = AccessControl
The type the
TopLevelStorage
borrows into. Usually just Self
.Source§fn route(storage: &mut S, selector: u32, input: &[u8]) -> Option<ArbResult>
fn route(storage: &mut S, selector: u32, input: &[u8]) -> Option<ArbResult>
Tries to find and execute a method for the given selector, returning
None
if none is found.
Routes add via #[inherit]
will only execute if no match is found among Self
.
This means that it is possible to override a method by redefining it in Self
.Source§fn fallback(storage: &mut S, input: &[u8]) -> Option<ArbResult>
fn fallback(storage: &mut S, input: &[u8]) -> Option<ArbResult>
Called when no receive function is defined.
If no #[fallback] function is defined in the contract, then any transactions that do not
match a selector will revert.
A fallback function may have two different implementations. It can be either declared
without any input or output, or with bytes input calldata and bytes output. If a user
defines a fallback function with no input or output, then this method will be called
and the underlying user-defined function will simply be invoked with no input.
A fallback function can be declared as payable. If not payable, then any transactions
that trigger a fallback with value attached will revert.
Source§fn receive(storage: &mut S) -> Option<Result<(), Vec<u8>>>
fn receive(storage: &mut S) -> Option<Result<(), Vec<u8>>>
Receive function for this contract. Called when no calldata is provided.
A receive function may not be defined, in which case this method will return None.
Receive functions are always payable, take in no inputs, and return no outputs.
If defined, they will always be called when a transaction does not send any
calldata, regardless of the transaction having a value attached.
Source§fn constructor(storage: &mut S, input: &[u8]) -> Option<ArbResult>
fn constructor(storage: &mut S, input: &[u8]) -> Option<ArbResult>
The router_entrypoint calls the constructor when the selector is CONSTRUCTOR_SELECTOR.
The implementation should: decode the calldata and pass the parameters to the user-defined
constructor; and call internal::constructor_guard to ensure it is only executed once.
Since each constructor has its own set of parameters, this function won’t call the
constructors for inherited structs automatically. Instead, the user-defined function should
call the base classes constructors.
A constructor function can be declared as payable. If not payable, then any transactions
that trigger the constructor with value attached will revert.
Source§impl<S> Router<S, dyn IErc165> for AccessControl
impl<S> Router<S, dyn IErc165> for AccessControl
Source§type Storage = AccessControl
type Storage = AccessControl
The type the
TopLevelStorage
borrows into. Usually just Self
.Source§fn route(storage: &mut S, selector: u32, input: &[u8]) -> Option<ArbResult>
fn route(storage: &mut S, selector: u32, input: &[u8]) -> Option<ArbResult>
Tries to find and execute a method for the given selector, returning
None
if none is found.
Routes add via #[inherit]
will only execute if no match is found among Self
.
This means that it is possible to override a method by redefining it in Self
.Source§fn fallback(storage: &mut S, input: &[u8]) -> Option<ArbResult>
fn fallback(storage: &mut S, input: &[u8]) -> Option<ArbResult>
Called when no receive function is defined.
If no #[fallback] function is defined in the contract, then any transactions that do not
match a selector will revert.
A fallback function may have two different implementations. It can be either declared
without any input or output, or with bytes input calldata and bytes output. If a user
defines a fallback function with no input or output, then this method will be called
and the underlying user-defined function will simply be invoked with no input.
A fallback function can be declared as payable. If not payable, then any transactions
that trigger a fallback with value attached will revert.
Source§fn receive(storage: &mut S) -> Option<Result<(), Vec<u8>>>
fn receive(storage: &mut S) -> Option<Result<(), Vec<u8>>>
Receive function for this contract. Called when no calldata is provided.
A receive function may not be defined, in which case this method will return None.
Receive functions are always payable, take in no inputs, and return no outputs.
If defined, they will always be called when a transaction does not send any
calldata, regardless of the transaction having a value attached.
Source§fn constructor(storage: &mut S, input: &[u8]) -> Option<ArbResult>
fn constructor(storage: &mut S, input: &[u8]) -> Option<ArbResult>
The router_entrypoint calls the constructor when the selector is CONSTRUCTOR_SELECTOR.
The implementation should: decode the calldata and pass the parameters to the user-defined
constructor; and call internal::constructor_guard to ensure it is only executed once.
Since each constructor has its own set of parameters, this function won’t call the
constructors for inherited structs automatically. Instead, the user-defined function should
call the base classes constructors.
A constructor function can be declared as payable. If not payable, then any transactions
that trigger the constructor with value attached will revert.
Source§impl StorageType for AccessControl
impl StorageType for AccessControl
Source§const SLOT_BYTES: usize = 32usize
const SLOT_BYTES: usize = 32usize
The number of bytes in a slot needed to represent the type. Must not exceed 32.
For types larger than 32 bytes that are stored inline with a struct’s fields,
set this to 32 and return the full size in
StorageType::new
. Read moreSource§const REQUIRED_SLOTS: usize = 1usize
const REQUIRED_SLOTS: usize = 1usize
The number of words this type must fill. For primitives this is always 0.
For complex types requiring more than one inline word, set this to the total size.
Source§type Wraps<'a> = StorageGuard<'a, AccessControl>
where
Self: 'a
type Wraps<'a> = StorageGuard<'a, AccessControl> where Self: 'a
For primitive types, this is the type being stored.
For collections, this is the
StorageType
being collected.Source§type WrapsMut<'a> = StorageGuardMut<'a, AccessControl>
where
Self: 'a
type WrapsMut<'a> = StorageGuardMut<'a, AccessControl> where Self: 'a
Mutable accessor to the type being stored.
Source§unsafe fn new(root: U256, offset: u8, host: VM) -> Self
unsafe fn new(root: U256, offset: u8, host: VM) -> Self
Where in persistent storage the type should live. Although useful for framework designers
creating new storage types, most user programs shouldn’t call this.
Note: implementations will have to be
const
once generic_const_exprs
stabilizes. Read moreSource§impl ValueDenier for AccessControl
impl ValueDenier for AccessControl
Auto Trait Implementations§
impl Freeze for AccessControl
impl RefUnwindSafe for AccessControl
impl Send for AccessControl
impl Sync for AccessControl
impl Unpin for AccessControl
impl UnwindSafe for AccessControl
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
Mutably borrows from an owned value. Read more