Skip to content

Commit

Permalink
Apply review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
chipshort committed Apr 16, 2024
1 parent a4449f9 commit ff8b0f5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion contracts/ibc-callbacks/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Ibc Reflect Contract
# IBC Callbacks Contract

This is a simple contract to demonstrate [IBC Callbacks]. It sends an ICS-20
transfer message to a remote chain and writes to storage which callbacks were
Expand Down
4 changes: 3 additions & 1 deletion packages/std/src/ibc/callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ impl IbcCallbackData {
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
pub struct IbcSrcCallback {
/// The source chain address that should receive the callback.
/// You probably want to put `env.contract.address` here.
/// For CosmWasm contracts, this *must* be `env.contract.address`.
/// Other addresses are not allowed and will effectively be ignored.
pub address: Addr,
/// Optional gas limit for the callback (in Cosmos SDK gas units)
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -105,6 +106,7 @@ pub struct IbcDstCallback {
/// For `IbcMsg::Transfer`, this is the `memo` field.
/// - The receiver of the callback must also be the sender of the message.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum IbcSourceChainCallbackMsg {
Acknowledgement(IbcPacketAckMsg),
Timeout(IbcPacketTimeoutMsg),
Expand Down
8 changes: 8 additions & 0 deletions packages/vm/src/calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,7 @@ mod tests {
const CONTRACT: &[u8] = include_bytes!("../testdata/ibc_reflect.wasm");
const IBC_CALLBACKS: &[u8] = include_bytes!("../testdata/ibc_callbacks.wasm");
const IBC_VERSION: &str = "ibc-reflect-v1";

fn setup(
instance: &mut Instance<MockApi, MockStorage, MockQuerier>,
channel_id: &str,
Expand Down Expand Up @@ -1014,13 +1015,16 @@ mod tests {
};
call_reply::<_, _, _, Empty>(instance, &mock_env(), &response).unwrap();
}

const CHANNEL_ID: &str = "channel-123";
const ACCOUNT: &str = "account-456";

#[test]
fn call_ibc_channel_open_and_connect_works() {
let mut instance = mock_instance(CONTRACT, &[]);
setup(&mut instance, CHANNEL_ID, ACCOUNT);
}

#[test]
fn call_ibc_channel_close_works() {
let mut instance = mock_instance(CONTRACT, &[]);
Expand All @@ -1032,6 +1036,7 @@ mod tests {
.unwrap()
.unwrap();
}

#[test]
fn call_ibc_packet_ack_works() {
let mut instance = mock_instance(CONTRACT, &[]);
Expand All @@ -1042,6 +1047,7 @@ mod tests {
.unwrap()
.unwrap();
}

#[test]
fn call_ibc_packet_timeout_works() {
let mut instance = mock_instance(CONTRACT, &[]);
Expand All @@ -1051,6 +1057,7 @@ mod tests {
.unwrap()
.unwrap();
}

#[test]
fn call_ibc_packet_receive_works() {
let mut instance = mock_instance(CONTRACT, &[]);
Expand All @@ -1061,6 +1068,7 @@ mod tests {
.unwrap()
.unwrap();
}

#[test]
fn call_ibc_source_chain_callback_works() {
let mut instance = mock_instance(IBC_CALLBACKS, &[]);
Expand Down

0 comments on commit ff8b0f5

Please sign in to comment.