Skip to content

Commit

Permalink
docs: added docs for v0.5.x (#94)
Browse files Browse the repository at this point in the history
* docs: v0.5.0

* imp: ran 'npm run docusaurus docs:version v0.5.x'
  • Loading branch information
srdtrk authored Mar 25, 2024
1 parent e1e9a69 commit 295c1ec
Show file tree
Hide file tree
Showing 20 changed files with 782 additions and 24 deletions.
4 changes: 2 additions & 2 deletions docs/docs/contract-api/01-instantiate-msg.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ slug: /contract-api/instantiate-msg
The `InstantiateMsg` is the message that is used to instantiate the `cw-ica-controller` contract.

```rust reference
https://github.com/srdtrk/cw-ica-controller/blob/v0.4.0/src/types/msg.rs#L8-L21
https://github.com/srdtrk/cw-ica-controller/blob/v0.5.0/src/types/msg.rs#L8-L21
```

## Fields
Expand All @@ -24,7 +24,7 @@ If left empty, the owner is set to the sender of the `InstantiateMsg`.
### `channel_open_init_options`

```rust reference
https://github.com/srdtrk/cw-ica-controller/blob/29472c6b30704c101268b9d2971ddfd8b91b24b1/src/types/msg.rs#L122-L138
https://github.com/srdtrk/cw-ica-controller/blob/v0.5.0/src/types/msg.rs#L124-L140
```

These are the options required for the contract to initiate an ICS-27 channel open handshake.
Expand Down
12 changes: 6 additions & 6 deletions docs/docs/contract-api/02-execute-msg.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The `ExecuteMsg` is the message that is used to interact with the `cw-ica-contro
## `CreateChannel`

```rust reference
https://github.com/srdtrk/cw-ica-controller/blob/v0.4.0/src/types/msg.rs#L27-L37
https://github.com/srdtrk/cw-ica-controller/blob/v0.5.0/src/types/msg.rs#L27-L37
```

This message is used to initiate an ICS-27 channel open handshake. It is only callable by the owner.
Expand All @@ -28,7 +28,7 @@ message and save them for future `CreateChannel` messages.
## `CloseChannel`

```rust reference
https://github.com/srdtrk/cw-ica-controller/blob/9890793d3a19a9ec068e26627ec99ec48b3b9d92/src/types/msg.rs#L38-L39
https://github.com/srdtrk/cw-ica-controller/blob/v0.5.0/src/types/msg.rs#L38-L39
```

This message is used to close the ICS-27 channel. It is only callable by the owner.
Expand All @@ -38,7 +38,7 @@ original channel open handshake.
## `SendCosmosMsgs`

```rust reference
https://github.com/srdtrk/cw-ica-controller/blob/v0.4.0/src/types/msg.rs#L38-L52
https://github.com/srdtrk/cw-ica-controller/blob/v0.5.0/src/types/msg.rs#L40-L54
```

Once an ICS-27 channel open handshake is complete, the owner can control the interchain account on the counterparty
Expand Down Expand Up @@ -85,12 +85,12 @@ But most of these middlewares do not yet support ICS-27 channels.

### `timeout_seconds`

This is the timeout in seconds that will be used for the ICS-27 packet. It is optional and defaults to [`DEFAULT_TIMEOUT_SECONDS`](https://github.com/srdtrk/cw-ica-controller/blob/v0.4.0/src/ibc/types/packet.rs#L15-L16).
This is the timeout in seconds that will be used for the ICS-27 packet. It is optional and defaults to [`DEFAULT_TIMEOUT_SECONDS`](https://github.com/srdtrk/cw-ica-controller/blob/v0.5.0/src/ibc/types/packet.rs#L15-L16).

## `SendCustomIcaMessages`

```rust reference
https://github.com/srdtrk/cw-ica-controller/blob/v0.4.0/src/types/msg.rs#L53-L89
https://github.com/srdtrk/cw-ica-controller/blob/v0.5.0/src/types/msg.rs#L55-L91
```

Recall that the `SendCosmosMsgs` message is the recommended way to use the interchain account. Use this only if you
Expand All @@ -108,7 +108,7 @@ I will not go into the details of the fields of this message since it is not rec
## `UpdateCallbackAddress`

```rust reference
https://github.com/srdtrk/cw-ica-controller/blob/v0.4.0/src/types/msg.rs#L90-L95
https://github.com/srdtrk/cw-ica-controller/blob/v0.5.0/src/types/msg.rs#L92-L97
```

This message is used to update the contract address that this contract will send callbacks to.
Expand Down
10 changes: 5 additions & 5 deletions docs/docs/contract-api/03-query-msg.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ understand the state of the contract.
## `GetChannel`

```rust reference
https://github.com/srdtrk/cw-ica-controller/blob/v0.4.0/src/types/msg.rs#L103-L105
https://github.com/srdtrk/cw-ica-controller/blob/v0.5.0/src/types/msg.rs#L105-L107
```

This message is used to query the state of the ICS-27 channel as tracked by the contract. It returns

```rust reference
https://github.com/srdtrk/cw-ica-controller/blob/v0.4.0/src/types/state.rs#L156-L164
https://github.com/srdtrk/cw-ica-controller/blob/v0.5.0/src/types/state.rs#L158-L166
```

## `GetContractState`

```rust reference
https://github.com/srdtrk/cw-ica-controller/blob/v0.4.0/src/types/msg.rs#L106-L108
https://github.com/srdtrk/cw-ica-controller/blob/v0.4.0/src/types/msg.rs#L108-L110
```

This message is used to query the state of the contract. It returns

```rust reference
https://github.com/srdtrk/cw-ica-controller/blob/9890793d3a19a9ec068e26627ec99ec48b3b9d92/src/types/state.rs#L39-L50
https://github.com/srdtrk/cw-ica-controller/blob/v0.5.0/src/types/state.rs#L39-L50
```

Lets look at the fields of the `ContractState`:
Expand All @@ -42,7 +42,7 @@ This field will be empty if the channel handshake has not been completed. Otherw
following information:

```rust reference
https://github.com/srdtrk/cw-ica-controller/blob/v0.4.0/src/types/state.rs#L109-L115
https://github.com/srdtrk/cw-ica-controller/blob/v0.5.0/src/types/state.rs#L90-L96
```

### `callback_address`
Expand Down
16 changes: 8 additions & 8 deletions docs/docs/how-it-works/02-go-vs-cosmwasm.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ This means that the users of `cw-ica-controller` can use the same contract on an

But there is more! `cw-ica-controller` is also able to do some things that the golang API limits you from doing.

| **Feature** | `cw-ica-controller` | golang `ica-controller` | **Description** |
|:-------------------------------------------:|:-------------------:|:-----------------------:|:-------------------------------------------------------------------------------------------------------------------------:|
| Callbacks ||| Golang implementation does not make callbacks |
| Submit `cosmwasm_std::CosmosMsg`s ||| Golang implementation requires ICA transactions to be submitted in protobuf or `proto3json` format. |
| Reopen an ICA channel with different params ||| In golang implementation, if the channel closes due to timeout the channel can only be reopened with the same parameters. |
| Change owner ||| `cw-ica-controller` uses [`cw-ownable`][1] for owner management |
| Live upgrades ||| In golang implementation, new features require coordinated chain upgrades which could get blocked on upgrading CosmosSDK. |
| Permanent channel closure ||| Golang implementation allows any relayer to always reopen any ICA channel (with the same parameters). |
| **Feature** | `cw-ica-controller` | golang `ica-controller` | neutron bindings | **Description** |
|:-------------------------------------------:|:-------------------:|:-----------------------:|------------------|:-------------------------------------------------------------------------------------------------------------------------:|
| Callbacks ||| | Golang implementation does not make callbacks |
| Submit `cosmwasm_std::CosmosMsg`s ||| | Golang implementation requires ICA transactions to be submitted in protobuf or `proto3json` format. |
| Reopen an ICA channel with different params ||| | In golang implementation, if the channel closes due to timeout the channel can only be reopened with the same parameters. |
| Change owner ||| | `cw-ica-controller` uses [`cw-ownable`][1] for owner management |
| Live upgrades ||| | In golang implementation, new features require coordinated chain upgrades which could get blocked on upgrading CosmosSDK. |
| Permanent channel closure ||| | Golang implementation allows any relayer to always reopen any ICA channel (with the same parameters). |

[1]: https://github.com/larry0x/cw-plus-plus/tree/main/packages/ownable
10 changes: 7 additions & 3 deletions docs/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,24 @@ const config: Config = {
// Please change this to your repo.
// Remove this to remove the "edit this page" links.
editUrl:
'https://github.com/srdtrk/cw-ica-controller/tree/feat/docusaurus-docs/docs',
'https://github.com/srdtrk/cw-ica-controller/tree/main/docs',
// Routed the docs to the root path
routeBasePath: "/",
sidebarCollapsed: false,
// Select the latest version
lastVersion: "v0.4.x",
lastVersion: "v0.5.x",
versions: {
current: {
label: 'main',
path: 'main',
banner: 'unreleased',
},
"v0.5.x": {
label: 'v0.5.x',
path: 'v0.5',
},
"v0.4.x": {
label: 'v0.4',
label: 'v0.4.x',
path: 'v0.4',
},
},
Expand Down
43 changes: 43 additions & 0 deletions docs/versioned_docs/version-v0.5.x/00-intro.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
title: Introduction
sidebar_label: Introduction
sidebar_position: 0
slug: /
---

import HighlightTag from '@site/src/components/HighlightTag';

# CosmWasm ICA Controller

<HighlightTag type="concepts"/><HighlightTag type="basics"/>

Welcome to the documentation for CosmWasm Interchain Accounts Controller. This document will guide you through
understanding the [ICS-27](https://github.com/cosmos/ibc/tree/main/spec/app/ics-027-interchain-accounts)
Interchain Accounts protocol and how to use `cw-ica-controller` to create and manage interchain accounts on
any IBC enabled CosmWasm chain.

The CosmWasm ICA Controller is a CosmWasm contract that implements the ICS-27 interchain accounts controller in
pure Rust. It is designed to be used by other CosmWasm contracts to create and manage interchain accounts on
the chain where the contract is deployed.

## High Level Overview

The following diagram shows how `cw-ica-controller` works at a high level.

![High Level Overview](/img/cw-ica-controller.svg)

The `cw-ica-controller` contract code is deployed on a chain that supports IBC CosmWasm. This chain does not need
to support ICS-27 interchain accounts nor does it need to support any custom IBC bindings. Then when an external
account or a contract instantiates a `cw-ica-controller` contract, the contract will initiate the ICS-27 handshake
with a chain that supports ICS-27 interchain accounts based on the options provided by the caller.

:::note

The counterparty chain need not be a CosmWasm chain. It can be any chain that uses ibc-go and supports `ICS-27`.
Such as CosmosHub, Osmosis, etc.

:::

Then the rest of the ICS-27 handshake is completed by the relayers automatically. Both the hermes relayer and the
go relayer support `ICS-27` interchain accounts. Once the handshake is complete, the `cw-ica-controller` contract
makes a callback to the callback contract if one was provided during instantiation.
22 changes: 22 additions & 0 deletions docs/versioned_docs/version-v0.5.x/contract-api/00-intro.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: Contract API
sidebar_label: Overview
sidebar_position: 0
slug: /contract-api/intro
---

import HighlightTag from '@site/src/components/HighlightTag';

# Contract API

<HighlightTag type="developer"/>

In this section we will cover how to interact with the contract and design decisions that were made. A full integration guide is work in progress.

In this section, we cover the following topics:

- ✉️ [`InstantiateMsg`](./01-instantiate-msg.mdx)
- 📨 [`ExecuteMsg`](./02-execute-msg.mdx)
- 🤔 [`QueryMsg`](./03-query-msg.mdx)
- 🤙 [Callbacks](./04-callbacks.mdx)
- 📜 [Events](./05-events.mdx)
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
title: InstantiateMsg
sidebar_label: InstantiateMsg
sidebar_position: 1
slug: /contract-api/instantiate-msg
---

# `InstantiateMsg`

The `InstantiateMsg` is the message that is used to instantiate the `cw-ica-controller` contract.

```rust reference
https://github.com/srdtrk/cw-ica-controller/blob/v0.5.0/src/types/msg.rs#L8-L21
```

## Fields

### `owner`

This contract has an owner who is allowed to call the `ExecuteMsg` methods.
The owner management is handled by the amazing [cw-ownable](https://crates.io/crates/cw-ownable) crate.
If left empty, the owner is set to the sender of the `InstantiateMsg`.

### `channel_open_init_options`

```rust reference
https://github.com/srdtrk/cw-ica-controller/blob/v0.5.0/src/types/msg.rs#L124-L140
```

These are the options required for the contract to initiate an ICS-27 channel open handshake.
This contract requires there to be an IBC connection between the two chains before it can open a channel.

#### `connection_id`

The identifier of the IBC connection end on the deployed (source) chain. (The underlying IBC light client must
be live.) If this field is set to a non-existent connection, the execution of the `InstantiateMsg` will fail.

#### `counterparty_connection_id`

The identifier of the IBC connection end on the counterparty (destination) chain. (The underlying IBC light
client must be live.) If this field is set to a non-existent connection or a different connection's end,
then the execution of the `InstantiateMsg` will not fail. This is because the source chain does not know
about the counterparty chain's connections. Instead, the channel open handshake will fail to complete.

If the contract was instantiated with a `counterparty_connection_id` that does not match the connection
end on the counterparty chain, then the owner must call [`ExecuteMsg::CreateChannel`](./02-execute-msg.mdx#createchannel) with the correct parameters to start a new channel open handshake.

#### `counterparty_port_id`

This is a required parameter for the ICS-27 channel version metadata. I've added it here for consistency.
Currently, the only supported value is `icahost`. If left empty, it is set to `icahost`.
**So you should ignore this field.**

#### `tx_encoding`

The ICS-27 implementation in `ibc-go` supports two transaction encoding formats: `proto3` and `proto3json`.
This contract supports both formats, but defaults to `proto3`. This is because most chains don't yet support
`proto3json` encoding. Moreover, this contract does not support some `CosmosMsg` while using `proto3json`.
**So, if you are unsure, leave this field empty.**

### `send_callbacks_to`

This is the address of the contract that will receive the callbacks from the `cw-ica-controller` contract.
This may be the same address as the `owner` or a different address. If left empty, no callbacks will be sent.
Learn more about callbacks [here](./04-callbacks.mdx).
Loading

0 comments on commit 295c1ec

Please sign in to comment.