Struct AccessControl

Source
pub struct AccessControl { /* private fields */ }
Expand description

State of an AccessControl contract.

Implementations§

Source§

impl AccessControl

Source

pub const DEFAULT_ADMIN_ROLE: [u8; 32]

The default admin role. [0; 32] by default.

Source

pub fn _set_role_admin(&mut self, role: B256, new_admin_role: B256)

Sets admin_role as role’s admin role.

§Arguments
  • &mut self - Write access to the contract’s state.
  • role - The identifier of the role we are changing the admin to.
  • new_admin_role - The new admin role.
§Events
Source

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
Source

pub fn _grant_role(&mut self, role: B256, account: Address) -> bool

Attempts to grant role to account and returns a boolean indicating if role was granted.

Internal function without access restriction.

§Arguments
  • &mut self - Write access to the contract’s state.
  • role - The role identifier.
  • account - The account which will be granted the role.
§Events
Source

pub fn _revoke_role(&mut self, role: B256, account: Address) -> bool

Attempts to revoke role from account and returns a boolean indicating if role was revoked.

Internal function without access restriction.

§Arguments
  • &mut self - Write access to the contract’s state.
  • role - The role identifier.
  • account - The account which will be granted the role.
§Events

Trait Implementations§

Source§

impl ConstructorGuard for AccessControl

Source§

impl HostAccess for AccessControl

Source§

fn vm(&self) -> &dyn Host

Provides access to the parametrized host of a contract, giving access to all the desired hostios from the user.
Source§

impl IAccessControl for AccessControl

Source§

type Error = Error

The error type associated with this interface implementation.
Source§

fn has_role(&self, role: B256, account: Address) -> bool

Returns true if account has been granted role. Read more
Source§

fn only_role(&self, role: B256) -> Result<(), Self::Error>

Checks if msg::sender has been granted role. Read more
Source§

fn get_role_admin(&self, role: B256) -> B256

Returns the admin role that controls role. See IAccessControl::grant_role and IAccessControl::revoke_role. Read more
Source§

fn grant_role( &mut self, role: B256, account: Address, ) -> Result<(), Self::Error>

Grants role to account. Read more
Source§

fn revoke_role( &mut self, role: B256, account: Address, ) -> Result<(), Self::Error>

Revokes role from account. Read more
Source§

fn renounce_role( &mut self, role: B256, confirmation: Address, ) -> Result<(), Self::Error>

Revokes role from the calling account. Read more
Source§

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

Source§

fn supports_interface(&self, interface_id: FixedBytes<4>) -> bool

Returns true if this contract implements the interface defined by interface_id. See the corresponding ERC to learn more about how these ids are created. Read more
Source§

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

Source§

type Storage = AccessControl

The type the TopLevelStorage borrows into. Usually just Self.
Source§

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>

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

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>

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

Source§

type Storage = AccessControl

The type the TopLevelStorage borrows into. Usually just Self.
Source§

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>

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

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>

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

Source§

type Storage = AccessControl

The type the TopLevelStorage borrows into. Usually just Self.
Source§

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>

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

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>

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

Source§

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 more
Source§

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

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

Mutable accessor to the type being stored.
Source§

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 more
Source§

fn load<'s>(self) -> Self::Wraps<'s>

Load the wrapped type, consuming the accessor. Note: most types have a get and/or getter, which don’t consume Self.
Source§

fn load_mut<'s>(self) -> Self::WrapsMut<'s>

Load the wrapped mutable type, consuming the accessor. Note: most types have a set and/or setter, which don’t consume Self.
Source§

impl ValueDenier for AccessControl

Source§

fn deny_value(&self, method_name: &str) -> Result<(), Vec<u8>>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.