/** * 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 { OwnerSetConfigParams, OwnerSetConfigParamsArgs, getOwnerSetConfigParamsSerializer, } from '../types'; // Accounts. export type OwnerSetConfigInstructionAccounts = { owner: Signer; config: PublicKey | Pda; }; // Data. export type OwnerSetConfigInstructionData = { discriminator: Uint8Array; params: OwnerSetConfigParams; }; export type OwnerSetConfigInstructionDataArgs = { params: OwnerSetConfigParamsArgs; }; export function getOwnerSetConfigInstructionDataSerializer(): Serializer< OwnerSetConfigInstructionDataArgs, OwnerSetConfigInstructionData > { return mapSerializer< OwnerSetConfigInstructionDataArgs, any, OwnerSetConfigInstructionData >( struct( [ ['discriminator', bytes({ size: 8 })], ['params', getOwnerSetConfigParamsSerializer()], ], { description: 'OwnerSetConfigInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([99, 197, 129, 19, 164, 164, 183, 123]), }) ) as Serializer< OwnerSetConfigInstructionDataArgs, OwnerSetConfigInstructionData >; } // Args. export type OwnerSetConfigInstructionArgs = OwnerSetConfigInstructionDataArgs; // Instruction. export function ownerSetConfig( context: Pick, input: OwnerSetConfigInstructionAccounts & OwnerSetConfigInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'executor', '6doghB248px58JSSwG4qejQ46kFMW4AMj7vzJnWZHNZn' ); // Accounts. const resolvedAccounts = { owner: { index: 0, isWritable: false as boolean, value: input.owner ?? null, }, config: { index: 1, isWritable: true as boolean, value: input.config ?? null, }, } satisfies ResolvedAccountsWithIndices; // Arguments. const resolvedArgs: OwnerSetConfigInstructionArgs = { ...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 = getOwnerSetConfigInstructionDataSerializer().serialize( resolvedArgs as OwnerSetConfigInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }