Skip to content

Commit f9869de

Browse files
committed
Update IbcAcknowledgement type
1 parent bbad026 commit f9869de

File tree

5 files changed

+28
-13
lines changed

5 files changed

+28
-13
lines changed

packages/std/src/ibc.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,18 @@ pub struct IbcPacket {
185185
}
186186

187187
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
188-
pub struct IbcAcknowledgement {
189-
pub acknowledgement: Binary,
188+
pub struct IbcAcknowledgementWithPacket {
189+
pub acknowledgement: IbcAcknowledgement,
190190
pub original_packet: IbcPacket,
191191
}
192192

193+
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
194+
pub struct IbcAcknowledgement {
195+
pub data: Binary,
196+
// we may add more info here in the future (meta-data from the acknowledgement)
197+
// there have been proposals to extend this type in core ibc for future versions
198+
}
199+
193200
/// This is the return value for the majority of the ibc handlers.
194201
/// That are able to dispatch messages / events on their own,
195202
/// but have no meaningful return value to the calling code.

packages/std/src/ibc_exports.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::memory::{consume_region, release_buffer, Region};
1212
use crate::results::ContractResult;
1313
use crate::serde::{from_slice, to_vec};
1414
use crate::types::Env;
15-
use crate::{IbcAcknowledgement, IbcPacket, IbcReceiveResponse};
15+
use crate::{IbcAcknowledgementWithPacket, IbcPacket, IbcReceiveResponse};
1616

1717
// TODO: replace with https://doc.rust-lang.org/std/ops/trait.Try.html once stabilized
1818
macro_rules! r#try_into_contract_result {
@@ -177,7 +177,11 @@ where
177177
/// contract_fn is called when this chain receives an IBC Acknowledgement for a packet
178178
/// that this contract previously sent
179179
pub fn do_ibc_packet_ack<C, E>(
180-
contract_fn: &dyn Fn(DepsMut, Env, IbcAcknowledgement) -> Result<IbcBasicResponse<C>, E>,
180+
contract_fn: &dyn Fn(
181+
DepsMut,
182+
Env,
183+
IbcAcknowledgementWithPacket,
184+
) -> Result<IbcBasicResponse<C>, E>,
181185
env_ptr: u32,
182186
msg_ptr: u32,
183187
) -> u32
@@ -191,7 +195,11 @@ where
191195
}
192196

193197
fn _do_ibc_packet_ack<C, E>(
194-
contract_fn: &dyn Fn(DepsMut, Env, IbcAcknowledgement) -> Result<IbcBasicResponse<C>, E>,
198+
contract_fn: &dyn Fn(
199+
DepsMut,
200+
Env,
201+
IbcAcknowledgementWithPacket,
202+
) -> Result<IbcBasicResponse<C>, E>,
195203
env_ptr: *mut Region,
196204
msg_ptr: *mut Region,
197205
) -> ContractResult<IbcBasicResponse<C>>
@@ -203,7 +211,7 @@ where
203211
let msg: Vec<u8> = unsafe { consume_region(msg_ptr) };
204212

205213
let env: Env = try_into_contract_result!(from_slice(&env));
206-
let msg: IbcAcknowledgement = try_into_contract_result!(from_slice(&msg));
214+
let msg: IbcAcknowledgementWithPacket = try_into_contract_result!(from_slice(&msg));
207215

208216
let mut deps = make_dependencies();
209217
contract_fn(deps.as_mut(), env, msg).into()

packages/std/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ pub use crate::errors::{
3434
};
3535
#[cfg(feature = "stargate")]
3636
pub use crate::ibc::{
37-
IbcAcknowledgement, IbcBasicResponse, IbcChannel, IbcEndpoint, IbcMsg, IbcOrder, IbcPacket,
38-
IbcReceiveResponse, IbcTimeout, IbcTimeoutBlock,
37+
IbcAcknowledgementWithPacket, IbcBasicResponse, IbcChannel, IbcEndpoint, IbcMsg, IbcOrder,
38+
IbcPacket, IbcReceiveResponse, IbcTimeout, IbcTimeoutBlock,
3939
};
4040
#[cfg(feature = "iterator")]
4141
#[allow(deprecated)]

packages/vm/src/calls.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use wasmer::Val;
66
use cosmwasm_std::{ContractResult, Env, MessageInfo, QueryResponse, Reply, Response};
77
#[cfg(feature = "stargate")]
88
use cosmwasm_std::{
9-
IbcAcknowledgement, IbcBasicResponse, IbcChannel, IbcPacket, IbcReceiveResponse,
9+
IbcAcknowledgementWithPacket, IbcBasicResponse, IbcChannel, IbcPacket, IbcReceiveResponse,
1010
};
1111

1212
use crate::backend::{BackendApi, Querier, Storage};
@@ -294,7 +294,7 @@ where
294294
pub fn call_ibc_packet_ack<A, S, Q, U>(
295295
instance: &mut Instance<A, S, Q>,
296296
env: &Env,
297-
ack: &IbcAcknowledgement,
297+
ack: &IbcAcknowledgementWithPacket,
298298
) -> VmResult<ContractResult<IbcBasicResponse<U>>>
299299
where
300300
A: BackendApi + 'static,
@@ -745,7 +745,7 @@ mod tests {
745745
let mut instance = mock_instance(&CONTRACT, &[]);
746746
setup(&mut instance, CHANNEL_ID, ACCOUNT);
747747
let packet = mock_ibc_packet_ack(CHANNEL_ID, br#"{}"#).unwrap();
748-
let ack = IbcAcknowledgement {
748+
let ack = IbcAcknowledgementWithPacket {
749749
acknowledgement: br#"{}"#.into(),
750750
original_packet: packet,
751751
};

packages/vm/src/testing/calls.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::fmt;
88
use cosmwasm_std::{ContractResult, Env, MessageInfo, QueryResponse, Reply, Response};
99
#[cfg(feature = "stargate")]
1010
use cosmwasm_std::{
11-
IbcAcknowledgement, IbcBasicResponse, IbcChannel, IbcPacket, IbcReceiveResponse,
11+
IbcAcknowledgementWithPacket, IbcBasicResponse, IbcChannel, IbcPacket, IbcReceiveResponse,
1212
};
1313

1414
use crate::calls::{
@@ -214,7 +214,7 @@ where
214214
pub fn ibc_packet_ack<A, S, Q, U>(
215215
instance: &mut Instance<A, S, Q>,
216216
env: Env,
217-
ack: IbcAcknowledgement,
217+
ack: IbcAcknowledgementWithPacket,
218218
) -> ContractResult<IbcBasicResponse<U>>
219219
where
220220
A: BackendApi + 'static,

0 commit comments

Comments
 (0)