@@ -202,7 +202,8 @@ This is how you can implement the `ibc_destination_callback` entrypoint:
202
202
</Callout >
203
203
204
204
``` rust template="core"
205
- use ibc :: apps :: transfer :: types :: packet :: PacketData as TransferPacketData ;
205
+ use ibc :: apps :: transfer :: types :: proto :: transfer :: v2 :: FungibleTokenPacketData ;
206
+ use std :: str :: FromStr ;
206
207
207
208
#[cfg_attr(not(feature = " library" ), entry_point)]
208
209
pub fn ibc_destination_callback (
@@ -224,7 +225,7 @@ pub fn ibc_destination_callback(
224
225
// but not to whom it is going, how much and what denom.
225
226
226
227
// Parse the packet data to get that information:
227
- let packet_data : TransferPacketData = from_json (& msg . packet. data)? ;
228
+ let packet_data : FungibleTokenPacketData = from_json (& msg . packet. data)? ;
228
229
229
230
// The receiver should be a valid address on this chain.
230
231
// Remember, we are on the destination chain.
@@ -236,17 +237,20 @@ pub fn ibc_destination_callback(
236
237
);
237
238
238
239
// We only care about this chain's native token in this example.
239
- // The `packet_data.token. denom` is formatted as `{port id}/{channel id}/{denom}`,
240
+ // The `packet_data.denom` is formatted as `{port id}/{channel id}/{denom}`,
240
241
// where the port id and channel id are the source chain's identifiers.
241
- // Assuming we are running this on Neutron and only want to handle NTRN tokens,
242
- // the denom should look like this:
243
- let ntrn_denom = format! (
242
+ // Please note that the denom is not formatted like that when you transfer untrn
243
+ // from Neutron to some other chain. In that case, the denom is just the native
244
+ // token of the source chain (untrn).
245
+ // That being said, assuming we are running this on Neutron and only want to
246
+ // handle NTRN tokens, the denom should look like this:
247
+ let ntrn_denom_on_source_chain = format! (
244
248
" {}/{}/untrn" ,
245
249
msg . packet. src. port_id, msg . packet. src. channel_id
246
250
);
247
251
ensure_eq! (
248
- packet_data . token . denom. to_string () ,
249
- ntrn_denom ,
252
+ packet_data . denom,
253
+ ntrn_denom_on_source_chain ,
250
254
StdError :: generic_err (" only want to handle NTRN tokens" )
251
255
);
252
256
@@ -255,7 +259,7 @@ pub fn ibc_destination_callback(
255
259
let msg = BankMsg :: Send {
256
260
to_address : " neutron155exr8rqjrknusllpzxdfvezxr8ddpqehj9g9d" . to_string (),
257
261
// this panics if the amount is too large
258
- amount : coins (packet_data . token . amount. as_ref () . as_u128 (), " untrn" ),
262
+ amount : coins (u128 :: from_str ( & packet_data . amount) . unwrap (), " untrn" ),
259
263
};
260
264
261
265
Ok (IbcBasicResponse :: new ()
0 commit comments