/** * 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, TransactionBuilder, transactionBuilder, } from '@metaplex-foundation/umi'; import { Serializer, array, bytes, mapSerializer, publicKey as publicKeySerializer, struct, u32, u64, } from '@metaplex-foundation/umi/serializers'; import { ResolvedAccount, ResolvedAccountsWithIndices, getAccountMetasAndSigners, } from '../shared'; import { LzOption, LzOptionArgs, getLzOptionSerializer } from '../types'; // Accounts. export type QuoteExecutorInstructionAccounts = { executorConfig: PublicKey | Pda; priceFeedProgram: PublicKey | Pda; priceFeedConfig: PublicKey | Pda; }; // Data. export type QuoteExecutorInstructionData = { discriminator: Uint8Array; msglib: PublicKey; dstEid: number; sender: PublicKey; calldataSize: bigint; options: Array; }; export type QuoteExecutorInstructionDataArgs = { msglib: PublicKey; dstEid: number; sender: PublicKey; calldataSize: number | bigint; options: Array; }; export function getQuoteExecutorInstructionDataSerializer(): Serializer< QuoteExecutorInstructionDataArgs, QuoteExecutorInstructionData > { return mapSerializer< QuoteExecutorInstructionDataArgs, any, QuoteExecutorInstructionData >( struct( [ ['discriminator', bytes({ size: 8 })], ['msglib', publicKeySerializer()], ['dstEid', u32()], ['sender', publicKeySerializer()], ['calldataSize', u64()], ['options', array(getLzOptionSerializer())], ], { description: 'QuoteExecutorInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([84, 246, 255, 191, 82, 65, 164, 92]), }) ) as Serializer< QuoteExecutorInstructionDataArgs, QuoteExecutorInstructionData >; } // Args. export type QuoteExecutorInstructionArgs = QuoteExecutorInstructionDataArgs; // Instruction. export function quoteExecutor( context: Pick, input: QuoteExecutorInstructionAccounts & QuoteExecutorInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'executor', '6doghB248px58JSSwG4qejQ46kFMW4AMj7vzJnWZHNZn' ); // Accounts. const resolvedAccounts = { executorConfig: { index: 0, isWritable: false as boolean, value: input.executorConfig ?? null, }, priceFeedProgram: { index: 1, isWritable: false as boolean, value: input.priceFeedProgram ?? null, }, priceFeedConfig: { index: 2, isWritable: false as boolean, value: input.priceFeedConfig ?? null, }, } satisfies ResolvedAccountsWithIndices; // Arguments. const resolvedArgs: QuoteExecutorInstructionArgs = { ...input }; // 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 = getQuoteExecutorInstructionDataSerializer().serialize( resolvedArgs as QuoteExecutorInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }