From 1193666100fb63ce749a462c808f6172521290b9 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 27 Jun 2023 11:52:30 +0200 Subject: [PATCH] Adapt contracts to packet_fee addition --- .../schema/ibc-reflect-send.json | 54 +++++++++++++++++++ .../ibc-reflect-send/schema/packet_msg.json | 54 +++++++++++++++++++ .../ibc-reflect-send/schema/raw/execute.json | 54 +++++++++++++++++++ contracts/ibc-reflect-send/src/contract.rs | 3 ++ contracts/ibc-reflect-send/src/ibc.rs | 3 ++ .../ibc-reflect-send/tests/integration.rs | 2 + contracts/ibc-reflect/schema/packet_msg.json | 54 +++++++++++++++++++ contracts/reflect/schema/raw/execute.json | 54 +++++++++++++++++++ contracts/reflect/schema/reflect.json | 54 +++++++++++++++++++ 9 files changed, 332 insertions(+) diff --git a/contracts/ibc-reflect-send/schema/ibc-reflect-send.json b/contracts/ibc-reflect-send/schema/ibc-reflect-send.json index 33fb5467c8..614690e809 100644 --- a/contracts/ibc-reflect-send/schema/ibc-reflect-send.json +++ b/contracts/ibc-reflect-send/schema/ibc-reflect-send.json @@ -393,6 +393,38 @@ } ] }, + "IbcFee": { + "description": "An [ICS-29] IBC fee.\n\nThis is mapped to an [ibc.applications.fee.v1.Fee].\n\n[ICS-29]: https://github.com/cosmos/ibc-go/blob/v7.2.0/docs/middleware/ics29-fee/overview.md [ibc.applications.fee.v1.Fee]: https://github.com/cosmos/ibc-go/blob/v7.2.0/proto/ibc/applications/fee/v1/fee.proto#L11-L31", + "type": "object", + "required": [ + "ack", + "recv", + "timeout" + ], + "properties": { + "ack": { + "description": "The packet acknowledgement fee", + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "recv": { + "description": "The packet receive fee", + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "timeout": { + "description": "The packet timeout fee", + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + } + }, "IbcMsg": { "description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points)", "oneOf": [ @@ -424,6 +456,17 @@ "description": "exisiting channel to send the tokens over", "type": "string" }, + "packet_fee": { + "description": "When set, a [MsgPayPacketFee] with the provided fee is created and emitted before the packet is sent. `signer` gets filled automatically with the contract address. No relayer restrictions will be in place.\n\n[MsgPayPacketFee]: https://github.com/cosmos/ibc-go/blob/v7.2.0/proto/ibc/applications/fee/v1/tx.proto#L76-L93", + "anyOf": [ + { + "$ref": "#/definitions/IbcFee" + }, + { + "type": "null" + } + ] + }, "timeout": { "description": "when packet times out, measured on remote chain", "allOf": [ @@ -462,6 +505,17 @@ "data": { "$ref": "#/definitions/Binary" }, + "packet_fee": { + "description": "When set, a [MsgPayPacketFee] with the provided fee is created and emitted before the packet is sent. `signer` gets filled automatically with the contract address. No relayer restrictions will be in place.\n\n[MsgPayPacketFee]: https://github.com/cosmos/ibc-go/blob/v7.2.0/proto/ibc/applications/fee/v1/tx.proto#L76-L93", + "anyOf": [ + { + "$ref": "#/definitions/IbcFee" + }, + { + "type": "null" + } + ] + }, "timeout": { "description": "when packet times out, measured on remote chain", "allOf": [ diff --git a/contracts/ibc-reflect-send/schema/packet_msg.json b/contracts/ibc-reflect-send/schema/packet_msg.json index ed5b77d0b8..ed4a17340e 100644 --- a/contracts/ibc-reflect-send/schema/packet_msg.json +++ b/contracts/ibc-reflect-send/schema/packet_msg.json @@ -331,6 +331,38 @@ } ] }, + "IbcFee": { + "description": "An [ICS-29] IBC fee.\n\nThis is mapped to an [ibc.applications.fee.v1.Fee].\n\n[ICS-29]: https://github.com/cosmos/ibc-go/blob/v7.2.0/docs/middleware/ics29-fee/overview.md [ibc.applications.fee.v1.Fee]: https://github.com/cosmos/ibc-go/blob/v7.2.0/proto/ibc/applications/fee/v1/fee.proto#L11-L31", + "type": "object", + "required": [ + "ack", + "recv", + "timeout" + ], + "properties": { + "ack": { + "description": "The packet acknowledgement fee", + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "recv": { + "description": "The packet receive fee", + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "timeout": { + "description": "The packet timeout fee", + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + } + }, "IbcMsg": { "description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points)", "oneOf": [ @@ -362,6 +394,17 @@ "description": "exisiting channel to send the tokens over", "type": "string" }, + "packet_fee": { + "description": "When set, a [MsgPayPacketFee] with the provided fee is created and emitted before the packet is sent. `signer` gets filled automatically with the contract address. No relayer restrictions will be in place.\n\n[MsgPayPacketFee]: https://github.com/cosmos/ibc-go/blob/v7.2.0/proto/ibc/applications/fee/v1/tx.proto#L76-L93", + "anyOf": [ + { + "$ref": "#/definitions/IbcFee" + }, + { + "type": "null" + } + ] + }, "timeout": { "description": "when packet times out, measured on remote chain", "allOf": [ @@ -400,6 +443,17 @@ "data": { "$ref": "#/definitions/Binary" }, + "packet_fee": { + "description": "When set, a [MsgPayPacketFee] with the provided fee is created and emitted before the packet is sent. `signer` gets filled automatically with the contract address. No relayer restrictions will be in place.\n\n[MsgPayPacketFee]: https://github.com/cosmos/ibc-go/blob/v7.2.0/proto/ibc/applications/fee/v1/tx.proto#L76-L93", + "anyOf": [ + { + "$ref": "#/definitions/IbcFee" + }, + { + "type": "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 db374275af..81d05d567e 100644 --- a/contracts/ibc-reflect-send/schema/raw/execute.json +++ b/contracts/ibc-reflect-send/schema/raw/execute.json @@ -382,6 +382,38 @@ } ] }, + "IbcFee": { + "description": "An [ICS-29] IBC fee.\n\nThis is mapped to an [ibc.applications.fee.v1.Fee].\n\n[ICS-29]: https://github.com/cosmos/ibc-go/blob/v7.2.0/docs/middleware/ics29-fee/overview.md [ibc.applications.fee.v1.Fee]: https://github.com/cosmos/ibc-go/blob/v7.2.0/proto/ibc/applications/fee/v1/fee.proto#L11-L31", + "type": "object", + "required": [ + "ack", + "recv", + "timeout" + ], + "properties": { + "ack": { + "description": "The packet acknowledgement fee", + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "recv": { + "description": "The packet receive fee", + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "timeout": { + "description": "The packet timeout fee", + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + } + }, "IbcMsg": { "description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points)", "oneOf": [ @@ -413,6 +445,17 @@ "description": "exisiting channel to send the tokens over", "type": "string" }, + "packet_fee": { + "description": "When set, a [MsgPayPacketFee] with the provided fee is created and emitted before the packet is sent. `signer` gets filled automatically with the contract address. No relayer restrictions will be in place.\n\n[MsgPayPacketFee]: https://github.com/cosmos/ibc-go/blob/v7.2.0/proto/ibc/applications/fee/v1/tx.proto#L76-L93", + "anyOf": [ + { + "$ref": "#/definitions/IbcFee" + }, + { + "type": "null" + } + ] + }, "timeout": { "description": "when packet times out, measured on remote chain", "allOf": [ @@ -451,6 +494,17 @@ "data": { "$ref": "#/definitions/Binary" }, + "packet_fee": { + "description": "When set, a [MsgPayPacketFee] with the provided fee is created and emitted before the packet is sent. `signer` gets filled automatically with the contract address. No relayer restrictions will be in place.\n\n[MsgPayPacketFee]: https://github.com/cosmos/ibc-go/blob/v7.2.0/proto/ibc/applications/fee/v1/tx.proto#L76-L93", + "anyOf": [ + { + "$ref": "#/definitions/IbcFee" + }, + { + "type": "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 50d074f3a8..6502885f3c 100644 --- a/contracts/ibc-reflect-send/src/contract.rs +++ b/contracts/ibc-reflect-send/src/contract.rs @@ -81,6 +81,7 @@ pub fn handle_send_msgs( channel_id, data: to_binary(&packet)?, timeout: env.block.time.plus_seconds(PACKET_LIFETIME).into(), + packet_fee: None, }; let res = Response::new() @@ -109,6 +110,7 @@ pub fn handle_check_remote_balance( channel_id, data: to_binary(&packet)?, timeout: env.block.time.plus_seconds(PACKET_LIFETIME).into(), + packet_fee: None, }; let res = Response::new() @@ -157,6 +159,7 @@ pub fn handle_send_funds( to_address: remote_addr, amount, timeout: env.block.time.plus_seconds(PACKET_LIFETIME).into(), + packet_fee: None, }; let res = Response::new() diff --git a/contracts/ibc-reflect-send/src/ibc.rs b/contracts/ibc-reflect-send/src/ibc.rs index 76939acea8..5db64ac2b0 100644 --- a/contracts/ibc-reflect-send/src/ibc.rs +++ b/contracts/ibc-reflect-send/src/ibc.rs @@ -63,6 +63,7 @@ pub fn ibc_channel_connect( channel_id: channel_id.clone(), data: to_binary(&packet)?, timeout: env.block.time.plus_seconds(PACKET_LIFETIME).into(), + packet_fee: None, }; Ok(IbcBasicResponse::new() @@ -413,12 +414,14 @@ mod tests { to_address, amount, timeout, + packet_fee, }) => { 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!(packet_fee.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 c0c2977b83..6e1d197021 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, + packet_fee, }) => { 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!(packet_fee.is_none()); } o => panic!("unexpected message: {:?}", o), } diff --git a/contracts/ibc-reflect/schema/packet_msg.json b/contracts/ibc-reflect/schema/packet_msg.json index 547c6fe054..c0fac668a3 100644 --- a/contracts/ibc-reflect/schema/packet_msg.json +++ b/contracts/ibc-reflect/schema/packet_msg.json @@ -318,6 +318,38 @@ } ] }, + "IbcFee": { + "description": "An [ICS-29] IBC fee.\n\nThis is mapped to an [ibc.applications.fee.v1.Fee].\n\n[ICS-29]: https://github.com/cosmos/ibc-go/blob/v7.2.0/docs/middleware/ics29-fee/overview.md [ibc.applications.fee.v1.Fee]: https://github.com/cosmos/ibc-go/blob/v7.2.0/proto/ibc/applications/fee/v1/fee.proto#L11-L31", + "type": "object", + "required": [ + "ack", + "recv", + "timeout" + ], + "properties": { + "ack": { + "description": "The packet acknowledgement fee", + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "recv": { + "description": "The packet receive fee", + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "timeout": { + "description": "The packet timeout fee", + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + } + }, "IbcMsg": { "description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points)", "oneOf": [ @@ -349,6 +381,17 @@ "description": "exisiting channel to send the tokens over", "type": "string" }, + "packet_fee": { + "description": "When set, a [MsgPayPacketFee] with the provided fee is created and emitted before the packet is sent. `signer` gets filled automatically with the contract address. No relayer restrictions will be in place.\n\n[MsgPayPacketFee]: https://github.com/cosmos/ibc-go/blob/v7.2.0/proto/ibc/applications/fee/v1/tx.proto#L76-L93", + "anyOf": [ + { + "$ref": "#/definitions/IbcFee" + }, + { + "type": "null" + } + ] + }, "timeout": { "description": "when packet times out, measured on remote chain", "allOf": [ @@ -387,6 +430,17 @@ "data": { "$ref": "#/definitions/Binary" }, + "packet_fee": { + "description": "When set, a [MsgPayPacketFee] with the provided fee is created and emitted before the packet is sent. `signer` gets filled automatically with the contract address. No relayer restrictions will be in place.\n\n[MsgPayPacketFee]: https://github.com/cosmos/ibc-go/blob/v7.2.0/proto/ibc/applications/fee/v1/tx.proto#L76-L93", + "anyOf": [ + { + "$ref": "#/definitions/IbcFee" + }, + { + "type": "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 5460db7a9b..ddceb498dc 100644 --- a/contracts/reflect/schema/raw/execute.json +++ b/contracts/reflect/schema/raw/execute.json @@ -377,6 +377,38 @@ } ] }, + "IbcFee": { + "description": "An [ICS-29] IBC fee.\n\nThis is mapped to an [ibc.applications.fee.v1.Fee].\n\n[ICS-29]: https://github.com/cosmos/ibc-go/blob/v7.2.0/docs/middleware/ics29-fee/overview.md [ibc.applications.fee.v1.Fee]: https://github.com/cosmos/ibc-go/blob/v7.2.0/proto/ibc/applications/fee/v1/fee.proto#L11-L31", + "type": "object", + "required": [ + "ack", + "recv", + "timeout" + ], + "properties": { + "ack": { + "description": "The packet acknowledgement fee", + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "recv": { + "description": "The packet receive fee", + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "timeout": { + "description": "The packet timeout fee", + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + } + }, "IbcMsg": { "description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points)", "oneOf": [ @@ -408,6 +440,17 @@ "description": "exisiting channel to send the tokens over", "type": "string" }, + "packet_fee": { + "description": "When set, a [MsgPayPacketFee] with the provided fee is created and emitted before the packet is sent. `signer` gets filled automatically with the contract address. No relayer restrictions will be in place.\n\n[MsgPayPacketFee]: https://github.com/cosmos/ibc-go/blob/v7.2.0/proto/ibc/applications/fee/v1/tx.proto#L76-L93", + "anyOf": [ + { + "$ref": "#/definitions/IbcFee" + }, + { + "type": "null" + } + ] + }, "timeout": { "description": "when packet times out, measured on remote chain", "allOf": [ @@ -446,6 +489,17 @@ "data": { "$ref": "#/definitions/Binary" }, + "packet_fee": { + "description": "When set, a [MsgPayPacketFee] with the provided fee is created and emitted before the packet is sent. `signer` gets filled automatically with the contract address. No relayer restrictions will be in place.\n\n[MsgPayPacketFee]: https://github.com/cosmos/ibc-go/blob/v7.2.0/proto/ibc/applications/fee/v1/tx.proto#L76-L93", + "anyOf": [ + { + "$ref": "#/definitions/IbcFee" + }, + { + "type": "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 aa6f6da44c..5ab2abae6a 100644 --- a/contracts/reflect/schema/reflect.json +++ b/contracts/reflect/schema/reflect.json @@ -387,6 +387,38 @@ } ] }, + "IbcFee": { + "description": "An [ICS-29] IBC fee.\n\nThis is mapped to an [ibc.applications.fee.v1.Fee].\n\n[ICS-29]: https://github.com/cosmos/ibc-go/blob/v7.2.0/docs/middleware/ics29-fee/overview.md [ibc.applications.fee.v1.Fee]: https://github.com/cosmos/ibc-go/blob/v7.2.0/proto/ibc/applications/fee/v1/fee.proto#L11-L31", + "type": "object", + "required": [ + "ack", + "recv", + "timeout" + ], + "properties": { + "ack": { + "description": "The packet acknowledgement fee", + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "recv": { + "description": "The packet receive fee", + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + }, + "timeout": { + "description": "The packet timeout fee", + "type": "array", + "items": { + "$ref": "#/definitions/Coin" + } + } + } + }, "IbcMsg": { "description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points)", "oneOf": [ @@ -418,6 +450,17 @@ "description": "exisiting channel to send the tokens over", "type": "string" }, + "packet_fee": { + "description": "When set, a [MsgPayPacketFee] with the provided fee is created and emitted before the packet is sent. `signer` gets filled automatically with the contract address. No relayer restrictions will be in place.\n\n[MsgPayPacketFee]: https://github.com/cosmos/ibc-go/blob/v7.2.0/proto/ibc/applications/fee/v1/tx.proto#L76-L93", + "anyOf": [ + { + "$ref": "#/definitions/IbcFee" + }, + { + "type": "null" + } + ] + }, "timeout": { "description": "when packet times out, measured on remote chain", "allOf": [ @@ -456,6 +499,17 @@ "data": { "$ref": "#/definitions/Binary" }, + "packet_fee": { + "description": "When set, a [MsgPayPacketFee] with the provided fee is created and emitted before the packet is sent. `signer` gets filled automatically with the contract address. No relayer restrictions will be in place.\n\n[MsgPayPacketFee]: https://github.com/cosmos/ibc-go/blob/v7.2.0/proto/ibc/applications/fee/v1/tx.proto#L76-L93", + "anyOf": [ + { + "$ref": "#/definitions/IbcFee" + }, + { + "type": "null" + } + ] + }, "timeout": { "description": "when packet times out, measured on remote chain", "allOf": [