Kit
Functions

assertAccountsExist

assertAccountsExist<TData, TAddress>(accounts): asserts accounts is (BaseAccount & { address: Address<TAddress>; data: TData } & { exists: true })[]

Given an array of MaybeAccounts, asserts that all the accounts exist and allows them to be used as an array of Accounts going forward.

Type Parameters

Type ParameterDefault typeDescription
TData extends object | Uint8Array<ArrayBufferLike>-The nature of this account's data. It can be represented as either a Uint8Array – meaning the account is encoded – or a custom data type – meaning the account is decoded.
TAddress extends stringstringSupply a string literal to define an account having a particular address.

Parameters

ParameterType
accountsMaybeAccount<TData, TAddress>[]

Returns

asserts accounts is (BaseAccount & { address: Address<TAddress>; data: TData } & { exists: true })[]

Example

const myAccounts: MaybeEncodedAccount<Address>[];
assertAccountsExist(myAccounts);
 
// Now we can use them as an array of `EncodedAccounts`
for (const a of myAccounts) {
    a satisfies EncodedAccount<Address>;
}

On this page