Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Previously set hooks or ISMs cannot be unset, so contracts can't opt back into using the default hook / ISM #140

Open
2 tasks
tkporter opened this issue Aug 14, 2024 · 0 comments · May be fixed by #143
Open
2 tasks

Comments

@tkporter
Copy link
Contributor

Background

The ConnectionMsg::SetIsm message only lets you set a new ISM, and same for ConnectionMsg::SetHook:

SetIsm { ism } => {
let ism_addr = deps.api.addr_validate(&ism)?;
ISM.save(deps.storage, &ism_addr)?;
Ok(event_to_resp(
new_event("set_ism").add_attribute("ism", ism),
))
}
SetHook { hook } => {
let hook_addr = deps.api.addr_validate(&hook)?;
HOOK.save(deps.storage, &hook_addr)?;
Ok(event_to_resp(
new_event("set_hook").add_attribute("hook", hook),
))
}

The implication of this is that getting the ISM or Hook will only return None (indicating to use the default hook or ISM configured on the Mailbox) if it hasn't been set before:

pub fn handle_query<C: CustomQuery>(
deps: Deps<'_, C>,
_env: Env,
msg: ConnectionQueryMsg,
) -> StdResult<QueryResponse> {
match msg {
ConnectionQueryMsg::GetMailbox {} => Ok(to_json_binary(&MailboxResponse {
mailbox: get_mailbox(deps.storage)?.map(|v| v.into()),
})?),
ConnectionQueryMsg::GetHook {} => Ok(to_json_binary(&HookResponse {
hook: get_hook(deps.storage)?.map(|v| v.into()),
})?),
ConnectionQueryMsg::GetIsm {} => Ok(to_json_binary(&IsmResponse {
ism: get_ism(deps.storage)?.map(|v| v.into()),
})?),
}
}
pub fn get_mailbox(storage: &dyn Storage) -> StdResult<Option<Addr>> {
MAILBOX.may_load(storage)
}
pub fn get_ism(storage: &dyn Storage) -> StdResult<Option<Addr>> {
ISM.may_load(storage)
}
pub fn get_hook(storage: &dyn Storage) -> StdResult<Option<Addr>> {
HOOK.may_load(storage)
}

Which means that any contract using connection that has previously set an ISM or Hook won't be able to opt back into using the default ISM or Hook.

Required Criteria

  • ConnectionMsg::SetIsm accepts an Option, where None unsets the ISM and opts the contract back into using the default ISM
  • ConnectionMsg::SetHook accepts an Option, where None unsets the hook and opts the contract back into using the default hook

Appendix

@aroralanuk aroralanuk linked a pull request Dec 6, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant