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

docs: add spec files #17

Merged
merged 17 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions spec/01-state.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# 01_state

## Overview

The `x/forwarding` module maintains state related to forwarding accounts, which are specialized accounts used to route IBC packets through predefined channels. The state contains account details, channel information, and statistics related to forwarding operations.
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved

### ForwardingAccount

The `ForwardingAccount` structure stores the data needed for forwarding. This includes routing information, account creation details, and a fallback address.

#### Structure

```Go
{
"BaseAccount": {
"address": "cosmos1...",
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
"pub_key": null,
"account_number": "0",
"sequence": "0"
},
"channel": "channel-0",
"recipient": "cosmos1...",
"created_at": "1620000000",
"fallback": "cosmos1..."
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
}
```

#### Fields

- **BaseAccount**: inherits from `cosmos.auth.v1beta1.BaseAccount`
- **channel**: specifies the IBC channel through which packets are forwarded
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
- **recipient**: the address that receives the forwarded packets
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
- **created_at**: timestamp at creation
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
- **fallback**: a fallback address to be used if forwarding to the primary recipient fails

#### State Update

The state is updated by the following messages:
- **`MsgRegisterAccount`**: updates the `ForwardingAccount` state by creating a new account
- **`MsgClearAccount`**: updates the `ForwardingAccount` state by clearing an account

### Genesis State

The genesis state of the `x/forwarding` module sets up the initial configuration, including which denominations are allowed for forwarding and the initial statistics related to registered accounts and forwarding transactions.
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved

#### Structure

```Go
{
"allowed_denoms": [
"uatom",
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
"uusdc"
],
"num_of_accounts": {
"channel-0": "1",
"channel-1": "1"
},
"num_of_forwards": {
"channel-0": "1",
"channel-1": "1"
},
"total_forwarded": {
"channel-0": "1000000uatom",
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
"channel-1": "500000uusdc"
}
}
```

#### Fields

- **allowed_denoms**: a list of denominations that are allowed to be forwarded
- **num_of_accounts**: a map linking channel IDs to the number of registered forwarding accounts
- **num_of_forwards**: a map linking channel IDs to the number of forwarding transactions
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
- **total_forwarded**: a map linking channel IDs to the total amount (of denom) forwarded through the channel
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved

### State Update

The state is updated by the following messages:
- **`MsgSetAllowedDenoms`**: updates the `allowed_denoms` field, changing which denominations are permitted for forwarding
79 changes: 79 additions & 0 deletions spec/02-messages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# 02_messages

## Overview

The `x/forwarding` module defines several messages concerning management of forwarding accounts and allowed denominations for IBC packet forwarding. These messages allow users to register and clear forwarding accounts, and update the list of denominations that can be forwarded.
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved

### MsgRegisterAccount

When `MsgRegisterAccount` is submitted, it creates a new forwarding account on the specified IBC channel. The message ensures that IBC packets are routed to the `recipient` address, with a fallback option if the primary routing fails. The `signer` is the address of the account who controls the forwarding account. The `fallback` must be a native address.
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved

#### Structure

```Go
{
"type": "noble/forwarding/MsgRegisterAccount",
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
"value": {
"signer": "cosmos1...",
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
"recipient": "cosmos1...",
"channel": "channel-0",
"fallback": "cosmos1..."
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
}
}
```

#### Fields

- **signer**: the address of the account that is registering the forwarding account
- **recipient**: the address where forwarded packets will be delivered
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
- **channel**: the IBC channel through which the forwarding occurs
- **fallback**: the fallback address to use if forwarding to the primary recipient fails


### MsgClearAccount

`MsgClearAccount` is used to clear a non-empty forwarding account, returning packets to the `fallback` address. If `fallback` is `false`, packets attempt to send at the end of the next block. The `signer` must have the necessary authority to perform this action.
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved

#### Structure

```Go
{
"type": "noble/forwarding/MsgClearAccount",
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
"value": {
"signer": "cosmos1...",
"address": "cosmos1...",
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
"fallback": true
}
}
```

#### Fields

- **signer**: the address of the account that is clearing the forwarding account
- **address**: the address of the forwarding account to be cleared
- **fallback**: a boolean indicating whether to use the fallback address for remaining packets
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved


### MsgSetAllowedDenoms

`MsgSetAllowedDenoms` is used to configure or update the list of token denominations that are allowed for IBC packet forwarding. This is important for maintaining control over which assets are eligible for forwarding, ensuring that only approved tokens are transferred.
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved

#### Structure

```Go
{
"type": "noble/forwarding/MsgSetAllowedDenoms",
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
"value": {
"signer": "cosmos1...",
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
"denoms": [
"uatom",
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
"uusdc"
]
}
}
```

#### Fields

- **signer**: the address authorized to update the list of allowed denominations
- **denoms**: a list of new denominations that are allowed for forwarding
84 changes: 84 additions & 0 deletions spec/03-events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# 03_events

## Overview

The `x/forwarding` module emits events for actions such as registration or clearing of forwarding accounts and updates to the list of allowed denominations.

### AccountRegistered

`AccountRegistered` is emitted when a new forwarding account is registered.

#### Structure

```Go
{
"type": "noble/forwarding/v1/AccountRegistered",
"attributes": {
"address": "cosmos1...",
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
"channel": "channel-0",
"recipient": "cosmos1...",
"fallback": "cosmos1..."
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
}
}
```

#### Fields

- **address**: the address of the newly registered forwarding account
- **channel**: the IBC channel used for forwarding
- **recipient**: the recipient address
- **fallback**: the fallback address to use if the primary forwarding fails

#### Emitted By

- **Transaction**: `noble.forwarding.v1.MsgRegisterAccount`

### AccountCleared

`AccountCleared` is emitted when a forwarding account is cleared.

#### Structure

```Go
{
"type": "noble/forwarding/v1/AccountCleared",
"attributes": {
"address": "cosmos1...",
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
"recipient": "cosmos1..."
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
}
}
```

#### Fields

- **address**: the address of the cleared forwarding account
- **recipient**: the recipient address if the fallback is used

#### Emitted By

- **Transaction**: `noble.forwarding.v1.MsgClearAccount`

### AllowedDenomsConfigured

`AllowedDenomsConfigured` is emitted whenever the list of allowed denominations is updated.

#### Structure

```Go
{
"type": "noble/forwarding/v1/AllowedDenomsConfigured",
"attributes": {
"previous_denoms": ["uatom", "uusdc"],
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
"current_denoms": ["uatom", "uusdc", "uiris"]
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
}
}
```

#### Fields

- **previous_denoms**: the list of denominations allowed before the update
- **current_denoms**: the newly configured list of allowed denominations

#### Emitted By

- **Transaction**: `noble.forwarding.v1.MsgSetAllowedDenoms`
152 changes: 152 additions & 0 deletions spec/04-queries.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# 04_queries

## Overview

The `x/forwarding` module provides several gRPC and REST query endpoints to retrieve information about allowed denominations, forwarding accounts, and statistics.

### QueryDenoms

`QueryDenoms` retrieves the list of denominations that are currently allowed for forwarding within the module.

#### Request

```Go
{
"type": "noble/forwarding/v1/QueryDenomsRequest",
"value": {}
}
```

#### Response

```Go
{
"type": "noble/forwarding/v1/QueryDenomsResponse",
"value": {
"allowed_denoms": [
"uatom",
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
"uusdc"
]
}
}
```

#### Fields

- **allowed_denoms**: a list of denominations that are currently allowed for forwarding

### QueryAddress

`QueryAddress` retrieves the address of a forwarding account based on the specified IBC channel, recipient, and fallback address

#### Request

```Go
{
"type": "noble/forwarding/v1/QueryAddressRequest",
"value": {
"channel": "channel-0",
"recipient": "cosmos1...",
"fallback": "cosmos1..."
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
}
}
```

#### Response

```Go
{
"type": "noble/forwarding/v1/QueryAddressResponse",
"value": {
"address": "cosmos1...",
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
"exists": true
}
}
```

#### Fields

- **channel**: the IBC channel through which packets are forwarded
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
- **recipient**: the recipient address
- **fallback**: the fallback address to use if forwarding to the primary recipient fails
- **address**: the forwarding account's address
- **exists**: a boolean indicating whether the forwarding account exists

### QueryStats

`QueryStats` retrieves statistics related to forwarding operations across all channels

#### Request

```Go
{
"type": "noble/forwarding/v1/QueryStatsRequest",
"value": {}
}
```

#### Response

```Go
{
"type": "noble/forwarding/v1/QueryStatsResponse",
"value": {
"stats": {
"channel-0": {
"num_of_accounts": "1",
"num_of_forwards": "1",
"total_forwarded": "1000000uatom"
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
},
"channel-1": {
"num_of_accounts": "1",
"num_of_forwards": "1",
"total_forwarded": "500000uusdc"
}
}
}
}
```

#### Fields

- **stats**: a map containing stats related to the forwarding, delineated by channel

### QueryStatsByChannel

`QueryStatsByChannel` retrieves statistics for a given IBC channel.

#### Request

```Go
{
"type": "noble/forwarding/v1/QueryStatsByChannelRequest",
"value": {
"channel": "channel-0"
}
}
```

#### Response

```Go
{
"type": "noble/forwarding/v1/QueryStatsByChannelResponse",
"value": {
"num_of_accounts": "10",
"num_of_forwards": "100",
"total_forwarded": [
{
"denom": "uatom",
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
"amount": "1000000"
}
]
}
}
```

#### Fields

- **channel**: the IBC channel for which statistics are being retrieved
- **num_of_accounts**: the number of registered accounts on the channel
- **num_of_forwards**: the number of forwarded packets on the channel
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
- **total_forwarded**: the total amount of assets forwarded on the channel, delineated by denomination
twothirtyfive marked this conversation as resolved.
Show resolved Hide resolved
Loading