Skip to content

Commit

Permalink
chore: release 'v0.20.0' chores (#136)
Browse files Browse the repository at this point in the history
* docs: updated CHANGELOG.md

* docs: ran 'npm run docusaurus docs:version v0.20.0'

* Revert "docs: ran 'npm run docusaurus docs:version v0.20.0'"

This reverts commit 046a860.

* docs: ran 'npm run docusaurus docs:version v0.20.x'

* docs: changed default version

* docs: bumped docusaurus to v3.5.1
  • Loading branch information
srdtrk authored Aug 13, 2024
1 parent 9d3f98b commit 44962d0
Show file tree
Hide file tree
Showing 19 changed files with 1,771 additions and 907 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## [Unreleased]

## v0.20.0 (2024-08-13)

### API Breaking Changes

- Upgraded CosmWasm to version 2.1. (https://github.com/srdtrk/cw-ica-controller/pull/133)

## v0.6.1 (2024-07-21)

### State Breaking Changes
Expand Down
6 changes: 5 additions & 1 deletion docs/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,17 @@ const config: Config = {
routeBasePath: "/",
sidebarCollapsed: false,
// Select the latest version
lastVersion: "v0.6.x",
lastVersion: "v0.20.x",
versions: {
current: {
label: 'main',
path: 'main',
banner: 'unreleased',
},
"v0.20.x": {
label: 'v0.20.x',
path: 'v0.20',
},
"v0.6.x": {
label: 'v0.6.x',
path: 'v0.6',
Expand Down
1,888 changes: 988 additions & 900 deletions docs/package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"typecheck": "tsc"
},
"dependencies": {
"@docusaurus/core": "^3.1.1",
"@docusaurus/plugin-client-redirects": "^3.1.1",
"@docusaurus/preset-classic": "^3.1.1",
"@docusaurus/core": "^3.5.1",
"@docusaurus/plugin-client-redirects": "^3.5.1",
"@docusaurus/preset-classic": "^3.5.1",
"@easyops-cn/docusaurus-search-local": "^0.40.1",
"@mdx-js/react": "^3.0.0",
"@radix-ui/react-hover-card": "^1.0.7",
Expand All @@ -32,9 +32,9 @@
"tailwindcss-animate": "^1.0.7"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "^3.1.1",
"@docusaurus/tsconfig": "^3.1.1",
"@docusaurus/types": "^3.1.1",
"@docusaurus/module-type-aliases": "^3.5.1",
"@docusaurus/tsconfig": "^3.5.1",
"@docusaurus/types": "^3.5.1",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"eslint": "^8.56.0",
Expand Down
43 changes: 43 additions & 0 deletions docs/versioned_docs/version-v0.20.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.20.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).
153 changes: 153 additions & 0 deletions docs/versioned_docs/version-v0.20.x/contract-api/02-execute-msg.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
---
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** | **Supported** |
|:------------------------------------------:|:-------------:|
| `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** | **Supported** |
|:-------------------------:|:-------------:|
| `BankQuery` ||
| `Stargate` ||
| `WasmQuery::Smart` ||
| `WasmQuery::Raw` ||
| `WasmQuery::ContractInfo` ||
| `WasmQuery::CodeInfo` ||
| `IbcQuery` ||
| `DistributionQuery` ||

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 works only if the counterparty chain is using wasmd `v0.52+`. 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.
Loading

0 comments on commit 44962d0

Please sign in to comment.