/** * 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, struct, u32, } from '@metaplex-foundation/umi/serializers'; import { ResolvedAccount, ResolvedAccountsWithIndices, getAccountMetasAndSigners, } from '../shared'; // Accounts. export type ValidatePacketInstructionAccounts = { payer?: Signer; receiveLibrary: PublicKey | Pda; }; // Data. export type ValidatePacketInstructionData = { discriminator: Uint8Array; packet: Uint8Array; }; export type ValidatePacketInstructionDataArgs = { packet: Uint8Array }; export function getValidatePacketInstructionDataSerializer(): Serializer< ValidatePacketInstructionDataArgs, ValidatePacketInstructionData > { return mapSerializer< ValidatePacketInstructionDataArgs, any, ValidatePacketInstructionData >( struct( [ ['discriminator', bytes({ size: 8 })], ['packet', bytes({ size: u32() })], ], { description: 'ValidatePacketInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([34, 146, 107, 76, 157, 98, 105, 211]), }) ) as Serializer< ValidatePacketInstructionDataArgs, ValidatePacketInstructionData >; } // Args. export type ValidatePacketInstructionArgs = ValidatePacketInstructionDataArgs; // Instruction. export function validatePacket( context: Pick, input: ValidatePacketInstructionAccounts & ValidatePacketInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'simpleMessagelib', '6GsmxMTHAAiFKfemuM4zBjumTjNSX5CAiw4xSSXM2Toy' ); // Accounts. const resolvedAccounts = { payer: { index: 0, isWritable: false as boolean, value: input.payer ?? null, }, receiveLibrary: { index: 1, isWritable: false as boolean, value: input.receiveLibrary ?? null, }, } satisfies ResolvedAccountsWithIndices; // Arguments. const resolvedArgs: ValidatePacketInstructionArgs = { ...input }; // Default values. if (!resolvedAccounts.payer.value) { resolvedAccounts.payer.value = context.payer; } // 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 = getValidatePacketInstructionDataSerializer().serialize( resolvedArgs as ValidatePacketInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }