Skip to content

Commit fde26bd

Browse files
authored
Merge pull request #1878 from CosmWasm/1477-ibc-transfer-memo
[2.0] Add memo field to `IbcMsg::Transfer`
2 parents e7c4ed8 + eb2c9ce commit fde26bd

File tree

11 files changed

+53
-1
lines changed

11 files changed

+53
-1
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ and this project adheres to
2424
`Decimal256`. ([#1902])
2525
- cosmwasm-std: Remove operand strings from `OverflowError`,
2626
`ConversionOverflowError` and `DivideByZeroError`. ([#1896])
27+
- cosmwasm-std: Add optional memo field to `IbcMsg::Transfer`. ([#1878])
2728

2829
[#1874]: https://github.com/CosmWasm/cosmwasm/pull/1874
30+
[#1878]: https://github.com/CosmWasm/cosmwasm/pull/1878
2931
[#1879]: https://github.com/CosmWasm/cosmwasm/pull/1879
3032
[#1890]: https://github.com/CosmWasm/cosmwasm/pull/1890
3133
[#1896]: https://github.com/CosmWasm/cosmwasm/pull/1896

contracts/ibc-reflect-send/schema/ibc-reflect-send.json

+7
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,13 @@
424424
"description": "existing channel to send the tokens over",
425425
"type": "string"
426426
},
427+
"memo": {
428+
"description": "optional memo",
429+
"type": [
430+
"string",
431+
"null"
432+
]
433+
},
427434
"timeout": {
428435
"description": "when packet times out, measured on remote chain",
429436
"allOf": [

contracts/ibc-reflect-send/schema/ibc/packet_msg.json

+7
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,13 @@
362362
"description": "existing channel to send the tokens over",
363363
"type": "string"
364364
},
365+
"memo": {
366+
"description": "optional memo",
367+
"type": [
368+
"string",
369+
"null"
370+
]
371+
},
365372
"timeout": {
366373
"description": "when packet times out, measured on remote chain",
367374
"allOf": [

contracts/ibc-reflect-send/schema/raw/execute.json

+7
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,13 @@
413413
"description": "existing channel to send the tokens over",
414414
"type": "string"
415415
},
416+
"memo": {
417+
"description": "optional memo",
418+
"type": [
419+
"string",
420+
"null"
421+
]
422+
},
416423
"timeout": {
417424
"description": "when packet times out, measured on remote chain",
418425
"allOf": [

contracts/ibc-reflect-send/src/contract.rs

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ pub fn handle_send_funds(
157157
to_address: remote_addr,
158158
amount,
159159
timeout: env.block.time.plus_seconds(PACKET_LIFETIME).into(),
160+
memo: None,
160161
};
161162

162163
let res = Response::new()

contracts/ibc-reflect-send/src/ibc.rs

+2
Original file line numberDiff line numberDiff line change
@@ -410,12 +410,14 @@ mod tests {
410410
to_address,
411411
amount,
412412
timeout,
413+
memo,
413414
}) => {
414415
assert_eq!(transfer_channel_id, channel_id.as_str());
415416
assert_eq!(remote_addr, to_address.as_str());
416417
assert_eq!(&coin(12344, "utrgd"), amount);
417418
assert!(timeout.block().is_none());
418419
assert!(timeout.timestamp().is_some());
420+
assert!(memo.is_none());
419421
}
420422
o => panic!("unexpected message: {o:?}"),
421423
}

contracts/ibc-reflect-send/tests/integration.rs

+2
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,14 @@ fn send_remote_funds() {
234234
to_address,
235235
amount,
236236
timeout,
237+
memo,
237238
}) => {
238239
assert_eq!(transfer_channel_id, channel_id.as_str());
239240
assert_eq!(remote_addr, to_address.as_str());
240241
assert_eq!(&coin(12344, "utrgd"), amount);
241242
assert!(timeout.block().is_none());
242243
assert!(timeout.timestamp().is_some());
244+
assert!(memo.is_none());
243245
}
244246
o => panic!("unexpected message: {o:?}"),
245247
}

contracts/ibc-reflect/schema/ibc/packet_msg.json

+7
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,13 @@
349349
"description": "existing channel to send the tokens over",
350350
"type": "string"
351351
},
352+
"memo": {
353+
"description": "optional memo",
354+
"type": [
355+
"string",
356+
"null"
357+
]
358+
},
352359
"timeout": {
353360
"description": "when packet times out, measured on remote chain",
354361
"allOf": [

contracts/reflect/schema/raw/execute.json

+7
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,13 @@
467467
"description": "existing channel to send the tokens over",
468468
"type": "string"
469469
},
470+
"memo": {
471+
"description": "optional memo",
472+
"type": [
473+
"string",
474+
"null"
475+
]
476+
},
470477
"timeout": {
471478
"description": "when packet times out, measured on remote chain",
472479
"allOf": [

contracts/reflect/schema/reflect.json

+7
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,13 @@
477477
"description": "existing channel to send the tokens over",
478478
"type": "string"
479479
},
480+
"memo": {
481+
"description": "optional memo",
482+
"type": [
483+
"string",
484+
"null"
485+
]
486+
},
480487
"timeout": {
481488
"description": "when packet times out, measured on remote chain",
482489
"allOf": [

packages/std/src/ibc.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ pub enum IbcMsg {
3535
amount: Coin,
3636
/// when packet times out, measured on remote chain
3737
timeout: IbcTimeout,
38+
/// optional memo
39+
memo: Option<String>,
3840
},
3941
/// Sends an IBC packet with given data over the existing channel.
4042
/// Data should be encoded in a format defined by the channel version,
@@ -793,9 +795,10 @@ mod tests {
793795
to_address: "my-special-addr".into(),
794796
amount: Coin::new(12345678u128, "uatom"),
795797
timeout: IbcTimeout::with_timestamp(Timestamp::from_nanos(1234567890)),
798+
memo: None,
796799
};
797800
let encoded = to_string(&msg).unwrap();
798-
let expected = r#"{"transfer":{"channel_id":"channel-123","to_address":"my-special-addr","amount":{"denom":"uatom","amount":"12345678"},"timeout":{"block":null,"timestamp":"1234567890"}}}"#;
801+
let expected = r#"{"transfer":{"channel_id":"channel-123","to_address":"my-special-addr","amount":{"denom":"uatom","amount":"12345678"},"timeout":{"block":null,"timestamp":"1234567890"},"memo":null}}"#;
799802
assert_eq!(encoded.as_str(), expected);
800803
}
801804

0 commit comments

Comments
 (0)