/** * 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_TOKEN_BADGE_AUTHORITY_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([207, 202, 4, 32, 205, 79, 13, 178]); export function getSetTokenBadgeAuthorityDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( SET_TOKEN_BADGE_AUTHORITY_DISCRIMINATOR, ); } export type SetTokenBadgeAuthorityInstruction< TProgram extends string = typeof WHIRLPOOL_PROGRAM_ADDRESS, TAccountWhirlpoolsConfig extends string | AccountMeta = string, TAccountWhirlpoolsConfigExtension extends string | AccountMeta = string, TAccountConfigExtensionAuthority extends string | AccountMeta = string, TAccountNewTokenBadgeAuthority extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & InstructionWithAccounts< [ TAccountWhirlpoolsConfig extends string ? ReadonlyAccount : TAccountWhirlpoolsConfig, TAccountWhirlpoolsConfigExtension extends string ? WritableAccount : TAccountWhirlpoolsConfigExtension, TAccountConfigExtensionAuthority extends string ? ReadonlySignerAccount & AccountSignerMeta : TAccountConfigExtensionAuthority, TAccountNewTokenBadgeAuthority extends string ? ReadonlyAccount : TAccountNewTokenBadgeAuthority, ...TRemainingAccounts, ] >; export interface SetTokenBadgeAuthorityInstructionData { discriminator: ReadonlyUint8Array; } export type SetTokenBadgeAuthorityInstructionDataArgs = {}; export function getSetTokenBadgeAuthorityInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]), (value) => ({ ...value, discriminator: SET_TOKEN_BADGE_AUTHORITY_DISCRIMINATOR, }), ); } export function getSetTokenBadgeAuthorityInstructionDataDecoder(): FixedSizeDecoder { return getStructDecoder([ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], ]); } export function getSetTokenBadgeAuthorityInstructionDataCodec(): FixedSizeCodec< SetTokenBadgeAuthorityInstructionDataArgs, SetTokenBadgeAuthorityInstructionData > { return combineCodec( getSetTokenBadgeAuthorityInstructionDataEncoder(), getSetTokenBadgeAuthorityInstructionDataDecoder(), ); } export interface SetTokenBadgeAuthorityInput< TAccountWhirlpoolsConfig extends string = string, TAccountWhirlpoolsConfigExtension extends string = string, TAccountConfigExtensionAuthority extends string = string, TAccountNewTokenBadgeAuthority extends string = string, > { whirlpoolsConfig: Address; whirlpoolsConfigExtension: Address; configExtensionAuthority: TransactionSigner; newTokenBadgeAuthority: Address; } export function getSetTokenBadgeAuthorityInstruction< TAccountWhirlpoolsConfig extends string, TAccountWhirlpoolsConfigExtension extends string, TAccountConfigExtensionAuthority extends string, TAccountNewTokenBadgeAuthority extends string, TProgramAddress extends Address = typeof WHIRLPOOL_PROGRAM_ADDRESS, >( input: SetTokenBadgeAuthorityInput< TAccountWhirlpoolsConfig, TAccountWhirlpoolsConfigExtension, TAccountConfigExtensionAuthority, TAccountNewTokenBadgeAuthority >, config?: { programAddress?: TProgramAddress }, ): SetTokenBadgeAuthorityInstruction< TProgramAddress, TAccountWhirlpoolsConfig, TAccountWhirlpoolsConfigExtension, TAccountConfigExtensionAuthority, TAccountNewTokenBadgeAuthority > { // Program address. const programAddress = config?.programAddress ?? WHIRLPOOL_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { whirlpoolsConfig: { value: input.whirlpoolsConfig ?? null, isWritable: false, }, whirlpoolsConfigExtension: { value: input.whirlpoolsConfigExtension ?? null, isWritable: true, }, configExtensionAuthority: { value: input.configExtensionAuthority ?? null, isWritable: false, }, newTokenBadgeAuthority: { value: input.newTokenBadgeAuthority ?? 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( "whirlpoolsConfigExtension", accounts.whirlpoolsConfigExtension, ), getAccountMeta( "configExtensionAuthority", accounts.configExtensionAuthority, ), getAccountMeta("newTokenBadgeAuthority", accounts.newTokenBadgeAuthority), ], data: getSetTokenBadgeAuthorityInstructionDataEncoder().encode({}), programAddress, } as SetTokenBadgeAuthorityInstruction< TProgramAddress, TAccountWhirlpoolsConfig, TAccountWhirlpoolsConfigExtension, TAccountConfigExtensionAuthority, TAccountNewTokenBadgeAuthority >); } export interface ParsedSetTokenBadgeAuthorityInstruction< TProgram extends string = typeof WHIRLPOOL_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], > { programAddress: Address; accounts: { whirlpoolsConfig: TAccountMetas[0]; whirlpoolsConfigExtension: TAccountMetas[1]; configExtensionAuthority: TAccountMetas[2]; newTokenBadgeAuthority: TAccountMetas[3]; }; data: SetTokenBadgeAuthorityInstructionData; } export function parseSetTokenBadgeAuthorityInstruction< TProgram extends string, TAccountMetas extends readonly AccountMeta[], >( instruction: Instruction & InstructionWithAccounts & InstructionWithData, ): ParsedSetTokenBadgeAuthorityInstruction { if (instruction.accounts.length < 4) { throw new SolanaError( SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 4, }, ); } let accountIndex = 0; const getNextAccount = () => { const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; accountIndex += 1; return accountMeta; }; return { programAddress: instruction.programAddress, accounts: { whirlpoolsConfig: getNextAccount(), whirlpoolsConfigExtension: getNextAccount(), configExtensionAuthority: getNextAccount(), newTokenBadgeAuthority: getNextAccount(), }, data: getSetTokenBadgeAuthorityInstructionDataDecoder().decode( instruction.data, ), }; }