/** * 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, ReadonlyUint8Array, TransactionSigner, WritableAccount, WritableSignerAccount, } 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 INITIALIZE_POSITION_BUNDLE_WITH_METADATA_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([93, 124, 16, 179, 249, 131, 115, 245]); export function getInitializePositionBundleWithMetadataDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( INITIALIZE_POSITION_BUNDLE_WITH_METADATA_DISCRIMINATOR, ); } export type InitializePositionBundleWithMetadataInstruction< TProgram extends string = typeof WHIRLPOOL_PROGRAM_ADDRESS, TAccountPositionBundle extends string | AccountMeta = string, TAccountPositionBundleMint extends string | AccountMeta = string, TAccountPositionBundleMetadata extends string | AccountMeta = string, TAccountPositionBundleTokenAccount extends string | AccountMeta = string, TAccountPositionBundleOwner extends string | AccountMeta = string, TAccountFunder extends string | AccountMeta = string, TAccountMetadataUpdateAuth extends string | AccountMeta = string, TAccountTokenProgram extends | string | AccountMeta = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", TAccountSystemProgram extends | string | AccountMeta = "11111111111111111111111111111111", TAccountRent extends | string | AccountMeta = "SysvarRent111111111111111111111111111111111", TAccountAssociatedTokenProgram extends | string | AccountMeta = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL", TAccountMetadataProgram extends | string | AccountMeta = "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s", TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & InstructionWithAccounts< [ TAccountPositionBundle extends string ? WritableAccount : TAccountPositionBundle, TAccountPositionBundleMint extends string ? WritableSignerAccount & AccountSignerMeta : TAccountPositionBundleMint, TAccountPositionBundleMetadata extends string ? WritableAccount : TAccountPositionBundleMetadata, TAccountPositionBundleTokenAccount extends string ? WritableAccount : TAccountPositionBundleTokenAccount, TAccountPositionBundleOwner extends string ? ReadonlyAccount : TAccountPositionBundleOwner, TAccountFunder extends string ? WritableSignerAccount & AccountSignerMeta : TAccountFunder, TAccountMetadataUpdateAuth extends string ? ReadonlyAccount : TAccountMetadataUpdateAuth, TAccountTokenProgram extends string ? ReadonlyAccount : TAccountTokenProgram, TAccountSystemProgram extends string ? ReadonlyAccount : TAccountSystemProgram, TAccountRent extends string ? ReadonlyAccount : TAccountRent, TAccountAssociatedTokenProgram extends string ? ReadonlyAccount : TAccountAssociatedTokenProgram, TAccountMetadataProgram extends string ? ReadonlyAccount : TAccountMetadataProgram, ...TRemainingAccounts, ] >; export interface InitializePositionBundleWithMetadataInstructionData { discriminator: ReadonlyUint8Array; } export type InitializePositionBundleWithMetadataInstructionDataArgs = {}; export function getInitializePositionBundleWithMetadataInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]), (value) => ({ ...value, discriminator: INITIALIZE_POSITION_BUNDLE_WITH_METADATA_DISCRIMINATOR, }), ); } export function getInitializePositionBundleWithMetadataInstructionDataDecoder(): FixedSizeDecoder { return getStructDecoder([ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], ]); } export function getInitializePositionBundleWithMetadataInstructionDataCodec(): FixedSizeCodec< InitializePositionBundleWithMetadataInstructionDataArgs, InitializePositionBundleWithMetadataInstructionData > { return combineCodec( getInitializePositionBundleWithMetadataInstructionDataEncoder(), getInitializePositionBundleWithMetadataInstructionDataDecoder(), ); } export interface InitializePositionBundleWithMetadataInput< TAccountPositionBundle extends string = string, TAccountPositionBundleMint extends string = string, TAccountPositionBundleMetadata extends string = string, TAccountPositionBundleTokenAccount extends string = string, TAccountPositionBundleOwner extends string = string, TAccountFunder extends string = string, TAccountMetadataUpdateAuth extends string = string, TAccountTokenProgram extends string = string, TAccountSystemProgram extends string = string, TAccountRent extends string = string, TAccountAssociatedTokenProgram extends string = string, TAccountMetadataProgram extends string = string, > { positionBundle: Address; positionBundleMint: TransactionSigner; positionBundleMetadata: Address; positionBundleTokenAccount: Address; positionBundleOwner: Address; funder: TransactionSigner; metadataUpdateAuth: Address; tokenProgram?: Address; systemProgram?: Address; rent?: Address; associatedTokenProgram?: Address; metadataProgram?: Address; } export function getInitializePositionBundleWithMetadataInstruction< TAccountPositionBundle extends string, TAccountPositionBundleMint extends string, TAccountPositionBundleMetadata extends string, TAccountPositionBundleTokenAccount extends string, TAccountPositionBundleOwner extends string, TAccountFunder extends string, TAccountMetadataUpdateAuth extends string, TAccountTokenProgram extends string, TAccountSystemProgram extends string, TAccountRent extends string, TAccountAssociatedTokenProgram extends string, TAccountMetadataProgram extends string, TProgramAddress extends Address = typeof WHIRLPOOL_PROGRAM_ADDRESS, >( input: InitializePositionBundleWithMetadataInput< TAccountPositionBundle, TAccountPositionBundleMint, TAccountPositionBundleMetadata, TAccountPositionBundleTokenAccount, TAccountPositionBundleOwner, TAccountFunder, TAccountMetadataUpdateAuth, TAccountTokenProgram, TAccountSystemProgram, TAccountRent, TAccountAssociatedTokenProgram, TAccountMetadataProgram >, config?: { programAddress?: TProgramAddress }, ): InitializePositionBundleWithMetadataInstruction< TProgramAddress, TAccountPositionBundle, TAccountPositionBundleMint, TAccountPositionBundleMetadata, TAccountPositionBundleTokenAccount, TAccountPositionBundleOwner, TAccountFunder, TAccountMetadataUpdateAuth, TAccountTokenProgram, TAccountSystemProgram, TAccountRent, TAccountAssociatedTokenProgram, TAccountMetadataProgram > { // 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, }, positionBundleMetadata: { value: input.positionBundleMetadata ?? null, isWritable: true, }, positionBundleTokenAccount: { value: input.positionBundleTokenAccount ?? null, isWritable: true, }, positionBundleOwner: { value: input.positionBundleOwner ?? null, isWritable: false, }, funder: { value: input.funder ?? null, isWritable: true }, metadataUpdateAuth: { value: input.metadataUpdateAuth ?? null, isWritable: false, }, tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, systemProgram: { value: input.systemProgram ?? null, isWritable: false }, rent: { value: input.rent ?? null, isWritable: false }, associatedTokenProgram: { value: input.associatedTokenProgram ?? null, isWritable: false, }, metadataProgram: { value: input.metadataProgram ?? 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">; } if (!accounts.systemProgram.value) { accounts.systemProgram.value = "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">; } if (!accounts.rent.value) { accounts.rent.value = "SysvarRent111111111111111111111111111111111" as Address<"SysvarRent111111111111111111111111111111111">; } if (!accounts.associatedTokenProgram.value) { accounts.associatedTokenProgram.value = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" as Address<"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL">; } if (!accounts.metadataProgram.value) { accounts.metadataProgram.value = "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" as Address<"metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s">; } const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); return Object.freeze({ accounts: [ getAccountMeta("positionBundle", accounts.positionBundle), getAccountMeta("positionBundleMint", accounts.positionBundleMint), getAccountMeta("positionBundleMetadata", accounts.positionBundleMetadata), getAccountMeta( "positionBundleTokenAccount", accounts.positionBundleTokenAccount, ), getAccountMeta("positionBundleOwner", accounts.positionBundleOwner), getAccountMeta("funder", accounts.funder), getAccountMeta("metadataUpdateAuth", accounts.metadataUpdateAuth), getAccountMeta("tokenProgram", accounts.tokenProgram), getAccountMeta("systemProgram", accounts.systemProgram), getAccountMeta("rent", accounts.rent), getAccountMeta("associatedTokenProgram", accounts.associatedTokenProgram), getAccountMeta("metadataProgram", accounts.metadataProgram), ], data: getInitializePositionBundleWithMetadataInstructionDataEncoder().encode( {}, ), programAddress, } as InitializePositionBundleWithMetadataInstruction< TProgramAddress, TAccountPositionBundle, TAccountPositionBundleMint, TAccountPositionBundleMetadata, TAccountPositionBundleTokenAccount, TAccountPositionBundleOwner, TAccountFunder, TAccountMetadataUpdateAuth, TAccountTokenProgram, TAccountSystemProgram, TAccountRent, TAccountAssociatedTokenProgram, TAccountMetadataProgram >); } export interface ParsedInitializePositionBundleWithMetadataInstruction< TProgram extends string = typeof WHIRLPOOL_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], > { programAddress: Address; accounts: { positionBundle: TAccountMetas[0]; positionBundleMint: TAccountMetas[1]; positionBundleMetadata: TAccountMetas[2]; positionBundleTokenAccount: TAccountMetas[3]; positionBundleOwner: TAccountMetas[4]; funder: TAccountMetas[5]; metadataUpdateAuth: TAccountMetas[6]; tokenProgram: TAccountMetas[7]; systemProgram: TAccountMetas[8]; rent: TAccountMetas[9]; associatedTokenProgram: TAccountMetas[10]; metadataProgram: TAccountMetas[11]; }; data: InitializePositionBundleWithMetadataInstructionData; } export function parseInitializePositionBundleWithMetadataInstruction< TProgram extends string, TAccountMetas extends readonly AccountMeta[], >( instruction: Instruction & InstructionWithAccounts & InstructionWithData, ): ParsedInitializePositionBundleWithMetadataInstruction< TProgram, TAccountMetas > { if (instruction.accounts.length < 12) { throw new SolanaError( SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 12, }, ); } 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(), positionBundleMetadata: getNextAccount(), positionBundleTokenAccount: getNextAccount(), positionBundleOwner: getNextAccount(), funder: getNextAccount(), metadataUpdateAuth: getNextAccount(), tokenProgram: getNextAccount(), systemProgram: getNextAccount(), rent: getNextAccount(), associatedTokenProgram: getNextAccount(), metadataProgram: getNextAccount(), }, data: getInitializePositionBundleWithMetadataInstructionDataDecoder().decode( instruction.data, ), }; }