• Given a MaybeAccount, asserts that the account exists and allows it to be used as an Account type going forward.

    Type Parameters

    • 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 string = string

      Supply a string literal to define an account having a particular address.

    Parameters

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

    const myAccount: MaybeEncodedAccount<'1234..5678'>;
    assertAccountExists(myAccount);

    // Now we can use myAccount as an `EncodedAccount`
    myAccount satisfies EncodedAccount<'1234..5678'>;