/** * This code was AUTOGENERATED using the kinobi library. * Please DO NOT EDIT THIS FILE, instead use visitors * to add features, then rerun kinobi to update it. * * @see https://github.com/kinobi-so/kinobi */ import { Account, Context, Pda, PublicKey, RpcAccount, RpcGetAccountOptions, RpcGetAccountsOptions, assertAccountExists, deserializeAccount, gpaBuilder, publicKey as toPublicKey, } from '@metaplex-foundation/umi'; import { Serializer, array, bytes, mapSerializer, struct, u64, u8, } from '@metaplex-foundation/umi/serializers'; export type PendingInboundNonce = Account; export type PendingInboundNonceAccountData = { discriminator: Uint8Array; nonces: Array; bump: number; }; export type PendingInboundNonceAccountDataArgs = { nonces: Array; bump: number; }; export function getPendingInboundNonceAccountDataSerializer(): Serializer< PendingInboundNonceAccountDataArgs, PendingInboundNonceAccountData > { return mapSerializer< PendingInboundNonceAccountDataArgs, any, PendingInboundNonceAccountData >( struct( [ ['discriminator', bytes({ size: 8 })], ['nonces', array(u64())], ['bump', u8()], ], { description: 'PendingInboundNonceAccountData' } ), (value) => ({ ...value, discriminator: new Uint8Array([170, 176, 95, 240, 120, 231, 241, 218]), }) ) as Serializer< PendingInboundNonceAccountDataArgs, PendingInboundNonceAccountData >; } export function deserializePendingInboundNonce( rawAccount: RpcAccount ): PendingInboundNonce { return deserializeAccount( rawAccount, getPendingInboundNonceAccountDataSerializer() ); } export async function fetchPendingInboundNonce( context: Pick, publicKey: PublicKey | Pda, options?: RpcGetAccountOptions ): Promise { const maybeAccount = await context.rpc.getAccount( toPublicKey(publicKey, false), options ); assertAccountExists(maybeAccount, 'PendingInboundNonce'); return deserializePendingInboundNonce(maybeAccount); } export async function safeFetchPendingInboundNonce( context: Pick, publicKey: PublicKey | Pda, options?: RpcGetAccountOptions ): Promise { const maybeAccount = await context.rpc.getAccount( toPublicKey(publicKey, false), options ); return maybeAccount.exists ? deserializePendingInboundNonce(maybeAccount) : null; } export async function fetchAllPendingInboundNonce( context: Pick, publicKeys: Array, options?: RpcGetAccountsOptions ): Promise { const maybeAccounts = await context.rpc.getAccounts( publicKeys.map((key) => toPublicKey(key, false)), options ); return maybeAccounts.map((maybeAccount) => { assertAccountExists(maybeAccount, 'PendingInboundNonce'); return deserializePendingInboundNonce(maybeAccount); }); } export async function safeFetchAllPendingInboundNonce( context: Pick, publicKeys: Array, options?: RpcGetAccountsOptions ): Promise { const maybeAccounts = await context.rpc.getAccounts( publicKeys.map((key) => toPublicKey(key, false)), options ); return maybeAccounts .filter((maybeAccount) => maybeAccount.exists) .map((maybeAccount) => deserializePendingInboundNonce(maybeAccount as RpcAccount) ); } export function getPendingInboundNonceGpaBuilder( context: Pick ) { const programId = context.programs.getPublicKey( 'endpoint', '76y77prsiCMvXMjuoZ5VRrhG5qYBrUMYTE5WgHqgjEn6' ); return gpaBuilder(context, programId) .registerFields<{ discriminator: Uint8Array; nonces: Array; bump: number; }>({ discriminator: [0, bytes({ size: 8 })], nonces: [8, array(u64())], bump: [null, u8()], }) .deserializeUsing((account) => deserializePendingInboundNonce(account) ) .whereField( 'discriminator', new Uint8Array([170, 176, 95, 240, 120, 231, 241, 218]) ); }