/** * 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, getU32Decoder, getU32Encoder, getU8Decoder, getU8Encoder, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, SolanaError, transformEncoder, type AccountMeta, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type ReadonlyAccount, type ReadonlyUint8Array, type WritableAccount, } from '@solana/kit'; import { getAccountMetaFactory, type ResolvedInstructionAccount, } from '@solana/program-client-core'; import { SAGE_PROGRAM_ADDRESS } from '../programs'; export const SKIP_UNPRICED_RENT_SOURCE_DISCRIMINATOR = new Uint8Array([ 173, 117, 234, 15, 230, 138, 114, 20, ]); export function getSkipUnpricedRentSourceDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode( SKIP_UNPRICED_RENT_SOURCE_DISCRIMINATOR, ); } export type SkipUnpricedRentSourceInstruction< TProgram extends string = typeof SAGE_PROGRAM_ADDRESS, TAccountGame extends string | AccountMeta = string, TAccountCatalog extends string | AccountMeta = string, TAccountSystem extends string | AccountMeta = string, TAccountBody extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & InstructionWithAccounts< [ TAccountGame extends string ? ReadonlyAccount : TAccountGame, TAccountCatalog extends string ? WritableAccount : TAccountCatalog, TAccountSystem extends string ? ReadonlyAccount : TAccountSystem, TAccountBody extends string ? ReadonlyAccount : TAccountBody, ...TRemainingAccounts, ] >; export type SkipUnpricedRentSourceInstructionData = { discriminator: ReadonlyUint8Array; kind: number; expectedCursor: number; }; export type SkipUnpricedRentSourceInstructionDataArgs = { kind: number; expectedCursor: number; }; export function getSkipUnpricedRentSourceInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['kind', getU8Encoder()], ['expectedCursor', getU32Encoder()], ]), (value) => ({ ...value, discriminator: SKIP_UNPRICED_RENT_SOURCE_DISCRIMINATOR, }), ); } export function getSkipUnpricedRentSourceInstructionDataDecoder(): FixedSizeDecoder { return getStructDecoder([ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['kind', getU8Decoder()], ['expectedCursor', getU32Decoder()], ]); } export function getSkipUnpricedRentSourceInstructionDataCodec(): FixedSizeCodec< SkipUnpricedRentSourceInstructionDataArgs, SkipUnpricedRentSourceInstructionData > { return combineCodec( getSkipUnpricedRentSourceInstructionDataEncoder(), getSkipUnpricedRentSourceInstructionDataDecoder(), ); } export type SkipUnpricedRentSourceInput< TAccountGame extends string = string, TAccountCatalog extends string = string, TAccountSystem extends string = string, TAccountBody extends string = string, > = { game: Address; catalog: Address; /** LEVEL only: the canonical star system of the scanned id. */ system?: Address; /** GRID only: the canonical celestial body of the scanned id. */ body?: Address; kind: SkipUnpricedRentSourceInstructionDataArgs['kind']; expectedCursor: SkipUnpricedRentSourceInstructionDataArgs['expectedCursor']; }; export function getSkipUnpricedRentSourceInstruction< TAccountGame extends string, TAccountCatalog extends string, TAccountSystem extends string, TAccountBody extends string, TProgramAddress extends Address = typeof SAGE_PROGRAM_ADDRESS, >( input: SkipUnpricedRentSourceInput< TAccountGame, TAccountCatalog, TAccountSystem, TAccountBody >, config?: { programAddress?: TProgramAddress }, ): SkipUnpricedRentSourceInstruction< TProgramAddress, TAccountGame, TAccountCatalog, TAccountSystem, TAccountBody > { // Program address. const programAddress = config?.programAddress ?? SAGE_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { game: { value: input.game ?? null, isWritable: false }, catalog: { value: input.catalog ?? null, isWritable: true }, system: { value: input.system ?? null, isWritable: false }, body: { value: input.body ?? 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('game', accounts.game), getAccountMeta('catalog', accounts.catalog), getAccountMeta('system', accounts.system), getAccountMeta('body', accounts.body), ], data: getSkipUnpricedRentSourceInstructionDataEncoder().encode( args as SkipUnpricedRentSourceInstructionDataArgs, ), programAddress, } as SkipUnpricedRentSourceInstruction< TProgramAddress, TAccountGame, TAccountCatalog, TAccountSystem, TAccountBody >); } export type ParsedSkipUnpricedRentSourceInstruction< TProgram extends string = typeof SAGE_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], > = { programAddress: Address; accounts: { game: TAccountMetas[0]; catalog: TAccountMetas[1]; /** LEVEL only: the canonical star system of the scanned id. */ system?: TAccountMetas[2] | undefined; /** GRID only: the canonical celestial body of the scanned id. */ body?: TAccountMetas[3] | undefined; }; data: SkipUnpricedRentSourceInstructionData; }; export function parseSkipUnpricedRentSourceInstruction< TProgram extends string, TAccountMetas extends readonly AccountMeta[], >( instruction: Instruction & InstructionWithAccounts & InstructionWithData, ): ParsedSkipUnpricedRentSourceInstruction { 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; }; const getNextOptionalAccount = () => { const accountMeta = getNextAccount(); return accountMeta.address === SAGE_PROGRAM_ADDRESS ? undefined : accountMeta; }; return { programAddress: instruction.programAddress, accounts: { game: getNextAccount(), catalog: getNextAccount(), system: getNextOptionalAccount(), body: getNextOptionalAccount(), }, data: getSkipUnpricedRentSourceInstructionDataDecoder().decode( instruction.data, ), }; }