/** * 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'; // Accounts. export type SetDefaultConfigInstructionAccounts = { admin: Signer; messageLib: PublicKey | Pda; sendConfig: PublicKey | Pda; receiveConfig: PublicKey | Pda; systemProgram?: PublicKey | Pda; }; // Data. export type SetDefaultConfigInstructionData = { discriminator: Uint8Array; eid: number; sendConfig: Option; receiveConfig: Option; }; export type SetDefaultConfigInstructionDataArgs = { eid: number; sendConfig: OptionOrNullable; receiveConfig: OptionOrNullable; }; export function getSetDefaultConfigInstructionDataSerializer(): Serializer< SetDefaultConfigInstructionDataArgs, SetDefaultConfigInstructionData > { return mapSerializer< SetDefaultConfigInstructionDataArgs, any, SetDefaultConfigInstructionData >( struct( [ ['discriminator', bytes({ size: 8 })], ['eid', u32()], ['sendConfig', option(bytes({ size: u32() }))], ['receiveConfig', option(bytes({ size: u32() }))], ], { 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, accounts: SetDefaultConfigInstructionAccounts, args: SetDefaultConfigInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'simpleMessagelib', '6GsmxMTHAAiFKfemuM4zBjumTjNSX5CAiw4xSSXM2Toy' ); // Accounts. const resolvedAccounts = { admin: { index: 0, isWritable: false as boolean, value: accounts.admin ?? null, }, messageLib: { index: 1, isWritable: false as boolean, value: accounts.messageLib ?? null, }, sendConfig: { index: 2, isWritable: true as boolean, value: accounts.sendConfig ?? null, }, receiveConfig: { index: 3, isWritable: true as boolean, value: accounts.receiveConfig ?? null, }, systemProgram: { index: 4, isWritable: false as boolean, value: accounts.systemProgram ?? null, }, } satisfies ResolvedAccountsWithIndices; // Arguments. const resolvedArgs: SetDefaultConfigInstructionArgs = { ...args }; // 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 = getSetDefaultConfigInstructionDataSerializer().serialize( resolvedArgs as SetDefaultConfigInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }