/** * 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, u64, } from '@metaplex-foundation/umi/serializers'; import { ResolvedAccount, ResolvedAccountsWithIndices, getAccountMetasAndSigners, } from '../shared'; // Accounts. export type SendInstructionAccounts = { sender: Signer; 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; eventAuthority: PublicKey | Pda; program: PublicKey | Pda; }; // Data. export type SendInstructionData = { discriminator: Uint8Array; dstEid: number; receiver: Uint8Array; message: Uint8Array; options: Uint8Array; nativeFee: bigint; lzTokenFee: bigint; }; export type SendInstructionDataArgs = { dstEid: number; receiver: Uint8Array; message: Uint8Array; options: Uint8Array; nativeFee: number | bigint; lzTokenFee: number | bigint; }; export function getSendInstructionDataSerializer(): Serializer< SendInstructionDataArgs, SendInstructionData > { return mapSerializer( struct( [ ['discriminator', bytes({ size: 8 })], ['dstEid', u32()], ['receiver', bytes({ size: 32 })], ['message', bytes({ size: u32() })], ['options', bytes({ size: u32() })], ['nativeFee', u64()], ['lzTokenFee', u64()], ], { description: 'SendInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([102, 251, 20, 187, 65, 75, 12, 69]), }) ) as Serializer; } // Args. export type SendInstructionArgs = SendInstructionDataArgs; // Instruction. export function send( context: Pick, input: SendInstructionAccounts & SendInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'endpoint', '76y77prsiCMvXMjuoZ5VRrhG5qYBrUMYTE5WgHqgjEn6' ); // Accounts. const resolvedAccounts = { sender: { index: 0, isWritable: false as boolean, value: input.sender ?? null, }, sendLibraryProgram: { index: 1, isWritable: false as boolean, value: input.sendLibraryProgram ?? null, }, sendLibraryConfig: { index: 2, isWritable: false as boolean, value: input.sendLibraryConfig ?? null, }, defaultSendLibraryConfig: { index: 3, isWritable: false as boolean, value: input.defaultSendLibraryConfig ?? null, }, sendLibraryInfo: { index: 4, isWritable: false as boolean, value: input.sendLibraryInfo ?? null, }, endpoint: { index: 5, isWritable: false as boolean, value: input.endpoint ?? null, }, nonce: { index: 6, isWritable: true as boolean, value: input.nonce ?? null, }, eventAuthority: { index: 7, isWritable: false as boolean, value: input.eventAuthority ?? null, }, program: { index: 8, isWritable: false as boolean, value: input.program ?? null, }, } satisfies ResolvedAccountsWithIndices; // Arguments. const resolvedArgs: SendInstructionArgs = { ...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 = getSendInstructionDataSerializer().serialize( resolvedArgs as SendInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }