/** * 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 InitSendLibraryInstructionAccounts = { /** only the delegate can initialize the send_library_config */ delegate: Signer; oappRegistry: PublicKey | Pda; sendLibraryConfig: PublicKey | Pda; systemProgram?: PublicKey | Pda; }; // Data. export type InitSendLibraryInstructionData = { discriminator: Uint8Array; sender: PublicKey; eid: number; }; export type InitSendLibraryInstructionDataArgs = { sender: PublicKey; eid: number; }; export function getInitSendLibraryInstructionDataSerializer(): Serializer< InitSendLibraryInstructionDataArgs, InitSendLibraryInstructionData > { return mapSerializer< InitSendLibraryInstructionDataArgs, any, InitSendLibraryInstructionData >( struct( [ ['discriminator', bytes({ size: 8 })], ['sender', publicKeySerializer()], ['eid', u32()], ], { description: 'InitSendLibraryInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([156, 24, 235, 120, 73, 193, 144, 19]), }) ) as Serializer< InitSendLibraryInstructionDataArgs, InitSendLibraryInstructionData >; } // Args. export type InitSendLibraryInstructionArgs = InitSendLibraryInstructionDataArgs; // Instruction. export function initSendLibrary( context: Pick, input: InitSendLibraryInstructionAccounts & InitSendLibraryInstructionArgs ): 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, }, sendLibraryConfig: { index: 2, isWritable: true as boolean, value: input.sendLibraryConfig ?? null, }, systemProgram: { index: 3, isWritable: false as boolean, value: input.systemProgram ?? null, }, } satisfies ResolvedAccountsWithIndices; // Arguments. const resolvedArgs: InitSendLibraryInstructionArgs = { ...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 = getInitSendLibraryInstructionDataSerializer().serialize( resolvedArgs as InitSendLibraryInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }