/** * 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, publicKey as publicKeySerializer, struct, u16, u32, } from '@metaplex-foundation/umi/serializers'; import { ResolvedAccount, ResolvedAccountsWithIndices, getAccountMetasAndSigners, } from '../shared'; // Accounts. export type SendComposeInstructionAccounts = { from: Signer; payer?: Signer; composeMessage: PublicKey | Pda; systemProgram?: PublicKey | Pda; eventAuthority: PublicKey | Pda; program: PublicKey | Pda; }; // Data. export type SendComposeInstructionData = { discriminator: Uint8Array; to: PublicKey; guid: Uint8Array; index: number; message: Uint8Array; }; export type SendComposeInstructionDataArgs = { to: PublicKey; guid: Uint8Array; index: number; message: Uint8Array; }; export function getSendComposeInstructionDataSerializer(): Serializer< SendComposeInstructionDataArgs, SendComposeInstructionData > { return mapSerializer< SendComposeInstructionDataArgs, any, SendComposeInstructionData >( struct( [ ['discriminator', bytes({ size: 8 })], ['to', publicKeySerializer()], ['guid', bytes({ size: 32 })], ['index', u16()], ['message', bytes({ size: u32() })], ], { description: 'SendComposeInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([75, 38, 228, 168, 43, 39, 238, 229]), }) ) as Serializer; } // Args. export type SendComposeInstructionArgs = SendComposeInstructionDataArgs; // Instruction. export function sendCompose( context: Pick, input: SendComposeInstructionAccounts & SendComposeInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'endpoint', '76y77prsiCMvXMjuoZ5VRrhG5qYBrUMYTE5WgHqgjEn6' ); // Accounts. const resolvedAccounts = { from: { index: 0, isWritable: false as boolean, value: input.from ?? null }, payer: { index: 1, isWritable: true as boolean, value: input.payer ?? null, }, composeMessage: { index: 2, isWritable: true as boolean, value: input.composeMessage ?? null, }, systemProgram: { index: 3, isWritable: false as boolean, value: input.systemProgram ?? 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: SendComposeInstructionArgs = { ...input }; // Default values. if (!resolvedAccounts.payer.value) { resolvedAccounts.payer.value = context.payer; } if (!resolvedAccounts.systemProgram.value) { resolvedAccounts.systemProgram.value = context.programs.getPublicKey( 'splSystem', '11111111111111111111111111111111' ); resolvedAccounts.systemProgram.isWritable = false; } // 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 = getSendComposeInstructionDataSerializer().serialize( resolvedArgs as SendComposeInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }