/** * 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 { combineCodec, fixDecoderSize, fixEncoderSize, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, SolanaError, transformEncoder, type AccountMeta, type AccountSignerMeta, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type ReadonlyAccount, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, type WritableSignerAccount, } from '@solana/kit'; import { getAccountMetaFactory, type ResolvedInstructionAccount, } from '@solana/program-client-core'; import { SAGE_PROGRAM_ADDRESS } from '../programs'; export const ADVANCE_ATLAS_REWARD_EPOCH_DISCRIMINATOR = new Uint8Array([ 166, 190, 92, 172, 4, 253, 242, 153, ]); export function getAdvanceAtlasRewardEpochDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode( ADVANCE_ATLAS_REWARD_EPOCH_DISCRIMINATOR, ); } export type AdvanceAtlasRewardEpochInstruction< TProgram extends string = typeof SAGE_PROGRAM_ADDRESS, TAccountFunder extends string | AccountMeta = string, TAccountGame extends string | AccountMeta = string, TAccountRegistry extends string | AccountMeta = string, TAccountActiveConfig extends string | AccountMeta = string, TAccountPendingConfig extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & InstructionWithAccounts< [ TAccountFunder extends string ? WritableSignerAccount & AccountSignerMeta : TAccountFunder, TAccountGame extends string ? ReadonlyAccount : TAccountGame, TAccountRegistry extends string ? WritableAccount : TAccountRegistry, TAccountActiveConfig extends string ? ReadonlyAccount : TAccountActiveConfig, TAccountPendingConfig extends string ? ReadonlyAccount : TAccountPendingConfig, ...TRemainingAccounts, ] >; export type AdvanceAtlasRewardEpochInstructionData = { discriminator: ReadonlyUint8Array; }; export type AdvanceAtlasRewardEpochInstructionDataArgs = {}; export function getAdvanceAtlasRewardEpochInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), (value) => ({ ...value, discriminator: ADVANCE_ATLAS_REWARD_EPOCH_DISCRIMINATOR, }), ); } export function getAdvanceAtlasRewardEpochInstructionDataDecoder(): FixedSizeDecoder { return getStructDecoder([ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ]); } export function getAdvanceAtlasRewardEpochInstructionDataCodec(): FixedSizeCodec< AdvanceAtlasRewardEpochInstructionDataArgs, AdvanceAtlasRewardEpochInstructionData > { return combineCodec( getAdvanceAtlasRewardEpochInstructionDataEncoder(), getAdvanceAtlasRewardEpochInstructionDataDecoder(), ); } export type AdvanceAtlasRewardEpochInput< TAccountFunder extends string = string, TAccountGame extends string = string, TAccountRegistry extends string = string, TAccountActiveConfig extends string = string, TAccountPendingConfig extends string = string, > = { funder: TransactionSigner; game: Address; registry: Address; /** Current active version, PDA-checked against registry data in `process`. */ activeConfig: Address; /** Required exactly when the registry has a pending version. */ pendingConfig?: Address; }; export function getAdvanceAtlasRewardEpochInstruction< TAccountFunder extends string, TAccountGame extends string, TAccountRegistry extends string, TAccountActiveConfig extends string, TAccountPendingConfig extends string, TProgramAddress extends Address = typeof SAGE_PROGRAM_ADDRESS, >( input: AdvanceAtlasRewardEpochInput< TAccountFunder, TAccountGame, TAccountRegistry, TAccountActiveConfig, TAccountPendingConfig >, config?: { programAddress?: TProgramAddress }, ): AdvanceAtlasRewardEpochInstruction< TProgramAddress, TAccountFunder, TAccountGame, TAccountRegistry, TAccountActiveConfig, TAccountPendingConfig > { // Program address. const programAddress = config?.programAddress ?? SAGE_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { funder: { value: input.funder ?? null, isWritable: true }, game: { value: input.game ?? null, isWritable: false }, registry: { value: input.registry ?? null, isWritable: true }, activeConfig: { value: input.activeConfig ?? null, isWritable: false }, pendingConfig: { value: input.pendingConfig ?? null, isWritable: false }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, ResolvedInstructionAccount >; const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); return Object.freeze({ accounts: [ getAccountMeta('funder', accounts.funder), getAccountMeta('game', accounts.game), getAccountMeta('registry', accounts.registry), getAccountMeta('activeConfig', accounts.activeConfig), getAccountMeta('pendingConfig', accounts.pendingConfig), ], data: getAdvanceAtlasRewardEpochInstructionDataEncoder().encode({}), programAddress, } as AdvanceAtlasRewardEpochInstruction< TProgramAddress, TAccountFunder, TAccountGame, TAccountRegistry, TAccountActiveConfig, TAccountPendingConfig >); } export type ParsedAdvanceAtlasRewardEpochInstruction< TProgram extends string = typeof SAGE_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], > = { programAddress: Address; accounts: { funder: TAccountMetas[0]; game: TAccountMetas[1]; registry: TAccountMetas[2]; /** Current active version, PDA-checked against registry data in `process`. */ activeConfig: TAccountMetas[3]; /** Required exactly when the registry has a pending version. */ pendingConfig?: TAccountMetas[4] | undefined; }; data: AdvanceAtlasRewardEpochInstructionData; }; export function parseAdvanceAtlasRewardEpochInstruction< TProgram extends string, TAccountMetas extends readonly AccountMeta[], >( instruction: Instruction & InstructionWithAccounts & InstructionWithData, ): ParsedAdvanceAtlasRewardEpochInstruction { if (instruction.accounts.length < 5) { throw new SolanaError( SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 5, }, ); } let accountIndex = 0; const getNextAccount = () => { const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; accountIndex += 1; return accountMeta; }; const getNextOptionalAccount = () => { const accountMeta = getNextAccount(); return accountMeta.address === SAGE_PROGRAM_ADDRESS ? undefined : accountMeta; }; return { programAddress: instruction.programAddress, accounts: { funder: getNextAccount(), game: getNextAccount(), registry: getNextAccount(), activeConfig: getNextAccount(), pendingConfig: getNextOptionalAccount(), }, data: getAdvanceAtlasRewardEpochInstructionDataDecoder().decode( instruction.data, ), }; }