/** * 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 SetDefaultSendLibraryInstructionAccounts = { admin: Signer; endpoint: PublicKey | Pda; defaultSendLibraryConfig: PublicKey | Pda; messageLibInfo: PublicKey | Pda; eventAuthority: PublicKey | Pda; program: PublicKey | Pda; }; // Data. export type SetDefaultSendLibraryInstructionData = { discriminator: Uint8Array; eid: number; newLib: PublicKey; }; export type SetDefaultSendLibraryInstructionDataArgs = { eid: number; newLib: PublicKey; }; export function getSetDefaultSendLibraryInstructionDataSerializer(): Serializer< SetDefaultSendLibraryInstructionDataArgs, SetDefaultSendLibraryInstructionData > { return mapSerializer< SetDefaultSendLibraryInstructionDataArgs, any, SetDefaultSendLibraryInstructionData >( struct( [ ['discriminator', bytes({ size: 8 })], ['eid', u32()], ['newLib', publicKeySerializer()], ], { description: 'SetDefaultSendLibraryInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([220, 215, 110, 127, 237, 178, 215, 170]), }) ) as Serializer< SetDefaultSendLibraryInstructionDataArgs, SetDefaultSendLibraryInstructionData >; } // Args. export type SetDefaultSendLibraryInstructionArgs = SetDefaultSendLibraryInstructionDataArgs; // Instruction. export function setDefaultSendLibrary( context: Pick, input: SetDefaultSendLibraryInstructionAccounts & SetDefaultSendLibraryInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'endpoint', '76y77prsiCMvXMjuoZ5VRrhG5qYBrUMYTE5WgHqgjEn6' ); // Accounts. const resolvedAccounts = { admin: { index: 0, isWritable: false as boolean, value: input.admin ?? null, }, endpoint: { index: 1, isWritable: false as boolean, value: input.endpoint ?? null, }, defaultSendLibraryConfig: { index: 2, isWritable: true as boolean, value: input.defaultSendLibraryConfig ?? null, }, messageLibInfo: { index: 3, isWritable: false as boolean, value: input.messageLibInfo ?? 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: SetDefaultSendLibraryInstructionArgs = { ...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 = getSetDefaultSendLibraryInstructionDataSerializer().serialize( resolvedArgs as SetDefaultSendLibraryInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }