Skip to content

Commit

Permalink
chore: v0.6.0 release chores (#124)
Browse files Browse the repository at this point in the history
* docs: tagged CHANGELOG

* docs: tagged 'v0.6.x' versioned_docs

* docs: marked v0.6.x the latest version
  • Loading branch information
srdtrk committed Jun 18, 2024
1 parent 5a65b07 commit a687ef7
Show file tree
Hide file tree
Showing 17 changed files with 777 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [Unreleased]

## v0.6.0 (2024-06-18)

### Features

- Added support for ICA queries. (https://github.com/srdtrk/cw-ica-controller/issues/88)
Expand Down
18 changes: 11 additions & 7 deletions docs/docusaurus.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {themes as prismThemes} from 'prism-react-renderer';
import type {Config} from '@docusaurus/types';
import { themes as prismThemes } from 'prism-react-renderer';
import type { Config } from '@docusaurus/types';
import type * as Preset from '@docusaurus/preset-classic';

const config: Config = {
Expand Down Expand Up @@ -43,13 +43,17 @@ const config: Config = {
routeBasePath: "/",
sidebarCollapsed: false,
// Select the latest version
lastVersion: "v0.5.x",
lastVersion: "v0.6.x",
versions: {
current: {
label: 'main',
path: 'main',
banner: 'unreleased',
},
"v0.6.x": {
label: 'v0.6.x',
path: 'v0.6',
},
"v0.5.x": {
label: 'v0.5.x',
path: 'v0.5',
Expand Down Expand Up @@ -158,10 +162,10 @@ const config: Config = {
},
// github codeblock theme configuration
codeblock: {
showGithubLink: true,
githubLinkLabel: 'View on GitHub',
showRunmeLink: false,
runmeLinkLabel: 'Checkout via Runme'
showGithubLink: true,
githubLinkLabel: 'View on GitHub',
showRunmeLink: false,
runmeLinkLabel: 'Checkout via Runme'
},
} satisfies Preset.ThemeConfig,
plugins: [
Expand Down
43 changes: 43 additions & 0 deletions docs/versioned_docs/version-v0.6.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.6.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,58 @@
---
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/6843b80b29af97b9c4561ad487420e2f54857553/src/types/msg.rs#L95-L107
```

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.**

### `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).
151 changes: 151 additions & 0 deletions docs/versioned_docs/version-v0.6.x/contract-api/02-execute-msg.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
---
title: ExecuteMsg
sidebar_label: ExecuteMsg
sidebar_position: 2
slug: /contract-api/execute-msg
---

# `ExecuteMsg`

The `ExecuteMsg` is the message that is used to interact with the `cw-ica-controller` contract.
**All execute messages are only callable by the owner of the contract.**

## `CreateChannel`

```rust reference
https://github.com/srdtrk/cw-ica-controller/blob/7773fbd8d4e227b6c942f0c88575f9800809b4bf/src/types/msg.rs#L29-L39
```

This message is used to initiate an ICS-27 channel open handshake. It is only callable by the owner.
This message only takes one optional parameter: `channel_open_init_options`.

If this parameter is left empty, then the contract will use the `channel_open_init_options` that were last
passed to the `InstantiateMsg` or `CreateChannel` messages.

If this parameter is set, then the contract will use the `channel_open_init_options` that are passed to this
message and save them for future `CreateChannel` messages.

## `CloseChannel`

```rust reference
https://github.com/srdtrk/cw-ica-controller/blob/7773fbd8d4e227b6c942f0c88575f9800809b4bf/src/types/msg.rs#L40-L41
```

This message is used to close the ICS-27 channel. It is only callable by the owner.
The channel can then be reopened with parameters (e.g. channel ordering and version) that are different from the
original channel open handshake.

## `SendCosmosMsgs`

```rust reference
https://github.com/srdtrk/cw-ica-controller/blob/7773fbd8d4e227b6c942f0c88575f9800809b4bf/src/types/msg.rs#L42-L64
```

Once an ICS-27 channel open handshake is complete, the owner can control the interchain account on the counterparty
chain. To give the owner a familiar interface, this message allows the owner to take actions with the interchain
account using `CosmosMsg`s. This is the recommended way to use the interchain account. We will go over the fields of
this message in detail.

### `messages`

This is a list of `CosmosMsg`s that the contract will execute on the counterparty chain using the interchain account.
This execution is atomic. If any of the `CosmosMsg`s fail, then the entire execution will fail.

:::note

All applicable `CosmosMsg`s are supported if the channel was opened with `tx_encoding` set to `proto3`.
The `proto3json` encoding is not supported by this contract anymore.

| **CosmosMsg** | `proto3` |
|:------------------------------------------:|:--------:|
| `Stargate` ||
| `BankMsg::Send` ||
| `BankMsg::Burn` ||
| `IbcMsg::Transfer` ||
| `IbcMsg::SendPacket` | N/A |
| `IbcMsg::CloseChannel` | N/A |
| `WasmMsg::*` ||
| `GovMsg::*` ||
| `StakingMsg::Delegate` ||
| `StakingMsg::*` | 🟢 |
| `DistributionMsg::WithdrawDelegatorReward` | 🟢 |
| `DistributionMsg::*` ||

Note that `🟢` means that the `CosmosMsg` is supported but not tested in the contract's test suite.
These will be tested in the future.

:::

### `queries`

This is a list of `QueryRequest`s that the contract will execute on the counterparty chain using the interchain account.

:::warning

This feature only works if the host (counterparty) chain is on ibc-go v7.5+. If the host chain is on an older version, then the packet will return an error acknowledgement.

:::

:::info

If both `messages` and `queries` are provided, then the `messages` will be executed first. If the `messages` are successful, then the `queries` will be executed. If any of the `queries` fail, then the entire execution will fail.

:::

:::note

In CosmosSDK, query execution is not generally deterministic. This is the main reason why not all query requests are supported. The supported query requests are:

| **QueryRequest** | `proto3` |
|:-------------------:|:--------:|
| `BankQuery` ||
| `Stargate` ||
| `StakingQuery` ||
| `IbcQuery` ||
| `DistributionQuery` ||
| `WasmQuery` ||

Note that not all Stargate queries are supported. Only queries which are marked with [`module_query_safe`](https://github.com/cosmos/cosmos-sdk/blob/27a231ae4816fd8c3ee39a1cc02eccf977fb1b79/proto/cosmos/query/v1/query.proto#L36) tag are supported. You can find a list of supported queries in the [ibc-go documentation](https://ibc.cosmos.network/main/apps/interchain-accounts/messages/#queries) for different versions of ibc-go.

Note that `WasmQuery` support will be added once [this issue](https://github.com/CosmWasm/wasmd/issues/1903) is resolved. Moreover, governance queries (as stargate queries) and `DistributionQuery` will be supported in the next version of the SDK.

:::

### `packet_memo`

This is the IBC packet memo that will be included in the ICS-27 packet. It is optional and defaults to `""`.
Additionally, the memo field is used by some IBC middleware to execute custom logic on the counterparty chain.
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.5.0/src/ibc/types/packet.rs#L15-L16).

## `UpdateCallbackAddress`

```rust reference
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.
This is useful if the owner wants to change the contract that receives the callbacks.
If set to `None`, then no callbacks will be sent.

## `UpdateOwnership`

```rust reference
https://github.com/larry0x/cw-plus-plus/blob/ownable-v0.5.0/packages/ownable/derive/src/lib.rs#L86-L90
```

This message type is provided by the [cw-ownable](https://crates.io/crates/cw-ownable) crate. It wraps a
`cw_ownable::Action` enum.

```rust reference
https://github.com/larry0x/cw-plus-plus/blob/ownable-v0.5.0/packages/ownable/src/lib.rs#L31-L57
```

The owner can propose to transfer the ownership of the contract to a new address using `Action::TransferOwnership` and
set and expiry time for the proposal. If the proposal is accepted before the expiry time through
`Action::AcceptOwnership`, then the ownership of the contract is transferred to the new address.

You can learn more about `cw-ownable` in its crate documentation.
64 changes: 64 additions & 0 deletions docs/versioned_docs/version-v0.6.x/contract-api/03-query-msg.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
title: QueryMsg
sidebar_label: QueryMsg
sidebar_position: 3
slug: /contract-api/query-msg
---

# `QueryMsg`

The `QueryMsg` is the message that allows you to see the state of the contract. Therefore, it is important to
understand the state of the contract.

## `GetChannel`

```rust reference
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.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#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/v0.5.0/src/types/state.rs#L39-L50
```

Lets look at the fields of the `ContractState`:

### `ica_info`

This field will be empty if the channel handshake has not been completed. Otherwise, it will contain the
following information:

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

### `callback_address`

This is the contract address that the `cw-ica-controller` contract will send callbacks to. If this field is empty,
then the contract will not send callbacks.

## `Ownership`

```rust reference
https://github.com/larry0x/cw-plus-plus/blob/ownable-v0.5.0/packages/ownable/derive/src/lib.rs#L142-L144
```

This message type is provided by the [cw-ownable](https://crates.io/crates/cw-ownable) crate. It allows to query
the ownership of the contract. It returns `Ownership<String>`:

```rust reference
https://github.com/larry0x/cw-plus-plus/blob/ownable-v0.5.0/packages/ownable/src/lib.rs#L14-L29
```
Loading

0 comments on commit a687ef7

Please sign in to comment.