/** * 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 SET_FEE_AUTHORITY_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([31, 1, 50, 87, 237, 101, 97, 132]); export function getSetFeeAuthorityDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( SET_FEE_AUTHORITY_DISCRIMINATOR, ); } export type SetFeeAuthorityInstruction< TProgram extends string = typeof WHIRLPOOL_PROGRAM_ADDRESS, TAccountWhirlpoolsConfig extends string | AccountMeta = string, TAccountFeeAuthority extends string | AccountMeta = string, TAccountNewFeeAuthority extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & InstructionWithAccounts< [ TAccountWhirlpoolsConfig extends string ? WritableAccount : TAccountWhirlpoolsConfig, TAccountFeeAuthority extends string ? ReadonlySignerAccount & AccountSignerMeta : TAccountFeeAuthority, TAccountNewFeeAuthority extends string ? ReadonlyAccount : TAccountNewFeeAuthority, ...TRemainingAccounts, ] >; export interface SetFeeAuthorityInstructionData { discriminator: ReadonlyUint8Array; } export type SetFeeAuthorityInstructionDataArgs = {}; export function getSetFeeAuthorityInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]), (value) => ({ ...value, discriminator: SET_FEE_AUTHORITY_DISCRIMINATOR }), ); } export function getSetFeeAuthorityInstructionDataDecoder(): FixedSizeDecoder { return getStructDecoder([ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], ]); } export function getSetFeeAuthorityInstructionDataCodec(): FixedSizeCodec< SetFeeAuthorityInstructionDataArgs, SetFeeAuthorityInstructionData > { return combineCodec( getSetFeeAuthorityInstructionDataEncoder(), getSetFeeAuthorityInstructionDataDecoder(), ); } export interface SetFeeAuthorityInput< TAccountWhirlpoolsConfig extends string = string, TAccountFeeAuthority extends string = string, TAccountNewFeeAuthority extends string = string, > { whirlpoolsConfig: Address; feeAuthority: TransactionSigner; newFeeAuthority: Address; } export function getSetFeeAuthorityInstruction< TAccountWhirlpoolsConfig extends string, TAccountFeeAuthority extends string, TAccountNewFeeAuthority extends string, TProgramAddress extends Address = typeof WHIRLPOOL_PROGRAM_ADDRESS, >( input: SetFeeAuthorityInput< TAccountWhirlpoolsConfig, TAccountFeeAuthority, TAccountNewFeeAuthority >, config?: { programAddress?: TProgramAddress }, ): SetFeeAuthorityInstruction< TProgramAddress, TAccountWhirlpoolsConfig, TAccountFeeAuthority, TAccountNewFeeAuthority > { // Program address. const programAddress = config?.programAddress ?? WHIRLPOOL_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { whirlpoolsConfig: { value: input.whirlpoolsConfig ?? null, isWritable: true, }, feeAuthority: { value: input.feeAuthority ?? null, isWritable: false }, newFeeAuthority: { value: input.newFeeAuthority ?? null, isWritable: false, }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, ResolvedInstructionAccount >; const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); return Object.freeze({ accounts: [ getAccountMeta("whirlpoolsConfig", accounts.whirlpoolsConfig), getAccountMeta("feeAuthority", accounts.feeAuthority), getAccountMeta("newFeeAuthority", accounts.newFeeAuthority), ], data: getSetFeeAuthorityInstructionDataEncoder().encode({}), programAddress, } as SetFeeAuthorityInstruction< TProgramAddress, TAccountWhirlpoolsConfig, TAccountFeeAuthority, TAccountNewFeeAuthority >); } export interface ParsedSetFeeAuthorityInstruction< TProgram extends string = typeof WHIRLPOOL_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], > { programAddress: Address; accounts: { whirlpoolsConfig: TAccountMetas[0]; feeAuthority: TAccountMetas[1]; newFeeAuthority: TAccountMetas[2]; }; data: SetFeeAuthorityInstructionData; } export function parseSetFeeAuthorityInstruction< TProgram extends string, TAccountMetas extends readonly AccountMeta[], >( instruction: Instruction & InstructionWithAccounts & InstructionWithData, ): ParsedSetFeeAuthorityInstruction { if (instruction.accounts.length < 3) { throw new SolanaError( SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 3, }, ); } let accountIndex = 0; const getNextAccount = () => { const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; accountIndex += 1; return accountMeta; }; return { programAddress: instruction.programAddress, accounts: { whirlpoolsConfig: getNextAccount(), feeAuthority: getNextAccount(), newFeeAuthority: getNextAccount(), }, data: getSetFeeAuthorityInstructionDataDecoder().decode(instruction.data), }; }