/** * 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, u64, } from '@metaplex-foundation/umi/serializers'; import { ResolvedAccount, ResolvedAccountsWithIndices, getAccountMetasAndSigners, } from '../shared'; import { LzComposeParams, LzComposeParamsArgs, getLzComposeParamsSerializer, } from '../types'; // Accounts. export type ComposeInstructionAccounts = { executor: Signer; config: PublicKey | Pda; endpointProgram: PublicKey | Pda; /** The authority for the endpoint program to emit events */ endpointEventAuthority: PublicKey | Pda; eventAuthority: PublicKey | Pda; program: PublicKey | Pda; }; // Data. export type ComposeInstructionData = { discriminator: Uint8Array; lzCompose: LzComposeParams; computeUnits: bigint; value: bigint; }; export type ComposeInstructionDataArgs = { lzCompose: LzComposeParamsArgs; computeUnits: number | bigint; value: number | bigint; }; export function getComposeInstructionDataSerializer(): Serializer< ComposeInstructionDataArgs, ComposeInstructionData > { return mapSerializer( struct( [ ['discriminator', bytes({ size: 8 })], ['lzCompose', getLzComposeParamsSerializer()], ['computeUnits', u64()], ['value', u64()], ], { description: 'ComposeInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([106, 64, 131, 142, 7, 159, 42, 15]), }) ) as Serializer; } // Args. export type ComposeInstructionArgs = ComposeInstructionDataArgs; // Instruction. export function compose( context: Pick, input: ComposeInstructionAccounts & ComposeInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'executor', '6doghB248px58JSSwG4qejQ46kFMW4AMj7vzJnWZHNZn' ); // Accounts. const resolvedAccounts = { executor: { index: 0, isWritable: true as boolean, value: input.executor ?? null, }, config: { index: 1, isWritable: false as boolean, value: input.config ?? null, }, endpointProgram: { index: 2, isWritable: false as boolean, value: input.endpointProgram ?? null, }, endpointEventAuthority: { index: 3, isWritable: false as boolean, value: input.endpointEventAuthority ?? null, }, eventAuthority: { index: 4, isWritable: false as boolean, value: input.eventAuthority ?? null, }, program: { index: 5, isWritable: false as boolean, value: input.program ?? null, }, } satisfies ResolvedAccountsWithIndices; // Arguments. const resolvedArgs: ComposeInstructionArgs = { ...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 = getComposeInstructionDataSerializer().serialize( resolvedArgs as ComposeInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }