/** * 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, 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 InitDefaultConfigInstructionAccounts = { admin: Signer; uln: PublicKey | Pda; sendConfig: PublicKey | Pda; receiveConfig: PublicKey | Pda; systemProgram?: PublicKey | Pda; eventAuthority: PublicKey | Pda; program: PublicKey | Pda; }; // Data. export type InitDefaultConfigInstructionData = { discriminator: Uint8Array; eid: number; sendUlnConfig: UlnConfig; receiveUlnConfig: UlnConfig; executorConfig: ExecutorConfig; }; export type InitDefaultConfigInstructionDataArgs = { eid: number; sendUlnConfig: UlnConfigArgs; receiveUlnConfig: UlnConfigArgs; executorConfig: ExecutorConfigArgs; }; export function getInitDefaultConfigInstructionDataSerializer(): Serializer< InitDefaultConfigInstructionDataArgs, InitDefaultConfigInstructionData > { return mapSerializer< InitDefaultConfigInstructionDataArgs, any, InitDefaultConfigInstructionData >( struct( [ ['discriminator', bytes({ size: 8 })], ['eid', u32()], ['sendUlnConfig', getUlnConfigSerializer()], ['receiveUlnConfig', getUlnConfigSerializer()], ['executorConfig', getExecutorConfigSerializer()], ], { description: 'InitDefaultConfigInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([98, 218, 197, 194, 173, 179, 112, 21]), }) ) as Serializer< InitDefaultConfigInstructionDataArgs, InitDefaultConfigInstructionData >; } // Args. export type InitDefaultConfigInstructionArgs = InitDefaultConfigInstructionDataArgs; // Instruction. export function initDefaultConfig( context: Pick, input: InitDefaultConfigInstructionAccounts & InitDefaultConfigInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'uln', '7a4WjyR8VZ7yZz5XJAKm39BUGn5iT9CKcv2pmG9tdXVH' ); // Accounts. const resolvedAccounts = { admin: { index: 0, isWritable: true 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, }, systemProgram: { index: 4, isWritable: false as boolean, value: input.systemProgram ?? null, }, eventAuthority: { index: 5, isWritable: false as boolean, value: input.eventAuthority ?? null, }, program: { index: 6, isWritable: false as boolean, value: input.program ?? null, }, } satisfies ResolvedAccountsWithIndices; // Arguments. const resolvedArgs: InitDefaultConfigInstructionArgs = { ...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 = getInitDefaultConfigInstructionDataSerializer().serialize( resolvedArgs as InitDefaultConfigInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }