/** * 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 WithdrawRentInstructionAccounts = { admin: Signer; endpoint: PublicKey | Pda; receiver: PublicKey | Pda; eventAuthority: PublicKey | Pda; program: PublicKey | Pda; }; // Data. export type WithdrawRentInstructionData = { discriminator: Uint8Array; amount: bigint; }; export type WithdrawRentInstructionDataArgs = { amount: number | bigint }; export function getWithdrawRentInstructionDataSerializer(): Serializer< WithdrawRentInstructionDataArgs, WithdrawRentInstructionData > { return mapSerializer< WithdrawRentInstructionDataArgs, any, WithdrawRentInstructionData >( struct( [ ['discriminator', bytes({ size: 8 })], ['amount', u64()], ], { description: 'WithdrawRentInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([226, 7, 41, 158, 173, 111, 192, 107]), }) ) as Serializer; } // Args. export type WithdrawRentInstructionArgs = WithdrawRentInstructionDataArgs; // Instruction. export function withdrawRent( context: Pick, input: WithdrawRentInstructionAccounts & WithdrawRentInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'endpoint', '76y77prsiCMvXMjuoZ5VRrhG5qYBrUMYTE5WgHqgjEn6' ); // Accounts. const resolvedAccounts = { admin: { index: 0, isWritable: false as boolean, value: input.admin ?? null, }, endpoint: { index: 1, isWritable: true as boolean, value: input.endpoint ?? 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: WithdrawRentInstructionArgs = { ...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 = getWithdrawRentInstructionDataSerializer().serialize( resolvedArgs as WithdrawRentInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }