/** * 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, getU16Decoder, getU16Encoder, 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 ReadonlySignerAccount, 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_OWNER_RENT_SETTLEMENT_DISCRIMINATOR = new Uint8Array([ 105, 229, 103, 89, 76, 246, 45, 65, ]); export function getBeginOwnerRentSettlementDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode( BEGIN_OWNER_RENT_SETTLEMENT_DISCRIMINATOR, ); } export type BeginOwnerRentSettlementInstruction< TProgram extends string = typeof SAGE_PROGRAM_ADDRESS, TAccountFunder extends string | AccountMeta = string, TAccountOwnerSigner extends string | AccountMeta = string, TAccountOwnerProfile extends string | AccountMeta = string, TAccountOwnerCertificate extends string | AccountMeta = string, TAccountOwnerProgram extends string | AccountMeta = 'C4PRoFNroxxzdgeCoM31LJjYRg7kT6ymogSTAT99iD1u', 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, TAccountOwnerSigner extends string ? ReadonlySignerAccount & AccountSignerMeta : TAccountOwnerSigner, TAccountOwnerProfile extends string ? WritableAccount : TAccountOwnerProfile, TAccountOwnerCertificate extends string ? ReadonlyAccount : TAccountOwnerCertificate, TAccountOwnerProgram extends string ? ReadonlyAccount : TAccountOwnerProgram, 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 BeginOwnerRentSettlementInstructionData = { discriminator: ReadonlyUint8Array; keyIndex: number; cutoff: bigint; expectedNonce: bigint; }; export type BeginOwnerRentSettlementInstructionDataArgs = { keyIndex: number; cutoff: number | bigint; expectedNonce: number | bigint; }; export function getBeginOwnerRentSettlementInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['keyIndex', getU16Encoder()], ['cutoff', getI64Encoder()], ['expectedNonce', getU64Encoder()], ]), (value) => ({ ...value, discriminator: BEGIN_OWNER_RENT_SETTLEMENT_DISCRIMINATOR, }), ); } export function getBeginOwnerRentSettlementInstructionDataDecoder(): FixedSizeDecoder { return getStructDecoder([ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['keyIndex', getU16Decoder()], ['cutoff', getI64Decoder()], ['expectedNonce', getU64Decoder()], ]); } export function getBeginOwnerRentSettlementInstructionDataCodec(): FixedSizeCodec< BeginOwnerRentSettlementInstructionDataArgs, BeginOwnerRentSettlementInstructionData > { return combineCodec( getBeginOwnerRentSettlementInstructionDataEncoder(), getBeginOwnerRentSettlementInstructionDataDecoder(), ); } export type BeginOwnerRentSettlementInput< TAccountFunder extends string = string, TAccountOwnerSigner extends string = string, TAccountOwnerProfile extends string = string, TAccountOwnerCertificate extends string = string, TAccountOwnerProgram 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; ownerSigner: TransactionSigner; ownerProfile: Address; ownerCertificate?: Address; ownerProgram?: Address; game: Address; catalog: Address; stake: Address; system: Address; celestialBody: Address; gridHead: Address; levelHead: Address; defHead: Address; authority: Address; eval: Address; systemProgram?: Address; keyIndex: BeginOwnerRentSettlementInstructionDataArgs['keyIndex']; cutoff: BeginOwnerRentSettlementInstructionDataArgs['cutoff']; expectedNonce: BeginOwnerRentSettlementInstructionDataArgs['expectedNonce']; }; export function getBeginOwnerRentSettlementInstruction< TAccountFunder extends string, TAccountOwnerSigner extends string, TAccountOwnerProfile extends string, TAccountOwnerCertificate extends string, TAccountOwnerProgram 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: BeginOwnerRentSettlementInput< TAccountFunder, TAccountOwnerSigner, TAccountOwnerProfile, TAccountOwnerCertificate, TAccountOwnerProgram, TAccountGame, TAccountCatalog, TAccountStake, TAccountSystem, TAccountCelestialBody, TAccountGridHead, TAccountLevelHead, TAccountDefHead, TAccountAuthority, TAccountEval, TAccountSystemProgram >, config?: { programAddress?: TProgramAddress }, ): BeginOwnerRentSettlementInstruction< TProgramAddress, TAccountFunder, TAccountOwnerSigner, TAccountOwnerProfile, TAccountOwnerCertificate, TAccountOwnerProgram, 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 }, ownerSigner: { value: input.ownerSigner ?? null, isWritable: false }, ownerProfile: { value: input.ownerProfile ?? null, isWritable: true }, ownerCertificate: { value: input.ownerCertificate ?? null, isWritable: false, }, ownerProgram: { value: input.ownerProgram ?? null, isWritable: false }, 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.ownerProgram.value) { accounts.ownerProgram.value = 'C4PRoFNroxxzdgeCoM31LJjYRg7kT6ymogSTAT99iD1u' as Address<'C4PRoFNroxxzdgeCoM31LJjYRg7kT6ymogSTAT99iD1u'>; } 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('ownerSigner', accounts.ownerSigner), getAccountMeta('ownerProfile', accounts.ownerProfile), getAccountMeta('ownerCertificate', accounts.ownerCertificate), getAccountMeta('ownerProgram', accounts.ownerProgram), 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: getBeginOwnerRentSettlementInstructionDataEncoder().encode( args as BeginOwnerRentSettlementInstructionDataArgs, ), programAddress, } as BeginOwnerRentSettlementInstruction< TProgramAddress, TAccountFunder, TAccountOwnerSigner, TAccountOwnerProfile, TAccountOwnerCertificate, TAccountOwnerProgram, TAccountGame, TAccountCatalog, TAccountStake, TAccountSystem, TAccountCelestialBody, TAccountGridHead, TAccountLevelHead, TAccountDefHead, TAccountAuthority, TAccountEval, TAccountSystemProgram >); } export type ParsedBeginOwnerRentSettlementInstruction< TProgram extends string = typeof SAGE_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], > = { programAddress: Address; accounts: { funder: TAccountMetas[0]; ownerSigner: TAccountMetas[1]; ownerProfile: TAccountMetas[2]; ownerCertificate?: TAccountMetas[3] | undefined; ownerProgram: TAccountMetas[4]; game: TAccountMetas[5]; catalog: TAccountMetas[6]; stake: TAccountMetas[7]; system: TAccountMetas[8]; celestialBody: TAccountMetas[9]; gridHead: TAccountMetas[10]; levelHead: TAccountMetas[11]; defHead: TAccountMetas[12]; authority: TAccountMetas[13]; eval: TAccountMetas[14]; systemProgram: TAccountMetas[15]; }; data: BeginOwnerRentSettlementInstructionData; }; export function parseBeginOwnerRentSettlementInstruction< TProgram extends string, TAccountMetas extends readonly AccountMeta[], >( instruction: Instruction & InstructionWithAccounts & InstructionWithData, ): ParsedBeginOwnerRentSettlementInstruction { if (instruction.accounts.length < 16) { throw new SolanaError( SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 16, }, ); } 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(), ownerSigner: getNextAccount(), ownerProfile: getNextAccount(), ownerCertificate: getNextOptionalAccount(), ownerProgram: getNextAccount(), game: getNextAccount(), catalog: getNextAccount(), stake: getNextAccount(), system: getNextAccount(), celestialBody: getNextAccount(), gridHead: getNextAccount(), levelHead: getNextAccount(), defHead: getNextAccount(), authority: getNextAccount(), eval: getNextAccount(), systemProgram: getNextAccount(), }, data: getBeginOwnerRentSettlementInstructionDataDecoder().decode( instruction.data, ), }; }