Skip to content

Commit d8056fe

Browse files
committed
docs: API reference and formatting updates
1 parent 230a037 commit d8056fe

File tree

1 file changed

+29
-21
lines changed

1 file changed

+29
-21
lines changed

main/guides/orchestration/chainhub.md

+29-21
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
11
# ChainHub
22

3-
The [ChainHub API](https://github.com/Agoric/agoric-sdk/blob/859d8c0d151ff6f686583db1eaf72efb89cc7648/packages/orchestration/src/exos/chain-hub.js#L99) is responsible managing chain and IBC connection information. It facilitates the registration and retrieval of chain and connection data.
3+
The [ChainHub API](https://github.com/Agoric/agoric-sdk/blob/859d8c0d151ff6f686583db1eaf72efb89cc7648/packages/orchestration/src/exos/chain-hub.js#L99) is responsible for managing chain and IBC connection information. It facilitates the registration and retrieval of chain and connection information.
44

55
```js
66
const zone = makeDurableZone(baggage);
77
const { agoricNames } = remotePowers;
88
const chainHub = makeChainHub(agoricNames, zone);
99
```
1010

11-
The `makeChainHub` function accepts a `Remote<NameHub>` reference (`agoricNames`) and an optional `Zone` for managing data durability. The `makeChainHub` fuction creates a new `ChainHub` instance either in the specified zone or in the heap if no zone is provided. The resulting object is an Exo singleton, which means it has no previous state. Its state consists only of a cache of queries to `agoricNames` and the information provided in registration calls.
11+
The `makeChainHub` function accepts a `Remote<NameHub>` reference (`agoricNames`) and an optional `Zone` to manage data durability. The `makeChainHub` function creates a new `ChainHub` instance either in the specified zone or in the heap if no zone is provided. The resulting object is an Exo singleton, meaning it has no previous state. Its state consists solely of a cache of queries to `agoricNames` and the information provided during registration calls.
1212

13-
The `ChainHub` objects maintains two `MapStores`:
13+
The `ChainHub` object maintains two `MapStores`:
1414

1515
- `chainInfos`: For storing `CosmosChainInfo` objects.
1616
- `connectionInfos`: For storing `IBCConnectionInfo` objects.
1717

1818
These `MapStores` are not exposed directly. They are abstracted and used internally by the methods provided by the ChainHub.
1919

20-
# ChainHub Interface
20+
# ChainHub APIs
2121

22-
The core functionality is encapsulated within the `makeChainHub` function, which sets up a new `ChainHub` in the given zone. The `ChainHub` is responsible for:
22+
The core functionality is encapsulated within the `makeChainHub` function, which sets up a new `ChainHub` in the specified zone. The `ChainHub` provides the following APIs:
2323

24-
## **Registering Chain Information (`registerChain`)**
24+
## **chainHub.registerChain(name, chainInfo)**
2525

26-
Stores information about a chain inside the `chainInfos` mapstore, which can be used for quickly looking up details without querying a remote source.
26+
- name: **string**
27+
- chainInfo: **CosmosChainInfo**
28+
29+
Stores information about a chain in the `chainInfos` MapStore, enabling quick lookup of details without querying a remote source.
2730

2831
```js
2932
const chainInfo = harden({
@@ -41,21 +44,24 @@ const chainKey = `${chainInfo.chainId}-${(nonce += 1n)}`;
4144
chainHub.registerChain(chainKey, chainInfo);
4245
```
4346

44-
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.
47+
## **chainHub.getChainInfo(chainName)**
4548

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

48-
Retrieves stored chain information from the `chainInfos` mapstore or fetches it from a remote source if not available locally.
52+
Retrieves stored chain information from the `chainInfos` MapStore or fetches it from a remote source if not available locally.
4953

5054
```js
5155
chainHub.getChainInfo('agoric-3');
5256
```
5357

54-
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.
58+
## **chainHub.registerConnection(chainId1, chainId2)**
5559

56-
## **Registering Connection Information (`registerConnection`)**
60+
- chainId1: **string**
61+
- chainId2: **string**
62+
- Returns: **IBCConnectionInfo**
5763

58-
Stores information about a connection between two chains in `connectionInfos` mapstore, such as IBC connection details.
64+
Stores information about a connection between two chains in `connectionInfos` Mapstore, such as IBC connection details.
5965

6066
```js
6167
const chainConnection = {
@@ -83,28 +89,30 @@ const chainConnection = {
8389
chainHub.registerConnection('agoric-3', 'cosmoshub', chainConnection);
8490
```
8591

86-
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
92+
## **chainHub.getConnectionInfo(chain1, chain2)**
8793

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

90-
Retrieves stored connection information from `connectionInfos` mapstore or fetches it from a remote source if not available locally.
98+
Retrieves stored connection information from `connectionInfos` Mapstore or fetches it from a remote source if not available locally.
9199

92100
```js
93101
const chainConnection = await E.when(
94102
chainHub.getConnectionInfo('agoric-3', 'cosmoshub'),
95103
);
96104
```
97105

98-
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.
106+
## **chainHub.getChainsAndConnection(chainName1, chainName2)**
99107

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

102-
A composite function that fetches information about two chains and their connection simultaneously.
112+
This method fetches information about two chains and their connection simultaneously.
103113

104114
```js
105115
const [agoric3, cosmoshub, connectionInfo] = await E.when(
106116
chainHub.getChainsAndConnection('agoric-3', 'cosmoshub'),
107117
);
108118
```
109-
110-
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 commit comments

Comments
 (0)