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

fix: update mock ibc core #795

Merged
merged 5 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
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,
},
}