/** * 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, array, bytes, mapSerializer, struct, u8, } from '@metaplex-foundation/umi/serializers'; import { ResolvedAccount, ResolvedAccountsWithIndices, getAccountMetasAndSigners, } from '../shared'; import { ExecuteTransactionDigest, ExecuteTransactionDigestArgs, getExecuteTransactionDigestSerializer, } from '../types'; // Accounts. export type InvokeInstructionAccounts = { signer: Signer; config: PublicKey | Pda; executeHash: PublicKey | Pda; systemProgram?: PublicKey | Pda; eventAuthority: PublicKey | Pda; program: PublicKey | Pda; }; // Data. export type InvokeInstructionData = { discriminator: Uint8Array; digest: ExecuteTransactionDigest; signatures: Array>; }; export type InvokeInstructionDataArgs = { digest: ExecuteTransactionDigestArgs; signatures: Array>; }; export function getInvokeInstructionDataSerializer(): Serializer< InvokeInstructionDataArgs, InvokeInstructionData > { return mapSerializer( struct( [ ['discriminator', bytes({ size: 8 })], ['digest', getExecuteTransactionDigestSerializer()], ['signatures', array(array(u8(), { size: 65 }))], ], { description: 'InvokeInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([26, 16, 169, 7, 21, 202, 242, 25]), }) ) as Serializer; } // Args. export type InvokeInstructionArgs = InvokeInstructionDataArgs; // Instruction. export function invoke( context: Pick, input: InvokeInstructionAccounts & InvokeInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'dvn', 'HtEYV4xB4wvsj5fgTkcfuChYpvGYzgzwvNhgDZQNh7wW' ); // Accounts. const resolvedAccounts = { signer: { index: 0, isWritable: true as boolean, value: input.signer ?? null, }, config: { index: 1, isWritable: true as boolean, value: input.config ?? null, }, executeHash: { index: 2, isWritable: true as boolean, value: input.executeHash ?? 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: InvokeInstructionArgs = { ...input }; // Default values. 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 = getInvokeInstructionDataSerializer().serialize( resolvedArgs as InvokeInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }