pub struct NestedAdmin(/* private fields */);
Expand description
§Abstract Admin Object
This object has a similar api to the cw_controllers::Admin object but incorporates nested ownership and abstract-specific Admin checks.
The ownership of a contract can be nested, meaning that the owner of the contract can be owned by another contract (or address) and so on.
By using this structure we allow both the direct owner as well as the top-level owner to have permissions to perform actions that are gated by this object.
See NestedAdmin::assert_admin for more details on how the admin rights are checked.
Implementations§
Source§impl NestedAdmin
impl NestedAdmin
pub const fn new(namespace: &'static str) -> Self
pub fn set<Q: CustomQuery>( &self, deps: DepsMut<'_, Q>, admin: Option<Addr>, ) -> StdResult<()>
pub fn get<Q: CustomQuery>(&self, deps: Deps<'_, Q>) -> StdResult<Option<Addr>>
Sourcepub fn is_admin<Q: CustomQuery>(
&self,
deps: Deps<'_, Q>,
env: &Env,
caller: &Addr,
) -> StdResult<bool>
pub fn is_admin<Q: CustomQuery>( &self, deps: Deps<'_, Q>, env: &Env, caller: &Addr, ) -> StdResult<bool>
See NestedAdmin::assert_admin for more details.
Sourcepub fn is_admin_custom<Q: CustomQuery>(
querier: &QuerierWrapper<'_, Q>,
env: &Env,
caller: &Addr,
admin: Addr,
) -> StdResult<bool>
pub fn is_admin_custom<Q: CustomQuery>( querier: &QuerierWrapper<'_, Q>, env: &Env, caller: &Addr, admin: Addr, ) -> StdResult<bool>
See NestedAdmin::assert_admin for more details.
Sourcepub fn assert_admin<Q: CustomQuery>(
&self,
deps: Deps<'_, Q>,
env: &Env,
caller: &Addr,
) -> Result<(), AdminError>
pub fn assert_admin<Q: CustomQuery>( &self, deps: Deps<'_, Q>, env: &Env, caller: &Addr, ) -> Result<(), AdminError>
Assert that the caller is allowed to perform admin actions.
This method will pass in two specific scenarios:
- If the caller is the direct admin of the contract. I.e. the admin stored in this contract. AND the state
CALLING_TO_AS_ADMIN
is set to the contract address or a wildcard. - If the caller is the top-level admin of the chain of ownership, starting from this contract.
Sourcepub fn assert_admin_custom<Q: CustomQuery>(
querier: &QuerierWrapper<'_, Q>,
env: &Env,
caller: &Addr,
admin: Addr,
) -> Result<(), AdminError>
pub fn assert_admin_custom<Q: CustomQuery>( querier: &QuerierWrapper<'_, Q>, env: &Env, caller: &Addr, admin: Addr, ) -> Result<(), AdminError>
Assert that the caller is allowed to perform admin actions.
This method will pass in two specific scenarios:
- If the caller is the direct admin of the contract. I.e. the admin stored in this contract. AND the state
CALLING_TO_AS_ADMIN
is set to the contract address or a wildcard. - If the caller is the top-level admin of the chain of ownership, starting from this contract.
pub fn execute_update_admin<C, Q: CustomQuery>( &self, deps: DepsMut<'_, Q>, env: &Env, info: MessageInfo, new_admin: Option<Addr>, ) -> Result<Response<C>, AdminError>
pub fn query_admin<Q: CustomQuery>( &self, deps: Deps<'_, Q>, ) -> StdResult<AdminResponse>
pub fn query_account_owner<Q: CustomQuery>( &self, deps: Deps<'_, Q>, ) -> StdResult<AdminResponse>
Auto Trait Implementations§
impl Freeze for NestedAdmin
impl RefUnwindSafe for NestedAdmin
impl Send for NestedAdmin
impl Sync for NestedAdmin
impl Unpin for NestedAdmin
impl UnwindSafe for NestedAdmin
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> 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