diff --git a/cosmwasm/ucs01-relay/src/contract.rs b/cosmwasm/ucs01-relay/src/contract.rs index d2499d36d5..fbc1ae01d2 100644 --- a/cosmwasm/ucs01-relay/src/contract.rs +++ b/cosmwasm/ucs01-relay/src/contract.rs @@ -79,11 +79,18 @@ pub fn execute( Err(ContractError::Unauthorized) } else { let normalized_hash = hash.0.try_into().expect("impossible"); - FOREIGN_DENOM_TO_HASH.save(deps.storage, denom.clone().into(), &normalized_hash)?; + FOREIGN_DENOM_TO_HASH.save(deps.storage, denom.clone(), &normalized_hash)?; HASH_TO_FOREIGN_DENOM.save(deps.storage, normalized_hash, &denom.to_string())?; Ok(Response::default()) } } + ExecuteMsg::BatchExecute { msgs } => { + if info.sender != env.contract.address { + Err(ContractError::Unauthorized) + } else { + Ok(Response::default().add_messages(msgs)) + } + } } } diff --git a/cosmwasm/ucs01-relay/src/msg.rs b/cosmwasm/ucs01-relay/src/msg.rs index 3d453bff50..f0fc87a1c1 100644 --- a/cosmwasm/ucs01-relay/src/msg.rs +++ b/cosmwasm/ucs01-relay/src/msg.rs @@ -1,5 +1,6 @@ use cosmwasm_schema::{cw_serde, QueryResponses}; -use cosmwasm_std::{Binary, IbcChannel, Uint512}; +use cosmwasm_std::{Binary, CosmosMsg, IbcChannel, Uint512}; +use token_factory_api::TokenFactoryMsg; use crate::state::ChannelInfo; @@ -24,6 +25,9 @@ pub enum ExecuteMsg { RegisterDenom { denom: String, hash: Binary }, /// Change the admin (must be called by current admin) UpdateAdmin { admin: String }, + BatchExecute { + msgs: Vec>, + }, } /// This is the message we accept via Receive diff --git a/cosmwasm/ucs01-relay/src/protocol.rs b/cosmwasm/ucs01-relay/src/protocol.rs index 185eca8d73..fc0b825aa5 100644 --- a/cosmwasm/ucs01-relay/src/protocol.rs +++ b/cosmwasm/ucs01-relay/src/protocol.rs @@ -40,6 +40,18 @@ pub fn protocol_ordering(version: &str) -> Option { } } +fn batch_submessages( + self_addr: &cosmwasm_std::Addr, + msgs: Vec>, +) -> Result>, ContractError> { + Ok(vec![wasm_execute( + self_addr, + &ExecuteMsg::BatchExecute { msgs }, + vec![], + )? + .into()]) +} + fn update_outstanding( deps: DepsMut, channel_id: &str, @@ -461,6 +473,7 @@ impl<'a> TransferProtocol for Ics20Protocol<'a> { receiver, tokens, ) + .map(|msgs| batch_submessages(self.self_addr(), msgs))? } fn normalize_for_ibc_transfer( @@ -574,6 +587,7 @@ impl<'a> TransferProtocol for Ucs01Protocol<'a> { receiver, tokens, ) + .map(|msgs| batch_submessages(self.self_addr(), msgs))? } fn normalize_for_ibc_transfer(