/** * 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, getI64Decoder, getI64Encoder, getStructDecoder, getStructEncoder, getU64Decoder, getU64Encoder, 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 BEGIN_RENT_SETTLEMENT_DISCRIMINATOR = new Uint8Array([ 198, 108, 146, 182, 182, 23, 72, 203, ]); export function getBeginRentSettlementDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode( BEGIN_RENT_SETTLEMENT_DISCRIMINATOR, ); } export type BeginRentSettlementInstruction< TProgram extends string = typeof SAGE_PROGRAM_ADDRESS, TAccountFunder extends string | AccountMeta = string, TAccountGame extends string | AccountMeta = string, TAccountCatalog extends string | AccountMeta = string, TAccountStake extends string | AccountMeta = string, TAccountSystem extends string | AccountMeta = string, TAccountCelestialBody extends string | AccountMeta = string, TAccountGridHead extends string | AccountMeta = string, TAccountLevelHead extends string | AccountMeta = string, TAccountDefHead extends string | AccountMeta = string, TAccountAuthority extends string | AccountMeta = string, TAccountEval extends string | AccountMeta = string, TAccountSystemProgram extends string | AccountMeta = '11111111111111111111111111111111', TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & InstructionWithAccounts< [ TAccountFunder extends string ? WritableSignerAccount & AccountSignerMeta : TAccountFunder, TAccountGame extends string ? ReadonlyAccount : TAccountGame, TAccountCatalog extends string ? ReadonlyAccount : TAccountCatalog, TAccountStake extends string ? ReadonlyAccount : TAccountStake, TAccountSystem extends string ? ReadonlyAccount : TAccountSystem, TAccountCelestialBody extends string ? WritableAccount : TAccountCelestialBody, TAccountGridHead extends string ? ReadonlyAccount : TAccountGridHead, TAccountLevelHead extends string ? ReadonlyAccount : TAccountLevelHead, TAccountDefHead extends string ? ReadonlyAccount : TAccountDefHead, TAccountAuthority extends string ? WritableAccount : TAccountAuthority, TAccountEval extends string ? WritableAccount : TAccountEval, TAccountSystemProgram extends string ? ReadonlyAccount : TAccountSystemProgram, ...TRemainingAccounts, ] >; export type BeginRentSettlementInstructionData = { discriminator: ReadonlyUint8Array; cutoff: bigint; expectedNonce: bigint; }; export type BeginRentSettlementInstructionDataArgs = { cutoff: number | bigint; expectedNonce: number | bigint; }; export function getBeginRentSettlementInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['cutoff', getI64Encoder()], ['expectedNonce', getU64Encoder()], ]), (value) => ({ ...value, discriminator: BEGIN_RENT_SETTLEMENT_DISCRIMINATOR, }), ); } export function getBeginRentSettlementInstructionDataDecoder(): FixedSizeDecoder { return getStructDecoder([ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['cutoff', getI64Decoder()], ['expectedNonce', getU64Decoder()], ]); } export function getBeginRentSettlementInstructionDataCodec(): FixedSizeCodec< BeginRentSettlementInstructionDataArgs, BeginRentSettlementInstructionData > { return combineCodec( getBeginRentSettlementInstructionDataEncoder(), getBeginRentSettlementInstructionDataDecoder(), ); } export type BeginRentSettlementInput< TAccountFunder extends string = string, TAccountGame extends string = string, TAccountCatalog extends string = string, TAccountStake extends string = string, TAccountSystem extends string = string, TAccountCelestialBody extends string = string, TAccountGridHead extends string = string, TAccountLevelHead extends string = string, TAccountDefHead extends string = string, TAccountAuthority extends string = string, TAccountEval extends string = string, TAccountSystemProgram extends string = string, > = { funder: TransactionSigner; game: Address; catalog: Address; stake: Address; system: Address; /** Writable: its validation runs the pinned planet sync. */ celestialBody: Address; gridHead: Address; levelHead: Address; defHead: Address; authority: Address; eval: Address; systemProgram?: Address; cutoff: BeginRentSettlementInstructionDataArgs['cutoff']; expectedNonce: BeginRentSettlementInstructionDataArgs['expectedNonce']; }; export function getBeginRentSettlementInstruction< TAccountFunder extends string, TAccountGame extends string, TAccountCatalog extends string, TAccountStake extends string, TAccountSystem extends string, TAccountCelestialBody extends string, TAccountGridHead extends string, TAccountLevelHead extends string, TAccountDefHead extends string, TAccountAuthority extends string, TAccountEval extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof SAGE_PROGRAM_ADDRESS, >( input: BeginRentSettlementInput< TAccountFunder, TAccountGame, TAccountCatalog, TAccountStake, TAccountSystem, TAccountCelestialBody, TAccountGridHead, TAccountLevelHead, TAccountDefHead, TAccountAuthority, TAccountEval, TAccountSystemProgram >, config?: { programAddress?: TProgramAddress }, ): BeginRentSettlementInstruction< TProgramAddress, TAccountFunder, TAccountGame, TAccountCatalog, TAccountStake, TAccountSystem, TAccountCelestialBody, TAccountGridHead, TAccountLevelHead, TAccountDefHead, TAccountAuthority, TAccountEval, TAccountSystemProgram > { // 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 }, catalog: { value: input.catalog ?? null, isWritable: false }, stake: { value: input.stake ?? null, isWritable: false }, system: { value: input.system ?? null, isWritable: false }, celestialBody: { value: input.celestialBody ?? null, isWritable: true }, gridHead: { value: input.gridHead ?? null, isWritable: false }, levelHead: { value: input.levelHead ?? null, isWritable: false }, defHead: { value: input.defHead ?? null, isWritable: false }, authority: { value: input.authority ?? null, isWritable: true }, eval: { value: input.eval ?? null, isWritable: true }, systemProgram: { value: input.systemProgram ?? null, isWritable: false }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, ResolvedInstructionAccount >; // Original args. const args = { ...input }; // Resolve default values. if (!accounts.systemProgram.value) { accounts.systemProgram.value = '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; } const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); return Object.freeze({ accounts: [ getAccountMeta('funder', accounts.funder), getAccountMeta('game', accounts.game), getAccountMeta('catalog', accounts.catalog), getAccountMeta('stake', accounts.stake), getAccountMeta('system', accounts.system), getAccountMeta('celestialBody', accounts.celestialBody), getAccountMeta('gridHead', accounts.gridHead), getAccountMeta('levelHead', accounts.levelHead), getAccountMeta('defHead', accounts.defHead), getAccountMeta('authority', accounts.authority), getAccountMeta('eval', accounts.eval), getAccountMeta('systemProgram', accounts.systemProgram), ], data: getBeginRentSettlementInstructionDataEncoder().encode( args as BeginRentSettlementInstructionDataArgs, ), programAddress, } as BeginRentSettlementInstruction< TProgramAddress, TAccountFunder, TAccountGame, TAccountCatalog, TAccountStake, TAccountSystem, TAccountCelestialBody, TAccountGridHead, TAccountLevelHead, TAccountDefHead, TAccountAuthority, TAccountEval, TAccountSystemProgram >); } export type ParsedBeginRentSettlementInstruction< TProgram extends string = typeof SAGE_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], > = { programAddress: Address; accounts: { funder: TAccountMetas[0]; game: TAccountMetas[1]; catalog: TAccountMetas[2]; stake: TAccountMetas[3]; system: TAccountMetas[4]; /** Writable: its validation runs the pinned planet sync. */ celestialBody: TAccountMetas[5]; gridHead: TAccountMetas[6]; levelHead: TAccountMetas[7]; defHead: TAccountMetas[8]; authority: TAccountMetas[9]; eval: TAccountMetas[10]; systemProgram: TAccountMetas[11]; }; data: BeginRentSettlementInstructionData; }; export function parseBeginRentSettlementInstruction< TProgram extends string, TAccountMetas extends readonly AccountMeta[], >( instruction: Instruction & InstructionWithAccounts & InstructionWithData, ): ParsedBeginRentSettlementInstruction { 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: { funder: getNextAccount(), game: getNextAccount(), catalog: getNextAccount(), stake: getNextAccount(), system: getNextAccount(), celestialBody: getNextAccount(), gridHead: getNextAccount(), levelHead: getNextAccount(), defHead: getNextAccount(), authority: getNextAccount(), eval: getNextAccount(), systemProgram: getNextAccount(), }, data: getBeginRentSettlementInstructionDataDecoder().decode( instruction.data, ), }; }