/** * 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, Option, OptionOrNullable, Pda, PublicKey, Signer, TransactionBuilder, transactionBuilder, } from '@metaplex-foundation/umi'; import { Serializer, bytes, mapSerializer, option, struct, u32, } from '@metaplex-foundation/umi/serializers'; import { ResolvedAccount, ResolvedAccountsWithIndices, getAccountMetasAndSigners, } from '../shared'; import { ExecutorConfig, ExecutorConfigArgs, UlnConfig, UlnConfigArgs, getExecutorConfigSerializer, getUlnConfigSerializer, } from '../types'; // Accounts. export type SetDefaultConfigInstructionAccounts = { admin: Signer; uln: PublicKey | Pda; sendConfig: PublicKey | Pda; receiveConfig: PublicKey | Pda; eventAuthority: PublicKey | Pda; program: PublicKey | Pda; }; // Data. export type SetDefaultConfigInstructionData = { discriminator: Uint8Array; eid: number; sendUlnConfig: Option; receiveUlnConfig: Option; executorConfig: Option; }; export type SetDefaultConfigInstructionDataArgs = { eid: number; sendUlnConfig: OptionOrNullable; receiveUlnConfig: OptionOrNullable; executorConfig: OptionOrNullable; }; export function getSetDefaultConfigInstructionDataSerializer(): Serializer< SetDefaultConfigInstructionDataArgs, SetDefaultConfigInstructionData > { return mapSerializer< SetDefaultConfigInstructionDataArgs, any, SetDefaultConfigInstructionData >( struct( [ ['discriminator', bytes({ size: 8 })], ['eid', u32()], ['sendUlnConfig', option(getUlnConfigSerializer())], ['receiveUlnConfig', option(getUlnConfigSerializer())], ['executorConfig', option(getExecutorConfigSerializer())], ], { description: 'SetDefaultConfigInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([111, 228, 17, 75, 5, 76, 213, 169]), }) ) as Serializer< SetDefaultConfigInstructionDataArgs, SetDefaultConfigInstructionData >; } // Args. export type SetDefaultConfigInstructionArgs = SetDefaultConfigInstructionDataArgs; // Instruction. export function setDefaultConfig( context: Pick, input: SetDefaultConfigInstructionAccounts & SetDefaultConfigInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'uln', '7a4WjyR8VZ7yZz5XJAKm39BUGn5iT9CKcv2pmG9tdXVH' ); // Accounts. const resolvedAccounts = { admin: { index: 0, isWritable: false as boolean, value: input.admin ?? null, }, uln: { index: 1, isWritable: false as boolean, value: input.uln ?? null }, sendConfig: { index: 2, isWritable: true as boolean, value: input.sendConfig ?? null, }, receiveConfig: { index: 3, isWritable: true as boolean, value: input.receiveConfig ?? 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: SetDefaultConfigInstructionArgs = { ...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 = getSetDefaultConfigInstructionDataSerializer().serialize( resolvedArgs as SetDefaultConfigInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }