/** * 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 SetSendLibraryInstructionAccounts = { /** The PDA of the OApp or delegate */ signer: Signer; oappRegistry: PublicKey | Pda; sendLibraryConfig: PublicKey | Pda; messageLibInfo?: PublicKey | Pda; eventAuthority: PublicKey | Pda; program: PublicKey | Pda; }; // Data. export type SetSendLibraryInstructionData = { discriminator: Uint8Array; sender: PublicKey; eid: number; newLib: PublicKey; }; export type SetSendLibraryInstructionDataArgs = { sender: PublicKey; eid: number; newLib: PublicKey; }; export function getSetSendLibraryInstructionDataSerializer(): Serializer< SetSendLibraryInstructionDataArgs, SetSendLibraryInstructionData > { return mapSerializer< SetSendLibraryInstructionDataArgs, any, SetSendLibraryInstructionData >( struct( [ ['discriminator', bytes({ size: 8 })], ['sender', publicKeySerializer()], ['eid', u32()], ['newLib', publicKeySerializer()], ], { description: 'SetSendLibraryInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([251, 118, 78, 158, 134, 149, 129, 5]), }) ) as Serializer< SetSendLibraryInstructionDataArgs, SetSendLibraryInstructionData >; } // Args. export type SetSendLibraryInstructionArgs = SetSendLibraryInstructionDataArgs; // Instruction. export function setSendLibrary( context: Pick, input: SetSendLibraryInstructionAccounts & SetSendLibraryInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'endpoint', '76y77prsiCMvXMjuoZ5VRrhG5qYBrUMYTE5WgHqgjEn6' ); // Accounts. const resolvedAccounts = { signer: { index: 0, isWritable: false as boolean, value: input.signer ?? null, }, oappRegistry: { index: 1, isWritable: false as boolean, value: input.oappRegistry ?? null, }, sendLibraryConfig: { index: 2, isWritable: true as boolean, value: input.sendLibraryConfig ?? 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: SetSendLibraryInstructionArgs = { ...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 = getSetSendLibraryInstructionDataSerializer().serialize( resolvedArgs as SetSendLibraryInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }