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

Document ibc #884

Merged
merged 13 commits into from
Apr 19, 2021
418 changes: 418 additions & 0 deletions IBC.md

Large diffs are not rendered by default.

104 changes: 70 additions & 34 deletions contracts/ibc-reflect-send/schema/execute_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@
"required": [
"amount",
"channel_id",
"timeout",
"to_address"
],
"properties": {
Expand All @@ -359,26 +360,14 @@
"description": "exisiting channel to send the tokens over",
"type": "string"
},
"timeout_block": {
"description": "block after which the packet times out. at least one of timeout_block, timeout_timestamp is required",
"anyOf": [
{
"$ref": "#/definitions/IbcTimeoutBlock"
},
"timeout": {
"description": "when packet times out, measured on remote chain",
"allOf": [
{
"type": "null"
"$ref": "#/definitions/IbcTimeout"
}
]
},
"timeout_timestamp": {
"description": "block timestamp (nanoseconds since UNIX epoch) after which the packet times out. See https://golang.org/pkg/time/#Time.UnixNano at least one of timeout_block, timeout_timestamp is required",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0.0
},
"to_address": {
"description": "address on the remote chain to receive these tokens",
"type": "string"
Expand All @@ -399,7 +388,8 @@
"type": "object",
"required": [
"channel_id",
"data"
"data",
"timeout"
],
"properties": {
"channel_id": {
Expand All @@ -408,33 +398,21 @@
"data": {
"$ref": "#/definitions/Binary"
},
"timeout_block": {
"description": "block height after which the packet times out. at least one of timeout_block, timeout_timestamp is required",
"anyOf": [
{
"$ref": "#/definitions/IbcTimeoutBlock"
},
"timeout": {
"description": "when packet times out, measured on remote chain",
"allOf": [
{
"type": "null"
"$ref": "#/definitions/IbcTimeout"
}
]
},
"timeout_timestamp": {
"description": "block timestamp (nanoseconds since UNIX epoch) after which the packet times out. See https://golang.org/pkg/time/#Time.UnixNano at least one of timeout_block, timeout_timestamp is required",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0.0
}
}
}
},
"additionalProperties": false
},
{
"description": "This will close an existing channel that is owned by this contract. Port is auto-assigned to the contracts' ibc port",
"description": "This will close an existing channel that is owned by this contract. Port is auto-assigned to the contract's IBC port",
"type": "object",
"required": [
"close_channel"
Expand All @@ -456,6 +434,64 @@
}
]
},
"IbcTimeout": {
"anyOf": [
{
"description": "block timestamp (nanoseconds since UNIX epoch) after which the packet times out (measured on the remote chain) See https://golang.org/pkg/time/#Time.UnixNano",
"type": "object",
"required": [
"timestamp_nanos"
],
"properties": {
"timestamp_nanos": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
}
},
"additionalProperties": false
},
{
"description": "block after which the packet times out (measured on remote chain)",
"type": "object",
"required": [
"block"
],
"properties": {
"block": {
"$ref": "#/definitions/IbcTimeoutBlock"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"both"
],
"properties": {
"both": {
"type": "object",
"required": [
"block",
"timestamp_nanos"
],
"properties": {
"block": {
"$ref": "#/definitions/IbcTimeoutBlock"
},
"timestamp_nanos": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
}
}
}
},
"additionalProperties": false
}
]
},
"IbcTimeoutBlock": {
"description": "IBCTimeoutHeight Height is a monotonically increasing data type that can be compared against another Height for the purposes of updating and freezing clients. Ordering is (revision_number, timeout_height)",
"type": "object",
Expand Down
104 changes: 70 additions & 34 deletions contracts/ibc-reflect-send/schema/packet_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@
"required": [
"amount",
"channel_id",
"timeout",
"to_address"
],
"properties": {
Expand All @@ -312,26 +313,14 @@
"description": "exisiting channel to send the tokens over",
"type": "string"
},
"timeout_block": {
"description": "block after which the packet times out. at least one of timeout_block, timeout_timestamp is required",
"anyOf": [
{
"$ref": "#/definitions/IbcTimeoutBlock"
},
"timeout": {
"description": "when packet times out, measured on remote chain",
"allOf": [
{
"type": "null"
"$ref": "#/definitions/IbcTimeout"
}
]
},
"timeout_timestamp": {
"description": "block timestamp (nanoseconds since UNIX epoch) after which the packet times out. See https://golang.org/pkg/time/#Time.UnixNano at least one of timeout_block, timeout_timestamp is required",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0.0
},
"to_address": {
"description": "address on the remote chain to receive these tokens",
"type": "string"
Expand All @@ -352,7 +341,8 @@
"type": "object",
"required": [
"channel_id",
"data"
"data",
"timeout"
],
"properties": {
"channel_id": {
Expand All @@ -361,33 +351,21 @@
"data": {
"$ref": "#/definitions/Binary"
},
"timeout_block": {
"description": "block height after which the packet times out. at least one of timeout_block, timeout_timestamp is required",
"anyOf": [
{
"$ref": "#/definitions/IbcTimeoutBlock"
},
"timeout": {
"description": "when packet times out, measured on remote chain",
"allOf": [
{
"type": "null"
"$ref": "#/definitions/IbcTimeout"
}
]
},
"timeout_timestamp": {
"description": "block timestamp (nanoseconds since UNIX epoch) after which the packet times out. See https://golang.org/pkg/time/#Time.UnixNano at least one of timeout_block, timeout_timestamp is required",
"type": [
"integer",
"null"
],
"format": "uint64",
"minimum": 0.0
}
}
}
},
"additionalProperties": false
},
{
"description": "This will close an existing channel that is owned by this contract. Port is auto-assigned to the contracts' ibc port",
"description": "This will close an existing channel that is owned by this contract. Port is auto-assigned to the contract's IBC port",
"type": "object",
"required": [
"close_channel"
Expand All @@ -409,6 +387,64 @@
}
]
},
"IbcTimeout": {
"anyOf": [
{
"description": "block timestamp (nanoseconds since UNIX epoch) after which the packet times out (measured on the remote chain) See https://golang.org/pkg/time/#Time.UnixNano",
"type": "object",
"required": [
"timestamp_nanos"
],
"properties": {
"timestamp_nanos": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
}
},
"additionalProperties": false
},
{
"description": "block after which the packet times out (measured on remote chain)",
"type": "object",
"required": [
"block"
],
"properties": {
"block": {
"$ref": "#/definitions/IbcTimeoutBlock"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"both"
],
"properties": {
"both": {
"type": "object",
"required": [
"block",
"timestamp_nanos"
],
"properties": {
"block": {
"$ref": "#/definitions/IbcTimeoutBlock"
},
"timestamp_nanos": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
}
}
}
},
"additionalProperties": false
}
]
},
"IbcTimeoutBlock": {
"description": "IBCTimeoutHeight Height is a monotonically increasing data type that can be compared against another Height for the purposes of updating and freezing clients. Ordering is (revision_number, timeout_height)",
"type": "object",
Expand Down
11 changes: 4 additions & 7 deletions contracts/ibc-reflect-send/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cosmwasm_std::{
QueryResponse, Response, StdError, StdResult,
};

use crate::ibc::build_timeout_timestamp;
use crate::ibc::PACKET_LIFETIME;
use crate::ibc_msg::PacketMsg;
use crate::msg::{
AccountInfo, AccountResponse, AdminResponse, ExecuteMsg, InstantiateMsg, ListAccountsResponse,
Expand Down Expand Up @@ -91,8 +91,7 @@ pub fn handle_send_msgs(
let msg = IbcMsg::SendPacket {
channel_id,
data: to_binary(&packet)?,
timeout_block: None,
timeout_timestamp: Some(build_timeout_timestamp(&env.block)),
timeout: env.block.timestamp().plus_seconds(PACKET_LIFETIME).into(),
};

Ok(Response {
Expand Down Expand Up @@ -122,8 +121,7 @@ pub fn handle_check_remote_balance(
let msg = IbcMsg::SendPacket {
channel_id,
data: to_binary(&packet)?,
timeout_block: None,
timeout_timestamp: Some(build_timeout_timestamp(&env.block)),
timeout: env.block.timestamp().plus_seconds(PACKET_LIFETIME).into(),
};

Ok(Response {
Expand Down Expand Up @@ -173,8 +171,7 @@ pub fn handle_send_funds(
channel_id: transfer_channel_id,
to_address: remote_addr,
amount,
timeout_block: None,
timeout_timestamp: Some(build_timeout_timestamp(&env.block)),
timeout: env.block.timestamp().plus_seconds(PACKET_LIFETIME).into(),
};

Ok(Response {
Expand Down
Loading