Skip to content

Commit

Permalink
chore: simplify registerChain
Browse files Browse the repository at this point in the history
  • Loading branch information
amessbee committed Sep 25, 2024
1 parent 62424aa commit d0ba308
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions main/guides/orchestration/getting-started/key-concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ set of high-level methods to manage and interact with local and remote chains. B
- `getChain` retrieves a chain object for the given `chainName` to get access to chain-specific methods. See [getChain](https://agoric-sdk.pages.dev/interfaces/_agoric_orchestration.Orchestrator#getChain).

```javascript
const chain = await orchestrator.getChain('chainName')
const chain = await orchestrator.getChain('chainName');
```

### Brand Utility Functions
Expand All @@ -22,13 +22,13 @@ const chain = await orchestrator.getChain('chainName')
held, and the chain that issues the corresponding asset. See [getBrandInfo](https://agoric-sdk.pages.dev/interfaces/_agoric_orchestration.Orchestrator#getBrandInfo).

```javascript
const brandInfo = orchestrator.getBrandInfo('denom')
const brandInfo = orchestrator.getBrandInfo('denom');
```

- `asAmount` converts a denom amount to an `Amount` with a brand. See [asAmount](https://agoric-sdk.pages.dev/interfaces/_agoric_orchestration.Orchestrator#asAmount).

```javascript
const amount = orchestrator.asAmount({ denom: 'uatom', value: 1000n })
const amount = orchestrator.asAmount({ denom: 'uatom', value: 1000n });
```

## Orchestration Account
Expand All @@ -45,20 +45,20 @@ interactions, providing a unified and simplified interface for developers.
```javascript
const [agoric, remoteChain] = await Promise.all([
orch.getChain('agoric'),
orch.getChain(chainName)
])
orch.getChain(chainName),
]);
const [localAccount, remoteAccount] = await Promise.all([
agoric.makeAccount(),
remoteChain.makeAccount()
])
remoteChain.makeAccount(),
]);
```

### Address Management

- `getAddress` retrieves the address of the account on the remote chain.

```javascript
const address = await orchestrationAccount.getAddress()
const address = await orchestrationAccount.getAddress();
```

### Balance Management
Expand All @@ -67,8 +67,8 @@ const address = await orchestrationAccount.getAddress()
- `getBalance` retrieves the balance of a specific denom for the account.

```javascript
const balances = await orchestrationAccount.getBalances()
const balance = await orchestrationAccount.getBalance('uatom')
const balances = await orchestrationAccount.getBalances();
const balance = await orchestrationAccount.getBalance('uatom');
```

### Funds Transfer
Expand All @@ -80,10 +80,10 @@ const balance = await orchestrationAccount.getBalance('uatom')
funds there.

```javascript
await orchestrationAccount.send(receiverAddress, amount)
await orchestrationAccount.transfer(amount, destinationAddress)
await orchestrationAccount.transferSteps(amount, transferMsg)
await orchestrationAccount.deposit(payment)
await orchestrationAccount.send(receiverAddress, amount);
await orchestrationAccount.transfer(amount, destinationAddress);
await orchestrationAccount.transferSteps(amount, transferMsg);
await orchestrationAccount.deposit(payment);
```

## ChainHub
Expand All @@ -98,9 +98,7 @@ and use of chain and connection information using the following APIs:

### Registration APIs

- `registerChain` register a new chain with `chainHub`. The name will override a name in well-known chain names. If a
durable zone was not provided, registration will not survive a reincarnation of the vat, and will have to be
registered again.
- `registerChain` register a new chain with `chainHub`. The name will override a name in well-known chain names.
- `registerConnection` registers a connections between two given chain IDs.
- `registerAsset` registers an asset that may be held on a chain other than the issuing chain. Both corresponding chains
should already be registered before this call.
Expand All @@ -117,15 +115,15 @@ In the below example, `chainHub` is used to register a new chain and establish a
the newly registered chain.

```javascript
const chainHub = makeChainHub(privateArgs.agoricNames, vowTools)
const chainHub = makeChainHub(privateArgs.agoricNames, vowTools);

// Register a new chain with its information
chainHub.registerChain(chainKey, chainInfo)
chainHub.registerChain(chainKey, chainInfo);

// Register a connection between the Agoric chain and the new chain
chainHub.registerConnection(
agoricChainInfo.chainId,
chainInfo.chainId,
connectionInfo
)
connectionInfo,
);
```

0 comments on commit d0ba308

Please sign in to comment.