/** * 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, getU8Decoder, getU8Encoder, 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_REWARD_AUTHORITY_BY_SUPER_AUTHORITY_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([240, 154, 201, 198, 148, 93, 56, 25]); export function getSetRewardAuthorityBySuperAuthorityDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( SET_REWARD_AUTHORITY_BY_SUPER_AUTHORITY_DISCRIMINATOR, ); } export type SetRewardAuthorityBySuperAuthorityInstruction< TProgram extends string = typeof WHIRLPOOL_PROGRAM_ADDRESS, TAccountWhirlpoolsConfig extends string | AccountMeta = string, TAccountWhirlpool extends string | AccountMeta = string, TAccountRewardEmissionsSuperAuthority extends string | AccountMeta = string, TAccountNewRewardAuthority extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & InstructionWithAccounts< [ TAccountWhirlpoolsConfig extends string ? ReadonlyAccount : TAccountWhirlpoolsConfig, TAccountWhirlpool extends string ? WritableAccount : TAccountWhirlpool, TAccountRewardEmissionsSuperAuthority extends string ? ReadonlySignerAccount & AccountSignerMeta : TAccountRewardEmissionsSuperAuthority, TAccountNewRewardAuthority extends string ? ReadonlyAccount : TAccountNewRewardAuthority, ...TRemainingAccounts, ] >; export interface SetRewardAuthorityBySuperAuthorityInstructionData { discriminator: ReadonlyUint8Array; rewardIndex: number; } export interface SetRewardAuthorityBySuperAuthorityInstructionDataArgs { rewardIndex: number; } export function getSetRewardAuthorityBySuperAuthorityInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], ["rewardIndex", getU8Encoder()], ]), (value) => ({ ...value, discriminator: SET_REWARD_AUTHORITY_BY_SUPER_AUTHORITY_DISCRIMINATOR, }), ); } export function getSetRewardAuthorityBySuperAuthorityInstructionDataDecoder(): FixedSizeDecoder { return getStructDecoder([ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], ["rewardIndex", getU8Decoder()], ]); } export function getSetRewardAuthorityBySuperAuthorityInstructionDataCodec(): FixedSizeCodec< SetRewardAuthorityBySuperAuthorityInstructionDataArgs, SetRewardAuthorityBySuperAuthorityInstructionData > { return combineCodec( getSetRewardAuthorityBySuperAuthorityInstructionDataEncoder(), getSetRewardAuthorityBySuperAuthorityInstructionDataDecoder(), ); } export interface SetRewardAuthorityBySuperAuthorityInput< TAccountWhirlpoolsConfig extends string = string, TAccountWhirlpool extends string = string, TAccountRewardEmissionsSuperAuthority extends string = string, TAccountNewRewardAuthority extends string = string, > { whirlpoolsConfig: Address; whirlpool: Address; rewardEmissionsSuperAuthority: TransactionSigner; newRewardAuthority: Address; rewardIndex: SetRewardAuthorityBySuperAuthorityInstructionDataArgs["rewardIndex"]; } export function getSetRewardAuthorityBySuperAuthorityInstruction< TAccountWhirlpoolsConfig extends string, TAccountWhirlpool extends string, TAccountRewardEmissionsSuperAuthority extends string, TAccountNewRewardAuthority extends string, TProgramAddress extends Address = typeof WHIRLPOOL_PROGRAM_ADDRESS, >( input: SetRewardAuthorityBySuperAuthorityInput< TAccountWhirlpoolsConfig, TAccountWhirlpool, TAccountRewardEmissionsSuperAuthority, TAccountNewRewardAuthority >, config?: { programAddress?: TProgramAddress }, ): SetRewardAuthorityBySuperAuthorityInstruction< TProgramAddress, TAccountWhirlpoolsConfig, TAccountWhirlpool, TAccountRewardEmissionsSuperAuthority, TAccountNewRewardAuthority > { // Program address. const programAddress = config?.programAddress ?? WHIRLPOOL_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { whirlpoolsConfig: { value: input.whirlpoolsConfig ?? null, isWritable: false, }, whirlpool: { value: input.whirlpool ?? null, isWritable: true }, rewardEmissionsSuperAuthority: { value: input.rewardEmissionsSuperAuthority ?? null, isWritable: false, }, newRewardAuthority: { value: input.newRewardAuthority ?? null, isWritable: false, }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, ResolvedInstructionAccount >; // Original args. const args = { ...input }; const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); return Object.freeze({ accounts: [ getAccountMeta("whirlpoolsConfig", accounts.whirlpoolsConfig), getAccountMeta("whirlpool", accounts.whirlpool), getAccountMeta( "rewardEmissionsSuperAuthority", accounts.rewardEmissionsSuperAuthority, ), getAccountMeta("newRewardAuthority", accounts.newRewardAuthority), ], data: getSetRewardAuthorityBySuperAuthorityInstructionDataEncoder().encode( args as SetRewardAuthorityBySuperAuthorityInstructionDataArgs, ), programAddress, } as SetRewardAuthorityBySuperAuthorityInstruction< TProgramAddress, TAccountWhirlpoolsConfig, TAccountWhirlpool, TAccountRewardEmissionsSuperAuthority, TAccountNewRewardAuthority >); } export interface ParsedSetRewardAuthorityBySuperAuthorityInstruction< TProgram extends string = typeof WHIRLPOOL_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], > { programAddress: Address; accounts: { whirlpoolsConfig: TAccountMetas[0]; whirlpool: TAccountMetas[1]; rewardEmissionsSuperAuthority: TAccountMetas[2]; newRewardAuthority: TAccountMetas[3]; }; data: SetRewardAuthorityBySuperAuthorityInstructionData; } export function parseSetRewardAuthorityBySuperAuthorityInstruction< TProgram extends string, TAccountMetas extends readonly AccountMeta[], >( instruction: Instruction & InstructionWithAccounts & InstructionWithData, ): ParsedSetRewardAuthorityBySuperAuthorityInstruction< TProgram, TAccountMetas > { 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(), whirlpool: getNextAccount(), rewardEmissionsSuperAuthority: getNextAccount(), newRewardAuthority: getNextAccount(), }, data: getSetRewardAuthorityBySuperAuthorityInstructionDataDecoder().decode( instruction.data, ), }; }