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

Improvements in Orch API docs #1153

Merged
merged 4 commits into from
Jul 11, 2024
Merged
Changes from all commits
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
44 changes: 29 additions & 15 deletions main/guides/orchestration/getting-started/api.md
Original file line number Diff line number Diff line change
@@ -1,86 +1,100 @@
# Orchestration API

The Agoric Orchestration API enables developers to seamlessly manage and interact with accounts across multiple blockchain networks, simplifying the complexities of cross-chain operations.
The Agoric [Orchestration](/glossary/#orchestration) API enables developers to seamlessly manage and interact with accounts across multiple blockchain networks, simplifying the complexities of cross-chain operations.

See [Orchestration API Spec](https://agoric-sdk.pages.dev/modules/_agoric_orchestration)

## Orchestrator Interface

The `Orchestrator` interface provides a set of high-level methods to manage and interact with interchain accounts. Below are the primary methods:
The [`Orchestrator`](https://agoric-sdk.pages.dev/interfaces/_agoric_orchestration.Orchestrator) interface provides a set of high-level methods to manage and interact with interchain accounts. Below are the primary methods:

### `getChain`
Retrieves the chain information and provides access to chain-specific methods.
### getChain

Retrieves the chain information and provides access to chain-specific methods. See [getChain](https://agoric-sdk.pages.dev/interfaces/_agoric_orchestration.Orchestrator#getChain).

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

### makeLocalAccount
Creates a new LocalChainAccount.
Creates a new `LocalChainAccount`. See [makeLocalAccount](https://agoric-sdk.pages.dev/interfaces/_agoric_orchestration.Orchestrator#makeLocalAccount).

```javascript
const localAccount = await orchestrator.makeLocalAccount();
```

### getBrandInfo
Returns information about a `denom`, including the equivalent local Brand, the chain where the denom is held, and the chain that issues the corresponding asset.

Returns information about a `denom`, including the equivalent local Brand, the chain where the denom is 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');
```

### asAmount
Converts a denom amount to an `Amount` with a brand.

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 });
```

## OrchestrationAccount Interface
Orchestration accounts provide high-level operations for managing accounts on remote chains. Below are the primary methods available:
## OrchestrationAccount

An [`OrchestrationAccount`](https://agoric-sdk.pages.dev/types/_agoric_orchestration.OrchestrationAccount) is a type alias that combines the [`OrchestrationAccountI`](https://agoric-sdk.pages.dev/interfaces/_agoric_orchestration.OrchestrationAccountI) interface with additional methods. Below are the primary methods available:

### getAddress
Retrieves the address of the account on the remote chain.

Retrieves the address of the account on the remote chain. See [getAddress](https://agoric-sdk.pages.dev/interfaces/_agoric_orchestration.OrchestrationAccountI#getAddress).

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

### getBalances
Returns an array of amounts for every balance in the account.

Returns an array of amounts for every balance in the account. See [getBalances](https://agoric-sdk.pages.dev/interfaces/_agoric_orchestration.OrchestrationAccountI#getBalances).

```javascript
const balances = await orchestrationAccount.getBalances();
```

### getBalance
Retrieves the balance of a specific denom for the account.

Retrieves the balance of a specific denom for the account. See [getBalance](https://agoric-sdk.pages.dev/interfaces/_agoric_orchestration.OrchestrationAccountI#getBalance).

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

### send
Transfers an amount to another account on the same chain. The promise settles when the transfer is complete.

Transfers an amount to another account on the same chain. The promise settles when the transfer is complete. See [send](https://agoric-sdk.pages.dev/interfaces/_agoric_orchestration.OrchestrationAccountI#send).

```javascript
await orchestrationAccount.send(receiverAddress, amount);
```

### transfer
Transfers an amount to another account, typically on another chain. The promise settles when the transfer is complete.

Transfers an amount to another account, typically on another chain. The promise settles when the transfer is complete. See [transfer](https://agoric-sdk.pages.dev/interfaces/_agoric_orchestration.OrchestrationAccountI#transfer).

```javascript
await orchestrationAccount.transfer(amount, destinationAddress);
```

### transferSteps
Transfers an amount to another account in multiple steps. The promise settles when the entire path of the transfer is complete.

Transfers an amount to another account in multiple steps. The promise settles when the entire path of the transfer is complete. See [transferSteps](https://agoric-sdk.pages.dev/interfaces/_agoric_orchestration.OrchestrationAccountI#transferSteps).

```javascript
await orchestrationAccount.transferSteps(amount, transferMsg);
```

### deposit

Deposits payment from Zoe to the account. For remote accounts, an IBC Transfer will be executed to transfer funds there.

```javascript
await orchestrationAccount.deposit(payment);
```
Loading