Skip to content

Commit

Permalink
Adapt contracts to packet_fee addition
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Jun 27, 2023
1 parent 1764141 commit 1193666
Show file tree
Hide file tree
Showing 9 changed files with 332 additions and 0 deletions.
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

0 comments on commit 1193666

Please sign in to comment.