diff --git a/CHANGELOG.md b/CHANGELOG.md index 70d3b93570..b03f1a2c07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,8 +24,10 @@ and this project adheres to `Decimal256`. ([#1902]) - cosmwasm-std: Remove operand strings from `OverflowError`, `ConversionOverflowError` and `DivideByZeroError`. ([#1896]) +- cosmwasm-std: Add optional memo field to `IbcMsg::Transfer`. ([#1878]) [#1874]: https://github.com/CosmWasm/cosmwasm/pull/1874 +[#1878]: https://github.com/CosmWasm/cosmwasm/pull/1878 [#1879]: https://github.com/CosmWasm/cosmwasm/pull/1879 [#1890]: https://github.com/CosmWasm/cosmwasm/pull/1890 [#1896]: https://github.com/CosmWasm/cosmwasm/pull/1896 diff --git a/contracts/ibc-reflect-send/schema/ibc-reflect-send.json b/contracts/ibc-reflect-send/schema/ibc-reflect-send.json index cf36088129..f863c79d43 100644 --- a/contracts/ibc-reflect-send/schema/ibc-reflect-send.json +++ b/contracts/ibc-reflect-send/schema/ibc-reflect-send.json @@ -424,6 +424,13 @@ "description": "existing channel to send the tokens over", "type": "string" }, + "memo": { + "description": "optional memo", + "type": [ + "string", + "null" + ] + }, "timeout": { "description": "when packet times out, measured on remote chain", "allOf": [ diff --git a/contracts/ibc-reflect-send/schema/ibc/packet_msg.json b/contracts/ibc-reflect-send/schema/ibc/packet_msg.json index 00bcd35219..f8f8640a5c 100644 --- a/contracts/ibc-reflect-send/schema/ibc/packet_msg.json +++ b/contracts/ibc-reflect-send/schema/ibc/packet_msg.json @@ -362,6 +362,13 @@ "description": "existing channel to send the tokens over", "type": "string" }, + "memo": { + "description": "optional memo", + "type": [ + "string", + "null" + ] + }, "timeout": { "description": "when packet times out, measured on remote chain", "allOf": [ diff --git a/contracts/ibc-reflect-send/schema/raw/execute.json b/contracts/ibc-reflect-send/schema/raw/execute.json index 5fee9b17a4..1765e73a74 100644 --- a/contracts/ibc-reflect-send/schema/raw/execute.json +++ b/contracts/ibc-reflect-send/schema/raw/execute.json @@ -413,6 +413,13 @@ "description": "existing channel to send the tokens over", "type": "string" }, + "memo": { + "description": "optional memo", + "type": [ + "string", + "null" + ] + }, "timeout": { "description": "when packet times out, measured on remote chain", "allOf": [ diff --git a/contracts/ibc-reflect-send/src/contract.rs b/contracts/ibc-reflect-send/src/contract.rs index 23adc82b89..d3a2bfe441 100644 --- a/contracts/ibc-reflect-send/src/contract.rs +++ b/contracts/ibc-reflect-send/src/contract.rs @@ -157,6 +157,7 @@ pub fn handle_send_funds( to_address: remote_addr, amount, timeout: env.block.time.plus_seconds(PACKET_LIFETIME).into(), + memo: None, }; let res = Response::new() diff --git a/contracts/ibc-reflect-send/src/ibc.rs b/contracts/ibc-reflect-send/src/ibc.rs index 6faabd5c10..511a7b1518 100644 --- a/contracts/ibc-reflect-send/src/ibc.rs +++ b/contracts/ibc-reflect-send/src/ibc.rs @@ -410,12 +410,14 @@ mod tests { to_address, amount, timeout, + memo, }) => { assert_eq!(transfer_channel_id, channel_id.as_str()); assert_eq!(remote_addr, to_address.as_str()); assert_eq!(&coin(12344, "utrgd"), amount); assert!(timeout.block().is_none()); assert!(timeout.timestamp().is_some()); + assert!(memo.is_none()); } o => panic!("unexpected message: {o:?}"), } diff --git a/contracts/ibc-reflect-send/tests/integration.rs b/contracts/ibc-reflect-send/tests/integration.rs index 21d5c95352..ea8a70f8d2 100644 --- a/contracts/ibc-reflect-send/tests/integration.rs +++ b/contracts/ibc-reflect-send/tests/integration.rs @@ -234,12 +234,14 @@ fn send_remote_funds() { to_address, amount, timeout, + memo, }) => { assert_eq!(transfer_channel_id, channel_id.as_str()); assert_eq!(remote_addr, to_address.as_str()); assert_eq!(&coin(12344, "utrgd"), amount); assert!(timeout.block().is_none()); assert!(timeout.timestamp().is_some()); + assert!(memo.is_none()); } o => panic!("unexpected message: {o:?}"), } diff --git a/contracts/ibc-reflect/schema/ibc/packet_msg.json b/contracts/ibc-reflect/schema/ibc/packet_msg.json index 3b9ebaef68..6856f57368 100644 --- a/contracts/ibc-reflect/schema/ibc/packet_msg.json +++ b/contracts/ibc-reflect/schema/ibc/packet_msg.json @@ -349,6 +349,13 @@ "description": "existing channel to send the tokens over", "type": "string" }, + "memo": { + "description": "optional memo", + "type": [ + "string", + "null" + ] + }, "timeout": { "description": "when packet times out, measured on remote chain", "allOf": [ diff --git a/contracts/reflect/schema/raw/execute.json b/contracts/reflect/schema/raw/execute.json index 4180145986..abd024e972 100644 --- a/contracts/reflect/schema/raw/execute.json +++ b/contracts/reflect/schema/raw/execute.json @@ -467,6 +467,13 @@ "description": "existing channel to send the tokens over", "type": "string" }, + "memo": { + "description": "optional memo", + "type": [ + "string", + "null" + ] + }, "timeout": { "description": "when packet times out, measured on remote chain", "allOf": [ diff --git a/contracts/reflect/schema/reflect.json b/contracts/reflect/schema/reflect.json index 641d7498d7..21b899f174 100644 --- a/contracts/reflect/schema/reflect.json +++ b/contracts/reflect/schema/reflect.json @@ -477,6 +477,13 @@ "description": "existing channel to send the tokens over", "type": "string" }, + "memo": { + "description": "optional memo", + "type": [ + "string", + "null" + ] + }, "timeout": { "description": "when packet times out, measured on remote chain", "allOf": [ diff --git a/packages/std/src/ibc.rs b/packages/std/src/ibc.rs index 1a732f3e55..17c60ae87f 100644 --- a/packages/std/src/ibc.rs +++ b/packages/std/src/ibc.rs @@ -35,6 +35,8 @@ pub enum IbcMsg { amount: Coin, /// when packet times out, measured on remote chain timeout: IbcTimeout, + /// optional memo + memo: Option, }, /// Sends an IBC packet with given data over the existing channel. /// Data should be encoded in a format defined by the channel version, @@ -793,9 +795,10 @@ mod tests { to_address: "my-special-addr".into(), amount: Coin::new(12345678u128, "uatom"), timeout: IbcTimeout::with_timestamp(Timestamp::from_nanos(1234567890)), + memo: None, }; let encoded = to_string(&msg).unwrap(); - let expected = r#"{"transfer":{"channel_id":"channel-123","to_address":"my-special-addr","amount":{"denom":"uatom","amount":"12345678"},"timeout":{"block":null,"timestamp":"1234567890"}}}"#; + 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}}"#; assert_eq!(encoded.as_str(), expected); }