/** * 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 ClearComposeInstructionAccounts = { to: Signer; composeMessage: PublicKey | Pda; eventAuthority: PublicKey | Pda; program: PublicKey | Pda; }; // Data. export type ClearComposeInstructionData = { discriminator: Uint8Array; from: PublicKey; guid: Uint8Array; index: number; message: Uint8Array; }; export type ClearComposeInstructionDataArgs = { from: PublicKey; guid: Uint8Array; index: number; message: Uint8Array; }; export function getClearComposeInstructionDataSerializer(): Serializer< ClearComposeInstructionDataArgs, ClearComposeInstructionData > { return mapSerializer< ClearComposeInstructionDataArgs, any, ClearComposeInstructionData >( struct( [ ['discriminator', bytes({ size: 8 })], ['from', publicKeySerializer()], ['guid', bytes({ size: 32 })], ['index', u16()], ['message', bytes({ size: u32() })], ], { description: 'ClearComposeInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([118, 1, 18, 142, 95, 175, 21, 125]), }) ) as Serializer; } // Args. export type ClearComposeInstructionArgs = ClearComposeInstructionDataArgs; // Instruction. export function clearCompose( context: Pick, input: ClearComposeInstructionAccounts & ClearComposeInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'endpoint', '76y77prsiCMvXMjuoZ5VRrhG5qYBrUMYTE5WgHqgjEn6' ); // Accounts. const resolvedAccounts = { to: { index: 0, isWritable: false as boolean, value: input.to ?? null }, composeMessage: { index: 1, isWritable: true as boolean, value: input.composeMessage ?? null, }, eventAuthority: { index: 2, isWritable: false as boolean, value: input.eventAuthority ?? null, }, program: { index: 3, isWritable: false as boolean, value: input.program ?? null, }, } satisfies ResolvedAccountsWithIndices; // Arguments. const resolvedArgs: ClearComposeInstructionArgs = { ...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 = getClearComposeInstructionDataSerializer().serialize( resolvedArgs as ClearComposeInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }