/** * 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 { assertAccountExists, assertAccountsExist, combineCodec, decodeAccount, fetchEncodedAccount, fetchEncodedAccounts, fixDecoderSize, fixEncoderSize, getAddressDecoder, getAddressEncoder, getArrayDecoder, getArrayEncoder, getBytesDecoder, getBytesEncoder, getI64Decoder, getI64Encoder, getStructDecoder, getStructEncoder, getU32Decoder, getU32Encoder, getU8Decoder, getU8Encoder, transformEncoder, type Account, type Address, type EncodedAccount, type FetchAccountConfig, type FetchAccountsConfig, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type MaybeAccount, type MaybeEncodedAccount, type ReadonlyUint8Array, } from '@solana/kit'; import { findRentPtrCatalogPda, RentPtrCatalogSeeds } from '../pdas'; export const RENT_PTR_CATALOG_DISCRIMINATOR = new Uint8Array([ 81, 246, 163, 244, 111, 255, 92, 112, ]); export function getRentPtrCatalogDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode( RENT_PTR_CATALOG_DISCRIMINATOR, ); } /** * The per-game rent-history admission catalog. Created by the migration (a later slice); until then the * PDA is uninitialized, which every reader treats as `DISABLED` (see [`read_catalog_state`]). */ export type RentPtrCatalog = { discriminator: ReadonlyUint8Array; /** Schema lever (=1). */ version: number; bump: number; domain: Array; gameId: Address; /** One of [`rent_catalog_state`]. */ state: number; /** Chain time the catalog became Active (0 before). */ activationTime: bigint; /** Chain time the catalog entered Preparing (0 before). Distinct from any head's creation time. */ preparingStartedAt: bigint; /** Migration scan cursor per source kind (indexed by [`rent_source_kind`]), `0..=RENT_ID_NAMESPACE`. */ scanCursor: Array; /** Admitted (baselined) members per source kind — each source counted exactly once. */ admitted: Array; /** Admitted members still awaiting the explicit configuration attestation. */ unconfigured: number; /** Additive growth budget — carve typed fields from the FRONT; NEVER append. */ reserved: Array; }; export type RentPtrCatalogArgs = { /** Schema lever (=1). */ version: number; bump: number; domain: Array; gameId: Address; /** One of [`rent_catalog_state`]. */ state: number; /** Chain time the catalog became Active (0 before). */ activationTime: number | bigint; /** Chain time the catalog entered Preparing (0 before). Distinct from any head's creation time. */ preparingStartedAt: number | bigint; /** Migration scan cursor per source kind (indexed by [`rent_source_kind`]), `0..=RENT_ID_NAMESPACE`. */ scanCursor: Array; /** Admitted (baselined) members per source kind — each source counted exactly once. */ admitted: Array; /** Admitted members still awaiting the explicit configuration attestation. */ unconfigured: number; /** Additive growth budget — carve typed fields from the FRONT; NEVER append. */ reserved: Array; }; /** Gets the encoder for {@link RentPtrCatalogArgs} account data. */ export function getRentPtrCatalogEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['version', getU8Encoder()], ['bump', getU8Encoder()], ['domain', getArrayEncoder(getU8Encoder(), { size: 8 })], ['gameId', getAddressEncoder()], ['state', getU8Encoder()], ['activationTime', getI64Encoder()], ['preparingStartedAt', getI64Encoder()], ['scanCursor', getArrayEncoder(getU32Encoder(), { size: 3 })], ['admitted', getArrayEncoder(getU32Encoder(), { size: 3 })], ['unconfigured', getU32Encoder()], ['reserved', getArrayEncoder(getU8Encoder(), { size: 92 })], ]), (value) => ({ ...value, discriminator: RENT_PTR_CATALOG_DISCRIMINATOR }), ); } /** Gets the decoder for {@link RentPtrCatalog} account data. */ export function getRentPtrCatalogDecoder(): FixedSizeDecoder { return getStructDecoder([ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['version', getU8Decoder()], ['bump', getU8Decoder()], ['domain', getArrayDecoder(getU8Decoder(), { size: 8 })], ['gameId', getAddressDecoder()], ['state', getU8Decoder()], ['activationTime', getI64Decoder()], ['preparingStartedAt', getI64Decoder()], ['scanCursor', getArrayDecoder(getU32Decoder(), { size: 3 })], ['admitted', getArrayDecoder(getU32Decoder(), { size: 3 })], ['unconfigured', getU32Decoder()], ['reserved', getArrayDecoder(getU8Decoder(), { size: 92 })], ]); } /** Gets the codec for {@link RentPtrCatalog} account data. */ export function getRentPtrCatalogCodec(): FixedSizeCodec< RentPtrCatalogArgs, RentPtrCatalog > { return combineCodec(getRentPtrCatalogEncoder(), getRentPtrCatalogDecoder()); } export function decodeRentPtrCatalog( encodedAccount: EncodedAccount, ): Account; export function decodeRentPtrCatalog( encodedAccount: MaybeEncodedAccount, ): MaybeAccount; export function decodeRentPtrCatalog( encodedAccount: EncodedAccount | MaybeEncodedAccount, ): Account | MaybeAccount { return decodeAccount( encodedAccount as MaybeEncodedAccount, getRentPtrCatalogDecoder(), ); } export async function fetchRentPtrCatalog( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchMaybeRentPtrCatalog(rpc, address, config); assertAccountExists(maybeAccount); return maybeAccount; } export async function fetchMaybeRentPtrCatalog< TAddress extends string = string, >( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchEncodedAccount(rpc, address, config); return decodeRentPtrCatalog(maybeAccount); } export async function fetchAllRentPtrCatalog( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchAllMaybeRentPtrCatalog( rpc, addresses, config, ); assertAccountsExist(maybeAccounts); return maybeAccounts; } export async function fetchAllMaybeRentPtrCatalog( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); return maybeAccounts.map((maybeAccount) => decodeRentPtrCatalog(maybeAccount), ); } export async function fetchRentPtrCatalogFromSeeds( rpc: Parameters[0], seeds: RentPtrCatalogSeeds, config: FetchAccountConfig & { programAddress?: Address } = {}, ): Promise> { const maybeAccount = await fetchMaybeRentPtrCatalogFromSeeds( rpc, seeds, config, ); assertAccountExists(maybeAccount); return maybeAccount; } export async function fetchMaybeRentPtrCatalogFromSeeds( rpc: Parameters[0], seeds: RentPtrCatalogSeeds, config: FetchAccountConfig & { programAddress?: Address } = {}, ): Promise> { const { programAddress, ...fetchConfig } = config; const [address] = await findRentPtrCatalogPda(seeds, { programAddress }); return await fetchMaybeRentPtrCatalog(rpc, address, fetchConfig); }