Kit
Functions

assertAccountExists

assertAccountExists<TData, TAddress>(account): asserts account is BaseAccount & { address: Address<TAddress>; data: TData } & { exists: true }

Given a MaybeAccount, asserts that the account exists and allows it to be used as an Account type 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
accountMaybeAccount<TData, TAddress>

Returns

asserts account is BaseAccount & { address: Address<TAddress>; data: TData } & { exists: true }

Example

const myAccount: MaybeEncodedAccount<'1234..5678'>;
assertAccountExists(myAccount);
 
// Now we can use myAccount as an `EncodedAccount`
myAccount satisfies EncodedAccount<'1234..5678'>;

On this page