/** * 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, u64, } from '@metaplex-foundation/umi/serializers'; import { ResolvedAccount, ResolvedAccountsWithIndices, getAccountMetasAndSigners, } from '../shared'; // Accounts. export type WithdrawFeesInstructionAccounts = { admin: Signer; messageLib: PublicKey | Pda; receiver: PublicKey | Pda; }; // Data. export type WithdrawFeesInstructionData = { discriminator: Uint8Array; amount: bigint; }; export type WithdrawFeesInstructionDataArgs = { amount: number | bigint }; export function getWithdrawFeesInstructionDataSerializer(): Serializer< WithdrawFeesInstructionDataArgs, WithdrawFeesInstructionData > { return mapSerializer< WithdrawFeesInstructionDataArgs, any, WithdrawFeesInstructionData >( struct( [ ['discriminator', bytes({ size: 8 })], ['amount', u64()], ], { description: 'WithdrawFeesInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([198, 212, 171, 109, 144, 215, 174, 89]), }) ) as Serializer; } // Args. export type WithdrawFeesInstructionArgs = WithdrawFeesInstructionDataArgs; // Instruction. export function withdrawFees( context: Pick, input: WithdrawFeesInstructionAccounts & WithdrawFeesInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'simpleMessagelib', '6GsmxMTHAAiFKfemuM4zBjumTjNSX5CAiw4xSSXM2Toy' ); // Accounts. const resolvedAccounts = { admin: { index: 0, isWritable: false as boolean, value: input.admin ?? null, }, messageLib: { index: 1, isWritable: true as boolean, value: input.messageLib ?? null, }, receiver: { index: 2, isWritable: true as boolean, value: input.receiver ?? null, }, } satisfies ResolvedAccountsWithIndices; // Arguments. const resolvedArgs: WithdrawFeesInstructionArgs = { ...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 = getWithdrawFeesInstructionDataSerializer().serialize( resolvedArgs as WithdrawFeesInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }