Skip to content

Commit db38a1a

Browse files
committed
docs: updated README.md
1 parent 7773fbd commit db38a1a

File tree

1 file changed

+34
-6
lines changed

1 file changed

+34
-6
lines changed

README.md

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ This is a CosmWasm smart contract that communicates with the golang `ica/host` m
2323
- [Using `InstantiateMsg`](#using-instantiatemsg)
2424
- [Using `ExecuteMsg::CreateChannel`](#using-executemsgcreatechannel)
2525
- [Execute an interchain account transaction](#execute-an-interchain-account-transaction)
26-
- [`SendCosmosMsgs`](#sendcosmosmsgs)
26+
- [Querying the host chain](#querying-the-host-chain)
2727
- [Execute a callback](#execute-a-callback)
2828
- [Channel Closing and Reopening](#channel-closing-and-reopening)
2929
- [Channel Closing](#channel-closing)
@@ -99,11 +99,9 @@ Learn more about channel closing and reopening [here](#channel-closing-and-reope
9999

100100
### Execute an interchain account transaction
101101

102-
`ExecuteMsg::SendCosmosMsgs` is used to commit a packet to be sent to the host chain. It accepts `cosmwasm_std::CosmosMsg`s to be sent to the host chain. (The contract then these messages to protobuf messages and sends them to the host chain. You can execute any custom message using `CosmosMsg::Stargate`.
102+
`ExecuteMsg::SendCosmosMsgs` is used to commit a packet to be sent to the host chain. It accepts `cosmwasm_std::CosmosMsg`s to be sent to the host chain. (The contract then these messages to protobuf messages and sends them to the host chain. You can execute any custom message using `CosmosMsg::Stargate`).
103103

104-
#### `SendCosmosMsgs`
105-
106-
In CosmWasm contracts, `CosmosMsg` are used to execute transactions on the chain that the contract is deployed on. In this contract, we use `CosmosMsg`s to execute transactions on the host chain. This is done by converting the `CosmosMsg`s to an ICA tx based on the encoding of the channel. The ICA tx is then sent to the host chain. The host chain then executes the ICA tx and sends the result back to this contract.
104+
In CosmWasm contracts, `CosmosMsg` are used to execute transactions on the chain that the contract is deployed on. In this contract, we use `CosmosMsg`s to execute transactions on the host (counterparty) chain. This is done by converting the `CosmosMsg`s to a protobuf ICA tx. The ICA tx is then sent to the host chain. The host chain then executes the ICA tx and sends the result back to this contract.
107105

108106
This execute message allows the user to submit an array of [`cosmwasm_std::CosmosMsg`](https://github.com/CosmWasm/cosmwasm/blob/v1.5.0/packages/std/src/results/cosmos_msg.rs#L27) which are then converted by the contract to an atomic ICA tx.
109107

@@ -117,7 +115,15 @@ pub enum ExecuteMsg {
117115
/// **This is the recommended way to send messages to the ICA host.**
118116
SendCosmosMsgs {
119117
/// The stargate messages to convert and send to the ICA host.
118+
#[serde_as(deserialize_as = "serde_with::DefaultOnNull")]
120119
messages: Vec<CosmosMsg>,
120+
/// The stargate queries to convert and send to the ICA host.
121+
/// The queries are executed after the messages.
122+
#[cfg(feature = "query")]
123+
#[serde(skip_serializing_if = "Vec::is_empty")]
124+
#[serde(default)]
125+
#[serde_as(deserialize_as = "serde_with::DefaultOnNull")]
126+
queries: Vec<cosmwasm_std::QueryRequest<cosmwasm_std::Empty>>,
121127
/// Optional memo to include in the ibc packet.
122128
#[serde(skip_serializing_if = "Option::is_none")]
123129
packet_memo: Option<String>,
@@ -131,7 +137,7 @@ pub enum ExecuteMsg {
131137
}
132138
```
133139

134-
(`Stargate` allows the user to submit any protobuf message to the host chain.)
140+
(`CosmosMsg::Stargate` allows the user to submit any protobuf message to the host chain.)
135141

136142
Here is an example execute message that delegates tokens to a validator on the host chain and then votes on a proposal (atomically).
137143

@@ -163,6 +169,14 @@ Here is an example execute message that delegates tokens to a validator on the h
163169
}
164170
```
165171

172+
#### Querying the host chain
173+
174+
This contract also supports querying the host chain. To do this, you can submit a `ExecuteMsg::SendCosmosMsgs` with the queries field filled out. The queries are always executed after the messages, and their results are deserialized and returned in the [callbacks](#execute-a-callback).
175+
176+
Similarly to `CosmosMsg`, in CosmWasm contracts, `QueryRequest` are used to execute queries on the chain that the contract is deployed on. In this contract, we use `QueryRequest`s to execute queries as transactions on the host (counterparty) chain. This is done by converting the `QueryRequests`s to a protobuf ICA tx. The ICA tx is then sent to the host chain. The host chain then executes the ICA tx and sends the result back to this contract.
177+
178+
Note that if both `messages` and `queries` are provided, the `queries` are executed after the `messages`.
179+
166180
### Execute a callback
167181

168182
This contract supports external contract callbacks. See [`src/types/callbacks.rs`](./src/types/callbacks.rs) to learn what callbacks are supported.
@@ -183,6 +197,20 @@ pub enum ExecuteMsg {
183197
}
184198
```
185199

200+
Note that this crate also includes a proc-macro to add the `ReceiveIcaCallback` variant to the `ExecuteMsg` enum. This is done by adding the following macro to the callback contract:
201+
202+
```rust, ignore
203+
use cosmwasm_schema::cw_serde;
204+
use cw_ica_controller::helpers::ica_callback_execute;
205+
206+
#[ica_callback_execute]
207+
#[cw_serde]
208+
/// This is the execute message of the contract.
209+
pub enum ExecuteMsg {
210+
// ... other variants
211+
}
212+
```
213+
186214
Any contract that imports the `cw-ica-controller` as a library needs to disable the `default-features` of the `cw-ica-controller` crate.
187215
This is because the `default-features` of the `cw-ica-controller` crate includes the CosmWasm entry points.
188216

0 commit comments

Comments
 (0)