/** * 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 WithdrawFeeInstructionAccounts = { admin: Signer; config: PublicKey | Pda; receiver: PublicKey | Pda; eventAuthority: PublicKey | Pda; program: PublicKey | Pda; }; // Data. export type WithdrawFeeInstructionData = { discriminator: Uint8Array; amount: bigint; }; export type WithdrawFeeInstructionDataArgs = { amount: number | bigint }; export function getWithdrawFeeInstructionDataSerializer(): Serializer< WithdrawFeeInstructionDataArgs, WithdrawFeeInstructionData > { return mapSerializer< WithdrawFeeInstructionDataArgs, any, WithdrawFeeInstructionData >( struct( [ ['discriminator', bytes({ size: 8 })], ['amount', u64()], ], { description: 'WithdrawFeeInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([14, 122, 231, 218, 31, 238, 223, 150]), }) ) as Serializer; } // Args. export type WithdrawFeeInstructionArgs = WithdrawFeeInstructionDataArgs; // Instruction. export function withdrawFee( context: Pick, input: WithdrawFeeInstructionAccounts & WithdrawFeeInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'dvn', 'HtEYV4xB4wvsj5fgTkcfuChYpvGYzgzwvNhgDZQNh7wW' ); // 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, }, receiver: { index: 2, isWritable: true as boolean, value: input.receiver ?? null, }, eventAuthority: { index: 3, isWritable: false as boolean, value: input.eventAuthority ?? null, }, program: { index: 4, isWritable: false as boolean, value: input.program ?? null, }, } satisfies ResolvedAccountsWithIndices; // Arguments. const resolvedArgs: WithdrawFeeInstructionArgs = { ...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 = getWithdrawFeeInstructionDataSerializer().serialize( resolvedArgs as WithdrawFeeInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }