Skip to content

Commit

Permalink
docs: API reference and formatting updates
Browse files Browse the repository at this point in the history
  • Loading branch information
rabi-siddique committed Jul 9, 2024
1 parent 230a037 commit 6abeb9c
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions main/guides/orchestration/chainhub.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ These `MapStores` are not exposed directly. They are abstracted and used interna

The core functionality is encapsulated within the `makeChainHub` function, which sets up a new `ChainHub` in the given zone. The `ChainHub` is responsible for:

## **Registering Chain Information (`registerChain`)**
## **chainHub.registerChain(name, chainInfo)**

- name: **string**
- chainInfo: **CosmosChainInfo**

Stores information about a chain inside the `chainInfos` mapstore, which can be used for quickly looking up details without querying a remote source.

Expand All @@ -41,19 +44,22 @@ const chainKey = `${chainInfo.chainId}-${(nonce += 1n)}`;
chainHub.registerChain(chainKey, chainInfo);
```

The function takes two parameters: `name`, which is a `string` representing the unique identifier of the chain, and `chainInfo`, which is an object structured according to the `CosmosChainInfo` format.
## **chainHub.getChainInfo(chainName)**

## **Retrieving Chain Information (`getChainInfo`)**
- chainName: **string**
- Returns: **Vow\<ActualChainInfo\<K\>\>**

Retrieves stored chain information from the `chainInfos` mapstore or fetches it from a remote source if not available locally.

```js
chainHub.getChainInfo('agoric-3');
```

The function takes a single parameter, `chainName`, which is a `string` template type `K`, and returns a promise (`Vow`) that resolves to `ActualChainInfo<K>`, providing detailed information about the specified chain based on its name.
## **registerConnection(chainId1, chainId2)**

## **Registering Connection Information (`registerConnection`)**
- chainId1: **string**
- chainId2: **string**
- Returns: **IBCConnectionInfo**

Stores information about a connection between two chains in `connectionInfos` mapstore, such as IBC connection details.

Expand Down Expand Up @@ -83,9 +89,11 @@ const chainConnection = {
chainHub.registerConnection('agoric-3', 'cosmoshub', chainConnection);
```

The function accepts three parameters: `chainId1` and `chainId2`, both of which are `strings` representing the identifiers of the two chains being connected, and `connectionInfo`, which is an object containing the details of the IBC connection as specified by the `IBCConnectionInfo` format
## **getConnectionInfo(chain1, chain2)**

## **Retrieving Connection Information (`getConnectionInfo`)**
- chain1: **string** | { chainId: **string** }
- chain2: **string** | { chainId: **string** }
- Returns: **Vow\<IBCConnectionInfo\<K\>\>**

Retrieves stored connection information from `connectionInfos` mapstore or fetches it from a remote source if not available locally.

Expand All @@ -95,16 +103,16 @@ const chainConnection = await E.when(
);
```

The function takes two parameters, `chain1` and `chain2`, each of which can be either a `string` representing a chain identifier or an `object` with a `chainId` property, and it returns a promise (`Vow`) that resolves with an `IBCConnectionInfo` object detailing the connection between the two chains.
## **getChainsAndConnection(chainName1, chainName2)**

## **Retrieving Combined Chain and Connection Information (`getChainsAndConnection`)**
- chainName1: **C1** extends **string**
- chainName2: **C2** extends **string**
- Returns: **Vow\<[ActualChainInfo\<C1\>, ActualChainInfo\<C2\>, IBCConnectionInfo]\>**

A composite function that fetches information about two chains and their connection simultaneously.
This method fetches information about two chains and their connection simultaneously.

```js
const [agoric3, cosmoshub, connectionInfo] = await E.when(
chainHub.getChainsAndConnection('agoric-3', 'cosmoshub'),
);
```

The function accepts two parameters, `chainName1` and `chainName2`, both of which are strings but defined as template types `C1` and `C2` respectively. It returns a promise (`Vow`) that resolves to a tuple containing the detailed information of both chains, `ActualChainInfo<C1>` and `ActualChainInfo<C2>`, along with their IBC connection information (`IBCConnectionInfo`).

0 comments on commit 6abeb9c

Please sign in to comment.