/** * 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, u32, } from '@metaplex-foundation/umi/serializers'; import { ResolvedAccount, ResolvedAccountsWithIndices, getAccountMetasAndSigners, } from '../shared'; // Accounts. export type InitDefaultReceiveLibraryInstructionAccounts = { admin: Signer; endpoint: PublicKey | Pda; defaultReceiveLibraryConfig: PublicKey | Pda; messageLibInfo: PublicKey | Pda; systemProgram?: PublicKey | Pda; eventAuthority: PublicKey | Pda; program: PublicKey | Pda; }; // Data. export type InitDefaultReceiveLibraryInstructionData = { discriminator: Uint8Array; eid: number; newLib: PublicKey; }; export type InitDefaultReceiveLibraryInstructionDataArgs = { eid: number; newLib: PublicKey; }; export function getInitDefaultReceiveLibraryInstructionDataSerializer(): Serializer< InitDefaultReceiveLibraryInstructionDataArgs, InitDefaultReceiveLibraryInstructionData > { return mapSerializer< InitDefaultReceiveLibraryInstructionDataArgs, any, InitDefaultReceiveLibraryInstructionData >( struct( [ ['discriminator', bytes({ size: 8 })], ['eid', u32()], ['newLib', publicKeySerializer()], ], { description: 'InitDefaultReceiveLibraryInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([32, 202, 76, 22, 42, 249, 227, 109]), }) ) as Serializer< InitDefaultReceiveLibraryInstructionDataArgs, InitDefaultReceiveLibraryInstructionData >; } // Args. export type InitDefaultReceiveLibraryInstructionArgs = InitDefaultReceiveLibraryInstructionDataArgs; // Instruction. export function initDefaultReceiveLibrary( context: Pick, input: InitDefaultReceiveLibraryInstructionAccounts & InitDefaultReceiveLibraryInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'endpoint', '76y77prsiCMvXMjuoZ5VRrhG5qYBrUMYTE5WgHqgjEn6' ); // Accounts. const resolvedAccounts = { admin: { index: 0, isWritable: true as boolean, value: input.admin ?? null, }, endpoint: { index: 1, isWritable: false as boolean, value: input.endpoint ?? null, }, defaultReceiveLibraryConfig: { index: 2, isWritable: true as boolean, value: input.defaultReceiveLibraryConfig ?? null, }, messageLibInfo: { index: 3, isWritable: false as boolean, value: input.messageLibInfo ?? null, }, systemProgram: { index: 4, isWritable: false as boolean, value: input.systemProgram ?? null, }, eventAuthority: { index: 5, isWritable: false as boolean, value: input.eventAuthority ?? null, }, program: { index: 6, isWritable: false as boolean, value: input.program ?? null, }, } satisfies ResolvedAccountsWithIndices; // Arguments. const resolvedArgs: InitDefaultReceiveLibraryInstructionArgs = { ...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 = getInitDefaultReceiveLibraryInstructionDataSerializer().serialize( resolvedArgs as InitDefaultReceiveLibraryInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }