/** * 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 InitReceiveLibraryInstructionAccounts = { /** only the delegate can initialize the send_library_config */ delegate: Signer; oappRegistry: PublicKey | Pda; receiveLibraryConfig: PublicKey | Pda; systemProgram?: PublicKey | Pda; }; // Data. export type InitReceiveLibraryInstructionData = { discriminator: Uint8Array; receiver: PublicKey; eid: number; }; export type InitReceiveLibraryInstructionDataArgs = { receiver: PublicKey; eid: number; }; export function getInitReceiveLibraryInstructionDataSerializer(): Serializer< InitReceiveLibraryInstructionDataArgs, InitReceiveLibraryInstructionData > { return mapSerializer< InitReceiveLibraryInstructionDataArgs, any, InitReceiveLibraryInstructionData >( struct( [ ['discriminator', bytes({ size: 8 })], ['receiver', publicKeySerializer()], ['eid', u32()], ], { description: 'InitReceiveLibraryInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([197, 114, 81, 100, 45, 233, 36, 230]), }) ) as Serializer< InitReceiveLibraryInstructionDataArgs, InitReceiveLibraryInstructionData >; } // Args. export type InitReceiveLibraryInstructionArgs = InitReceiveLibraryInstructionDataArgs; // Instruction. export function initReceiveLibrary( context: Pick, input: InitReceiveLibraryInstructionAccounts & InitReceiveLibraryInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'endpoint', '76y77prsiCMvXMjuoZ5VRrhG5qYBrUMYTE5WgHqgjEn6' ); // Accounts. const resolvedAccounts = { delegate: { index: 0, isWritable: true as boolean, value: input.delegate ?? null, }, oappRegistry: { index: 1, isWritable: false as boolean, value: input.oappRegistry ?? null, }, receiveLibraryConfig: { index: 2, isWritable: true as boolean, value: input.receiveLibraryConfig ?? null, }, systemProgram: { index: 3, isWritable: false as boolean, value: input.systemProgram ?? null, }, } satisfies ResolvedAccountsWithIndices; // Arguments. const resolvedArgs: InitReceiveLibraryInstructionArgs = { ...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 = getInitReceiveLibraryInstructionDataSerializer().serialize( resolvedArgs as InitReceiveLibraryInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }