Skip to content

Commit

Permalink
fix: update mock ibc core (icon-project#795)
Browse files Browse the repository at this point in the history
* fix: add mock query

* fix: add writeacknowledgement

* chore: pass build
  • Loading branch information
ibrizsabin authored Dec 27, 2023
1 parent 7291763 commit 9a90959
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
12 changes: 11 additions & 1 deletion contracts/cosmwasm-vm/cw-mock-ibc-core/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ use common::ibc::core::ics04_channel::timeout::TimeoutHeight;
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
to_binary, Addr, Binary, CosmosMsg, Deps, DepsMut, Empty, Env, IbcEndpoint, IbcPacket,
to_binary, Addr, Binary, CosmosMsg, Deps, DepsMut, Empty, Env, Event, IbcEndpoint, IbcPacket,
IbcPacketReceiveMsg, IbcTimeout, IbcTimeoutBlock, MessageInfo, Reply, Response, StdResult,
SubMsg, Timestamp, WasmMsg,
};
use cw2::set_contract_version;
use cw_common::hex_string::HexString;
use cw_common::ibc_types::IbcHeight;
use cw_common::raw_types::channel::RawPacket;
use cw_common::ProstMessage;
Expand Down Expand Up @@ -154,9 +155,17 @@ pub fn execute(
.add_attribute("method", "ibc_config")
.add_attribute("data", to_binary(&sub_message).unwrap().to_base64()))
}
ExecuteMsg::WriteAcknowledgement {
packet: _,
acknowledgement,
} => Ok(Response::new().add_event(event_ack(acknowledgement))),
}
}

pub fn event_ack(ack: HexString) -> Event {
Event::new("write_acknowledgement").add_attribute("data", hex::encode(ack.to_bytes().unwrap()))
}

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
Expand All @@ -168,6 +177,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {

Ok(to_binary(&state.sequence).unwrap())
}
QueryMsg::GetLatestHeight { client_id: _ } => Ok(to_binary(&100000_u64).unwrap()),
_ => Err(cosmwasm_std::StdError::NotFound {
kind: "Query Not Found".to_string(),
}),
Expand Down
22 changes: 17 additions & 5 deletions contracts/cosmwasm-vm/cw-mock-ibc-core/src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cosmwasm_schema::cw_serde;
use cosmwasm_std::Addr;
use cosmwasm_std::{Addr, IbcPacket};
use cw_common::cw_types::CwChannelConnectMsg;
use cw_common::hex_string::HexString;

Expand All @@ -8,8 +8,20 @@ pub struct InstantiateMsg {}

#[cw_serde]
pub enum ExecuteMsg {
SendPacket { packet: HexString },
ReceivePacket { message: String },
RegisterXcall { address: Addr },
IbcConfig { msg: CwChannelConnectMsg },
SendPacket {
packet: HexString,
},
ReceivePacket {
message: String,
},
RegisterXcall {
address: Addr,
},
IbcConfig {
msg: CwChannelConnectMsg,
},
WriteAcknowledgement {
packet: IbcPacket,
acknowledgement: HexString,
},
}

0 comments on commit 9a90959

Please sign in to comment.