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

Make merkle hook not ownable #5

Merged
merged 2 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions contracts/hooks/merkle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,31 +59,26 @@ pub fn instantiate(
) -> Result<Response, ContractError> {
cw2::set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;

let owner = deps.api.addr_validate(&msg.owner)?;
let mailbox = deps.api.addr_validate(&msg.mailbox)?;

hpl_ownable::initialize(deps.storage, &owner)?;

MAILBOX.save(deps.storage, &mailbox)?;
MESSAGE_TREE.save(deps.storage, &MerkleTree::default())?;

Ok(Response::new().add_event(
new_event("initialize")
.add_attribute("sender", info.sender)
.add_attribute("owner", owner)
.add_attribute("mailbox", mailbox),
))
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn execute(
deps: DepsMut,
env: Env,
info: MessageInfo,
_env: Env,
_info: MessageInfo,
msg: ExecuteMsg,
) -> Result<Response, ContractError> {
match msg {
ExecuteMsg::Ownable(msg) => Ok(hpl_ownable::handle(deps, env, info, msg)?),
ExecuteMsg::PostDispatch(PostDispatchMsg { message, .. }) => {
let mailbox = MAILBOX.load(deps.storage)?;

Expand Down Expand Up @@ -123,11 +118,10 @@ pub fn execute(
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> Result<QueryResponse, ContractError> {
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> Result<QueryResponse, ContractError> {
use MerkleHookQueryMsg::*;

match msg {
QueryMsg::Ownable(msg) => Ok(hpl_ownable::handle_query(deps, env, msg)?),
QueryMsg::Hook(msg) => match msg {
HookQueryMsg::Mailbox {} => to_binary(get_mailbox(deps)),
HookQueryMsg::QuoteDispatch(_) => to_binary(quote_dispatch()),
Expand Down Expand Up @@ -228,7 +222,6 @@ mod test {
#[fixture]
fn deps(
#[default(Addr::unchecked("deployer"))] sender: Addr,
#[default(Addr::unchecked("owner"))] owner: Addr,
#[default(Addr::unchecked("mailbox"))] mailbox: Addr,
) -> TestDeps {
let mut deps = mock_dependencies();
Expand All @@ -238,7 +231,6 @@ mod test {
mock_env(),
mock_info(sender.as_str(), &[]),
InstantiateMsg {
owner: owner.to_string(),
mailbox: mailbox.to_string(),
},
)
Expand Down
5 changes: 0 additions & 5 deletions packages/interface/src/hook/merkle.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
use cosmwasm_schema::{cw_serde, QueryResponses};
use cosmwasm_std::HexBinary;

use crate::ownable::{OwnableMsg, OwnableQueryMsg};

use super::{HookQueryMsg, PostDispatchMsg};

pub const TREE_DEPTH: usize = 32;

#[cw_serde]
pub struct InstantiateMsg {
pub owner: String,
pub mailbox: String,
}

#[cw_serde]
pub enum ExecuteMsg {
Ownable(OwnableMsg),
PostDispatch(PostDispatchMsg),
}

#[cw_serde]
#[derive(QueryResponses)]
#[query_responses(nested)]
pub enum QueryMsg {
Ownable(OwnableQueryMsg),
Hook(HookQueryMsg),
MerkleHook(MerkleHookQueryMsg),
}
Expand Down
Loading