/** * 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, bool, bytes, mapSerializer, publicKey as publicKeySerializer, struct, u32, } from '@metaplex-foundation/umi/serializers'; import { ResolvedAccount, ResolvedAccountsWithIndices, getAccountMetasAndSigners, } from '../shared'; // Accounts. export type QuoteInstructionAccounts = { sendLibraryProgram: PublicKey | Pda; sendLibraryConfig: PublicKey | Pda; defaultSendLibraryConfig: PublicKey | Pda; /** The PDA signer to the send library when the endpoint calls the send library. */ sendLibraryInfo: PublicKey | Pda; endpoint: PublicKey | Pda; nonce: PublicKey | Pda; }; // Data. export type QuoteInstructionData = { discriminator: Uint8Array; sender: PublicKey; dstEid: number; receiver: Uint8Array; message: Uint8Array; options: Uint8Array; payInLzToken: boolean; }; export type QuoteInstructionDataArgs = { sender: PublicKey; dstEid: number; receiver: Uint8Array; message: Uint8Array; options: Uint8Array; payInLzToken: boolean; }; export function getQuoteInstructionDataSerializer(): Serializer< QuoteInstructionDataArgs, QuoteInstructionData > { return mapSerializer( struct( [ ['discriminator', bytes({ size: 8 })], ['sender', publicKeySerializer()], ['dstEid', u32()], ['receiver', bytes({ size: 32 })], ['message', bytes({ size: u32() })], ['options', bytes({ size: u32() })], ['payInLzToken', bool()], ], { description: 'QuoteInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([149, 42, 109, 247, 134, 146, 213, 123]), }) ) as Serializer; } // Args. export type QuoteInstructionArgs = QuoteInstructionDataArgs; // Instruction. export function quote( context: Pick, input: QuoteInstructionAccounts & QuoteInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'endpoint', '76y77prsiCMvXMjuoZ5VRrhG5qYBrUMYTE5WgHqgjEn6' ); // Accounts. const resolvedAccounts = { sendLibraryProgram: { index: 0, isWritable: false as boolean, value: input.sendLibraryProgram ?? null, }, sendLibraryConfig: { index: 1, isWritable: false as boolean, value: input.sendLibraryConfig ?? null, }, defaultSendLibraryConfig: { index: 2, isWritable: false as boolean, value: input.defaultSendLibraryConfig ?? null, }, sendLibraryInfo: { index: 3, isWritable: false as boolean, value: input.sendLibraryInfo ?? null, }, endpoint: { index: 4, isWritable: false as boolean, value: input.endpoint ?? null, }, nonce: { index: 5, isWritable: false as boolean, value: input.nonce ?? null, }, } satisfies ResolvedAccountsWithIndices; // Arguments. const resolvedArgs: QuoteInstructionArgs = { ...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 = getQuoteInstructionDataSerializer().serialize( resolvedArgs as QuoteInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }