/** * This code was AUTOGENERATED using the Codama library. * Please DO NOT EDIT THIS FILE, instead use visitors * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ import type { AccountMeta, AccountSignerMeta, Address, FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder, Instruction, InstructionWithAccounts, InstructionWithData, ReadonlyAccount, ReadonlySignerAccount, ReadonlyUint8Array, TransactionSigner, WritableAccount, } from "@solana/kit"; import type { ResolvedInstructionAccount } from "@solana/program-client-core"; import { combineCodec, fixDecoderSize, fixEncoderSize, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, SolanaError, transformEncoder, } from "@solana/kit"; import { getAccountMetaFactory } from "@solana/program-client-core"; import { WHIRLPOOL_PROGRAM_ADDRESS } from "../programs/index.js"; export const DELETE_POSITION_BUNDLE_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([100, 25, 99, 2, 217, 239, 124, 173]); export function getDeletePositionBundleDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( DELETE_POSITION_BUNDLE_DISCRIMINATOR, ); } export type DeletePositionBundleInstruction< TProgram extends string = typeof WHIRLPOOL_PROGRAM_ADDRESS, TAccountPositionBundle extends string | AccountMeta = string, TAccountPositionBundleMint extends string | AccountMeta = string, TAccountPositionBundleTokenAccount extends string | AccountMeta = string, TAccountPositionBundleOwner extends string | AccountMeta = string, TAccountReceiver extends string | AccountMeta = string, TAccountTokenProgram extends | string | AccountMeta = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & InstructionWithAccounts< [ TAccountPositionBundle extends string ? WritableAccount : TAccountPositionBundle, TAccountPositionBundleMint extends string ? WritableAccount : TAccountPositionBundleMint, TAccountPositionBundleTokenAccount extends string ? WritableAccount : TAccountPositionBundleTokenAccount, TAccountPositionBundleOwner extends string ? ReadonlySignerAccount & AccountSignerMeta : TAccountPositionBundleOwner, TAccountReceiver extends string ? WritableAccount : TAccountReceiver, TAccountTokenProgram extends string ? ReadonlyAccount : TAccountTokenProgram, ...TRemainingAccounts, ] >; export interface DeletePositionBundleInstructionData { discriminator: ReadonlyUint8Array; } export type DeletePositionBundleInstructionDataArgs = {}; export function getDeletePositionBundleInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]), (value) => ({ ...value, discriminator: DELETE_POSITION_BUNDLE_DISCRIMINATOR, }), ); } export function getDeletePositionBundleInstructionDataDecoder(): FixedSizeDecoder { return getStructDecoder([ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], ]); } export function getDeletePositionBundleInstructionDataCodec(): FixedSizeCodec< DeletePositionBundleInstructionDataArgs, DeletePositionBundleInstructionData > { return combineCodec( getDeletePositionBundleInstructionDataEncoder(), getDeletePositionBundleInstructionDataDecoder(), ); } export interface DeletePositionBundleInput< TAccountPositionBundle extends string = string, TAccountPositionBundleMint extends string = string, TAccountPositionBundleTokenAccount extends string = string, TAccountPositionBundleOwner extends string = string, TAccountReceiver extends string = string, TAccountTokenProgram extends string = string, > { positionBundle: Address; positionBundleMint: Address; positionBundleTokenAccount: Address; positionBundleOwner: TransactionSigner; receiver: Address; tokenProgram?: Address; } export function getDeletePositionBundleInstruction< TAccountPositionBundle extends string, TAccountPositionBundleMint extends string, TAccountPositionBundleTokenAccount extends string, TAccountPositionBundleOwner extends string, TAccountReceiver extends string, TAccountTokenProgram extends string, TProgramAddress extends Address = typeof WHIRLPOOL_PROGRAM_ADDRESS, >( input: DeletePositionBundleInput< TAccountPositionBundle, TAccountPositionBundleMint, TAccountPositionBundleTokenAccount, TAccountPositionBundleOwner, TAccountReceiver, TAccountTokenProgram >, config?: { programAddress?: TProgramAddress }, ): DeletePositionBundleInstruction< TProgramAddress, TAccountPositionBundle, TAccountPositionBundleMint, TAccountPositionBundleTokenAccount, TAccountPositionBundleOwner, TAccountReceiver, TAccountTokenProgram > { // Program address. const programAddress = config?.programAddress ?? WHIRLPOOL_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { positionBundle: { value: input.positionBundle ?? null, isWritable: true }, positionBundleMint: { value: input.positionBundleMint ?? null, isWritable: true, }, positionBundleTokenAccount: { value: input.positionBundleTokenAccount ?? null, isWritable: true, }, positionBundleOwner: { value: input.positionBundleOwner ?? null, isWritable: false, }, receiver: { value: input.receiver ?? null, isWritable: true }, tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, ResolvedInstructionAccount >; // Resolve default values. if (!accounts.tokenProgram.value) { accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" as Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">; } const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); return Object.freeze({ accounts: [ getAccountMeta("positionBundle", accounts.positionBundle), getAccountMeta("positionBundleMint", accounts.positionBundleMint), getAccountMeta( "positionBundleTokenAccount", accounts.positionBundleTokenAccount, ), getAccountMeta("positionBundleOwner", accounts.positionBundleOwner), getAccountMeta("receiver", accounts.receiver), getAccountMeta("tokenProgram", accounts.tokenProgram), ], data: getDeletePositionBundleInstructionDataEncoder().encode({}), programAddress, } as DeletePositionBundleInstruction< TProgramAddress, TAccountPositionBundle, TAccountPositionBundleMint, TAccountPositionBundleTokenAccount, TAccountPositionBundleOwner, TAccountReceiver, TAccountTokenProgram >); } export interface ParsedDeletePositionBundleInstruction< TProgram extends string = typeof WHIRLPOOL_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], > { programAddress: Address; accounts: { positionBundle: TAccountMetas[0]; positionBundleMint: TAccountMetas[1]; positionBundleTokenAccount: TAccountMetas[2]; positionBundleOwner: TAccountMetas[3]; receiver: TAccountMetas[4]; tokenProgram: TAccountMetas[5]; }; data: DeletePositionBundleInstructionData; } export function parseDeletePositionBundleInstruction< TProgram extends string, TAccountMetas extends readonly AccountMeta[], >( instruction: Instruction & InstructionWithAccounts & InstructionWithData, ): ParsedDeletePositionBundleInstruction { if (instruction.accounts.length < 6) { throw new SolanaError( SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 6, }, ); } let accountIndex = 0; const getNextAccount = () => { const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; accountIndex += 1; return accountMeta; }; return { programAddress: instruction.programAddress, accounts: { positionBundle: getNextAccount(), positionBundleMint: getNextAccount(), positionBundleTokenAccount: getNextAccount(), positionBundleOwner: getNextAccount(), receiver: getNextAccount(), tokenProgram: getNextAccount(), }, data: getDeletePositionBundleInstructionDataDecoder().decode( instruction.data, ), }; }