/** * 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, u64, } from '@metaplex-foundation/umi/serializers'; import { ResolvedAccount, ResolvedAccountsWithIndices, getAccountMetasAndSigners, } from '../shared'; // Accounts. export type SetReceiveLibraryInstructionAccounts = { /** The PDA of the OApp or delegate */ signer: Signer; oappRegistry: PublicKey | Pda; receiveLibraryConfig: PublicKey | Pda; messageLibInfo?: PublicKey | Pda; eventAuthority: PublicKey | Pda; program: PublicKey | Pda; }; // Data. export type SetReceiveLibraryInstructionData = { discriminator: Uint8Array; receiver: PublicKey; eid: number; newLib: PublicKey; gracePeriod: bigint; }; export type SetReceiveLibraryInstructionDataArgs = { receiver: PublicKey; eid: number; newLib: PublicKey; gracePeriod: number | bigint; }; export function getSetReceiveLibraryInstructionDataSerializer(): Serializer< SetReceiveLibraryInstructionDataArgs, SetReceiveLibraryInstructionData > { return mapSerializer< SetReceiveLibraryInstructionDataArgs, any, SetReceiveLibraryInstructionData >( struct( [ ['discriminator', bytes({ size: 8 })], ['receiver', publicKeySerializer()], ['eid', u32()], ['newLib', publicKeySerializer()], ['gracePeriod', u64()], ], { description: 'SetReceiveLibraryInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([223, 172, 180, 105, 165, 161, 147, 228]), }) ) as Serializer< SetReceiveLibraryInstructionDataArgs, SetReceiveLibraryInstructionData >; } // Args. export type SetReceiveLibraryInstructionArgs = SetReceiveLibraryInstructionDataArgs; // Instruction. export function setReceiveLibrary( context: Pick, input: SetReceiveLibraryInstructionAccounts & SetReceiveLibraryInstructionArgs ): 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, }, receiveLibraryConfig: { index: 2, isWritable: true as boolean, value: input.receiveLibraryConfig ?? 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: SetReceiveLibraryInstructionArgs = { ...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 = getSetReceiveLibraryInstructionDataSerializer().serialize( resolvedArgs as SetReceiveLibraryInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }