Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IBC fees to IbcMsg::Transfer and ::SendPacket #1749

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions contracts/ibc-reflect-send/schema/ibc-reflect-send.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -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": [
Expand Down Expand Up @@ -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": [
Expand Down
54 changes: 54 additions & 0 deletions contracts/ibc-reflect-send/schema/packet_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -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": [
Expand Down Expand Up @@ -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": [
Expand Down
54 changes: 54 additions & 0 deletions contracts/ibc-reflect-send/schema/raw/execute.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -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": [
Expand Down Expand Up @@ -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": [
Expand Down
3 changes: 3 additions & 0 deletions contracts/ibc-reflect-send/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions contracts/ibc-reflect-send/src/ibc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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),
}
Expand Down
2 changes: 2 additions & 0 deletions contracts/ibc-reflect-send/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
54 changes: 54 additions & 0 deletions contracts/ibc-reflect/schema/packet_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -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": [
Expand Down Expand Up @@ -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": [
Expand Down
Loading