/** * 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 { Context, Pda, PublicKey, Signer, TransactionBuilder, transactionBuilder, } from '@metaplex-foundation/umi'; import { Serializer, bytes, mapSerializer, publicKey as publicKeySerializer, struct, u32, u64, } from '@metaplex-foundation/umi/serializers'; import { ResolvedAccount, ResolvedAccountsWithIndices, getAccountMetasAndSigners, } from '../shared'; // Accounts. export type ClearInstructionAccounts = { /** The PDA of the OApp or delegate */ signer: Signer; oappRegistry: PublicKey | Pda; nonce: PublicKey | Pda; /** close the account and return the lamports to endpoint settings account */ payloadHash: PublicKey | Pda; endpoint: PublicKey | Pda; eventAuthority: PublicKey | Pda; program: PublicKey | Pda; }; // Data. export type ClearInstructionData = { discriminator: Uint8Array; receiver: PublicKey; srcEid: number; sender: Uint8Array; nonce: bigint; guid: Uint8Array; message: Uint8Array; }; export type ClearInstructionDataArgs = { receiver: PublicKey; srcEid: number; sender: Uint8Array; nonce: number | bigint; guid: Uint8Array; message: Uint8Array; }; export function getClearInstructionDataSerializer(): Serializer< ClearInstructionDataArgs, ClearInstructionData > { return mapSerializer( struct( [ ['discriminator', bytes({ size: 8 })], ['receiver', publicKeySerializer()], ['srcEid', u32()], ['sender', bytes({ size: 32 })], ['nonce', u64()], ['guid', bytes({ size: 32 })], ['message', bytes({ size: u32() })], ], { description: 'ClearInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([250, 39, 28, 213, 123, 163, 133, 5]), }) ) as Serializer; } // Args. export type ClearInstructionArgs = ClearInstructionDataArgs; // Instruction. export function clear( context: Pick, accounts: ClearInstructionAccounts, args: ClearInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'endpoint', '76y77prsiCMvXMjuoZ5VRrhG5qYBrUMYTE5WgHqgjEn6' ); // Accounts. const resolvedAccounts = { signer: { index: 0, isWritable: false as boolean, value: accounts.signer ?? null, }, oappRegistry: { index: 1, isWritable: false as boolean, value: accounts.oappRegistry ?? null, }, nonce: { index: 2, isWritable: false as boolean, value: accounts.nonce ?? null, }, payloadHash: { index: 3, isWritable: true as boolean, value: accounts.payloadHash ?? null, }, endpoint: { index: 4, isWritable: true as boolean, value: accounts.endpoint ?? null, }, eventAuthority: { index: 5, isWritable: false as boolean, value: accounts.eventAuthority ?? null, }, program: { index: 6, isWritable: false as boolean, value: accounts.program ?? null, }, } satisfies ResolvedAccountsWithIndices; // Arguments. const resolvedArgs: ClearInstructionArgs = { ...args }; // Accounts in order. const orderedAccounts: ResolvedAccount[] = Object.values( resolvedAccounts ).sort((a, b) => a.index - b.index); // Keys and Signers. const [keys, signers] = getAccountMetasAndSigners( orderedAccounts, 'programId', programId ); // Data. const data = getClearInstructionDataSerializer().serialize( resolvedArgs as ClearInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }