SelfFetchFunctions
Methods that allow a codec to fetch and decode accounts directly.
These methods are added to codec objects via addSelfFetchFunctions,
enabling a fluent API where you can call .fetch() directly on a codec
to retrieve and decode accounts in one step.
Examples
Fetching a single account and asserting it exists.
Fetching a single account that may not exist.
Fetching multiple accounts at once.
See
Type Parameters
| Type Parameter | Description |
|---|---|
TFrom extends object | The type that the codec encodes from. |
TTo extends TFrom | The type that the codec decodes to. |
Properties
fetch()
Fetches and decodes a single account, throwing if it does not exist.
Type Parameters
| Type Parameter |
|---|
TAddress extends string |
Parameters
| Parameter | Type |
|---|---|
address | Address<TAddress> |
config? | FetchAccountConfig |
Returns
Promise<Account<TTo, TAddress>>
fetchAll()
Fetches and decodes multiple accounts, throwing if any do not exist.
Parameters
| Parameter | Type |
|---|---|
addresses | Address[] |
config? | FetchAccountsConfig |
Returns
Promise<Account<TTo>[]>
fetchAllMaybe()
Fetches and decodes multiple accounts, returning MaybeAccount for each.
Parameters
| Parameter | Type |
|---|---|
addresses | Address[] |
config? | FetchAccountsConfig |
Returns
Promise<MaybeAccount<TTo>[]>
fetchMaybe()
Fetches and decodes a single account, returning a MaybeAccount.
Type Parameters
| Type Parameter |
|---|
TAddress extends string |
Parameters
| Parameter | Type |
|---|---|
address | Address<TAddress> |
config? | FetchAccountConfig |
Returns
Promise<MaybeAccount<TTo, TAddress>>