/** * 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, } from '@metaplex-foundation/umi/serializers'; import { ResolvedAccount, ResolvedAccountsWithIndices, getAccountMetasAndSigners, } from '../shared'; import { AdminSetConfigParams, AdminSetConfigParamsArgs, getAdminSetConfigParamsSerializer, } from '../types'; // Accounts. export type AdminSetConfigInstructionAccounts = { admin: Signer; config: PublicKey | Pda; }; // Data. export type AdminSetConfigInstructionData = { discriminator: Uint8Array; params: AdminSetConfigParams; }; export type AdminSetConfigInstructionDataArgs = { params: AdminSetConfigParamsArgs; }; export function getAdminSetConfigInstructionDataSerializer(): Serializer< AdminSetConfigInstructionDataArgs, AdminSetConfigInstructionData > { return mapSerializer< AdminSetConfigInstructionDataArgs, any, AdminSetConfigInstructionData >( struct( [ ['discriminator', bytes({ size: 8 })], ['params', getAdminSetConfigParamsSerializer()], ], { description: 'AdminSetConfigInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([35, 56, 160, 84, 132, 156, 27, 79]), }) ) as Serializer< AdminSetConfigInstructionDataArgs, AdminSetConfigInstructionData >; } // Args. export type AdminSetConfigInstructionArgs = AdminSetConfigInstructionDataArgs; // Instruction. export function adminSetConfig( context: Pick, input: AdminSetConfigInstructionAccounts & AdminSetConfigInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'executor', '6doghB248px58JSSwG4qejQ46kFMW4AMj7vzJnWZHNZn' ); // Accounts. const resolvedAccounts = { admin: { index: 0, isWritable: false as boolean, value: input.admin ?? null, }, config: { index: 1, isWritable: true as boolean, value: input.config ?? null, }, } satisfies ResolvedAccountsWithIndices; // Arguments. const resolvedArgs: AdminSetConfigInstructionArgs = { ...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 = getAdminSetConfigInstructionDataSerializer().serialize( resolvedArgs as AdminSetConfigInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }