pub struct Ownable { /* private fields */ }Expand description
This module provides a straightforward access control feature that enables
exclusive access to particular functions by an account, known as the owner.
The account that initiates contract deployment is automatically assigned as
the owner. However, ownership can be transferred later by using the
transfer_ownership() function.
You can use this module as a standalone contract or integrate it into a custom module by adding it as a field.
When used in a custom module, the only_owner() function is available,
allowing you to restrict function usage to the owner.
Implementations§
Source§impl Ownable
impl Ownable
Sourcepub fn init(&mut self, owner: Address)
pub fn init(&mut self, owner: Address)
Initializes the module setting an owner as the initial owner.
Sourcepub fn transfer_ownership(&mut self, new_owner: &Address)
pub fn transfer_ownership(&mut self, new_owner: &Address)
Transfers ownership of the module to new_owner. This function can only
be accessed by the current owner of the module.
Sourcepub fn renounce_ownership(&mut self)
pub fn renounce_ownership(&mut self)
If the contract’s owner chooses to renounce their ownership, the contract will no longer have an owner. This means that any functions that can only be accessed by the owner will no longer be available.
The function can only be called by the current owner, and it will permanently remove the owner’s privileges.
Sourcepub fn assert_owner(&self, address: &Address)
pub fn assert_owner(&self, address: &Address)
Reverts with Error::CallerNotTheOwner if the function called by
any account other than the owner.
Sourcepub fn get_optional_owner(&self) -> Option<Address>
pub fn get_optional_owner(&self) -> Option<Address>
Returns the optional address of the current owner.
Sourcepub fn unchecked_transfer_ownership(&mut self, new_owner: Option<Address>)
pub fn unchecked_transfer_ownership(&mut self, new_owner: Option<Address>)
Unchecked version of the ownership transfer. It emits an event and sets the new owner.
Trait Implementations§
Source§impl HasEntrypoints for Ownable
impl HasEntrypoints for Ownable
Source§fn entrypoints() -> Vec<Entrypoint>
fn entrypoints() -> Vec<Entrypoint>
Source§impl Module for Ownable
impl Module for Ownable
Source§fn new(env: Rc<ContractEnv>) -> Self
fn new(env: Rc<ContractEnv>) -> Self
Source§fn env(&self) -> Rc<ContractEnv>
fn env(&self) -> Rc<ContractEnv>
Source§impl OdraContract for Ownable
impl OdraContract for Ownable
Source§type HostRef = OwnableHostRef
type HostRef = OwnableHostRef
Source§type ContractRef = OwnableContractRef
type ContractRef = OwnableContractRef
Source§type InitArgs = OwnableInitArgs
type InitArgs = OwnableInitArgs
Source§type UpgradeArgs = NoArgs
type UpgradeArgs = NoArgs
Source§impl SchemaCustomTypes for Ownable
impl SchemaCustomTypes for Ownable
Source§fn schema_types() -> Vec<Option<CustomType>>
fn schema_types() -> Vec<Option<CustomType>>
Source§impl SchemaEntrypoints for Ownable
impl SchemaEntrypoints for Ownable
Source§fn schema_entrypoints() -> Vec<Entrypoint>
fn schema_entrypoints() -> Vec<Entrypoint>
Source§impl SchemaErrors for Ownable
impl SchemaErrors for Ownable
Source§impl SchemaEvents for Ownable
impl SchemaEvents for Ownable
Source§fn custom_types() -> Vec<Option<CustomType>>
fn custom_types() -> Vec<Option<CustomType>>
Auto Trait Implementations§
impl Freeze for Ownable
impl !RefUnwindSafe for Ownable
impl !Send for Ownable
impl !Sync for Ownable
impl Unpin for Ownable
impl !UnwindSafe for Ownable
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<R> Deployer<R> for Rwhere
R: OdraContract,
impl<R> Deployer<R> for Rwhere
R: OdraContract,
Source§fn deploy(
env: &HostEnv,
init_args: <R as OdraContract>::InitArgs,
) -> <R as OdraContract>::HostRef
fn deploy( env: &HostEnv, init_args: <R as OdraContract>::InitArgs, ) -> <R as OdraContract>::HostRef
Source§fn try_deploy(
env: &HostEnv,
init_args: <R as OdraContract>::InitArgs,
) -> Result<<R as OdraContract>::HostRef, OdraError>
fn try_deploy( env: &HostEnv, init_args: <R as OdraContract>::InitArgs, ) -> Result<<R as OdraContract>::HostRef, OdraError>
Source§fn deploy_with_cfg(
env: &HostEnv,
init_args: <R as OdraContract>::InitArgs,
cfg: InstallConfig,
) -> <R as OdraContract>::HostRef
fn deploy_with_cfg( env: &HostEnv, init_args: <R as OdraContract>::InitArgs, cfg: InstallConfig, ) -> <R as OdraContract>::HostRef
Source§fn try_deploy_with_cfg(
env: &HostEnv,
init_args: <R as OdraContract>::InitArgs,
cfg: InstallConfig,
) -> Result<<R as OdraContract>::HostRef, OdraError>
fn try_deploy_with_cfg( env: &HostEnv, init_args: <R as OdraContract>::InitArgs, cfg: InstallConfig, ) -> Result<<R as OdraContract>::HostRef, OdraError>
Source§fn try_upgrade(
env: &HostEnv,
contract_to_upgrade: Address,
upgrade_args: <R as OdraContract>::UpgradeArgs,
) -> Result<<R as OdraContract>::HostRef, OdraError>
fn try_upgrade( env: &HostEnv, contract_to_upgrade: Address, upgrade_args: <R as OdraContract>::UpgradeArgs, ) -> Result<<R as OdraContract>::HostRef, OdraError>
Source§fn try_upgrade_with_cfg(
env: &HostEnv,
contract_to_upgrade: Address,
upgrade_args: <R as OdraContract>::UpgradeArgs,
cfg: UpgradeConfig,
) -> Result<<R as OdraContract>::HostRef, OdraError>
fn try_upgrade_with_cfg( env: &HostEnv, contract_to_upgrade: Address, upgrade_args: <R as OdraContract>::UpgradeArgs, cfg: UpgradeConfig, ) -> Result<<R as OdraContract>::HostRef, OdraError>
Source§impl<T> HostRefLoader<<T as OdraContract>::HostRef> for Twhere
T: OdraContract,
impl<T> HostRefLoader<<T as OdraContract>::HostRef> for Twhere
T: OdraContract,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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