/** * 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 InitVerifyInstructionAccounts = { payer?: Signer; nonce: PublicKey | Pda; payloadHash: PublicKey | Pda; systemProgram?: PublicKey | Pda; }; // Data. export type InitVerifyInstructionData = { discriminator: Uint8Array; srcEid: number; sender: Uint8Array; receiver: PublicKey; nonce: bigint; }; export type InitVerifyInstructionDataArgs = { srcEid: number; sender: Uint8Array; receiver: PublicKey; nonce: number | bigint; }; export function getInitVerifyInstructionDataSerializer(): Serializer< InitVerifyInstructionDataArgs, InitVerifyInstructionData > { return mapSerializer< InitVerifyInstructionDataArgs, any, InitVerifyInstructionData >( struct( [ ['discriminator', bytes({ size: 8 })], ['srcEid', u32()], ['sender', bytes({ size: 32 })], ['receiver', publicKeySerializer()], ['nonce', u64()], ], { description: 'InitVerifyInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([76, 246, 244, 124, 115, 17, 235, 91]), }) ) as Serializer; } // Args. export type InitVerifyInstructionArgs = InitVerifyInstructionDataArgs; // Instruction. export function initVerify( context: Pick, accounts: InitVerifyInstructionAccounts, args: InitVerifyInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'endpoint', '76y77prsiCMvXMjuoZ5VRrhG5qYBrUMYTE5WgHqgjEn6' ); // Accounts. const resolvedAccounts = { payer: { index: 0, isWritable: true as boolean, value: accounts.payer ?? null, }, nonce: { index: 1, isWritable: false as boolean, value: accounts.nonce ?? null, }, payloadHash: { index: 2, isWritable: true as boolean, value: accounts.payloadHash ?? null, }, systemProgram: { index: 3, isWritable: false as boolean, value: accounts.systemProgram ?? null, }, } satisfies ResolvedAccountsWithIndices; // Arguments. const resolvedArgs: InitVerifyInstructionArgs = { ...args }; // Default values. if (!resolvedAccounts.payer.value) { resolvedAccounts.payer.value = context.payer; } if (!resolvedAccounts.systemProgram.value) { resolvedAccounts.systemProgram.value = context.programs.getPublicKey( 'splSystem', '11111111111111111111111111111111' ); resolvedAccounts.systemProgram.isWritable = false; } // 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 = getInitVerifyInstructionDataSerializer().serialize( resolvedArgs as InitVerifyInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }