Struct cw_controllers::Hooks
source · pub struct Hooks<'a>(_);
Implementations§
source§impl<'a> Hooks<'a>
impl<'a> Hooks<'a>
pub const fn new(storage_key: &'a str) -> Self
sourcepub fn add_hook(
&self,
storage: &mut dyn Storage,
addr: Addr
) -> Result<(), HookError>
pub fn add_hook(
&self,
storage: &mut dyn Storage,
addr: Addr
) -> Result<(), HookError>
Examples found in repository?
src/hooks.rs (line 88)
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
pub fn execute_add_hook<C, Q: CustomQuery>(
&self,
admin: &Admin,
deps: DepsMut<Q>,
info: MessageInfo,
addr: Addr,
) -> Result<Response<C>, HookError>
where
C: Clone + fmt::Debug + PartialEq + JsonSchema,
{
admin.assert_admin(deps.as_ref(), &info.sender)?;
self.add_hook(deps.storage, addr.clone())?;
let attributes = vec![
attr("action", "add_hook"),
attr("hook", addr),
attr("sender", info.sender),
];
Ok(Response::new().add_attributes(attributes))
}
sourcepub fn remove_hook(
&self,
storage: &mut dyn Storage,
addr: Addr
) -> Result<(), HookError>
pub fn remove_hook(
&self,
storage: &mut dyn Storage,
addr: Addr
) -> Result<(), HookError>
Examples found in repository?
src/hooks.rs (line 109)
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
pub fn execute_remove_hook<C, Q: CustomQuery>(
&self,
admin: &Admin,
deps: DepsMut<Q>,
info: MessageInfo,
addr: Addr,
) -> Result<Response<C>, HookError>
where
C: Clone + fmt::Debug + PartialEq + JsonSchema,
{
admin.assert_admin(deps.as_ref(), &info.sender)?;
self.remove_hook(deps.storage, addr.clone())?;
let attributes = vec![
attr("action", "remove_hook"),
attr("hook", addr),
attr("sender", info.sender),
];
Ok(Response::new().add_attributes(attributes))
}