/** * 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, getBytesDecoder, getBytesEncoder, getI64Decoder, getI64Encoder, getMapDecoder, getMapEncoder, getStructDecoder, getStructEncoder, getU16Decoder, getU16Encoder, getU32Decoder, getU32Encoder, getU64Decoder, getU64Encoder, getU8Decoder, getU8Encoder, transformEncoder, type Account, type Address, type Codec, type Decoder, type EncodedAccount, type Encoder, type FetchAccountConfig, type FetchAccountsConfig, type MaybeAccount, type MaybeEncodedAccount, type ReadonlyUint8Array, } from '@solana/kit'; import { getBuildingIdDecoder, getBuildingIdEncoder, getClaimStakeDefinitionIdDecoder, getClaimStakeDefinitionIdEncoder, getProductionCoreDecoder, getProductionCoreEncoder, getStructureInstanceStateDecoder, getStructureInstanceStateEncoder, type BuildingId, type BuildingIdArgs, type ClaimStakeDefinitionId, type ClaimStakeDefinitionIdArgs, type ProductionCore, type ProductionCoreArgs, type StructureInstanceState, type StructureInstanceStateArgs, } from '../types'; export const CLAIM_STAKE_INSTANCE_DISCRIMINATOR = new Uint8Array([ 200, 38, 62, 51, 255, 157, 40, 163, ]); export function getClaimStakeInstanceDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode( CLAIM_STAKE_INSTANCE_DISCRIMINATOR, ); } /** Claim stake instance that specifies capabilities and requirements. Inherits stats from `ClaimStakeDefinition` */ export type ClaimStakeInstance = { discriminator: ReadonlyUint8Array; /** The data version of this account. */ version: number; /** The owner of the claim stake instance */ owner: Address; /** The game id */ gameId: Address; /** The celestial body id */ celestialBodyId: Address; /** The claim stake cargo id */ claimStakeDefinitionId: ClaimStakeDefinitionId; /** The sequence id of the claim stake definitions */ claimStakeDefinitionSeqId: number; /** The sequence id of the building definitions */ buildingDefinitionSeqId: number; /** The sequence id of the system in which the claim stake is placed */ systemSeqId: bigint; /** Last time rent was collected */ lastRentClockTimestamp: bigint; /** Remaining seconds of construction (decrements while Active) */ constructionRemaining: bigint; /** * Active-time cursor for construction progression. * This timestamp is advanced only while the stake is Active. */ constructionProgressTimestamp: bigint; /** Rent balance */ rentBalance: bigint; /** Actual committed Crew for version 1. Version 0 contains unverified nominal stats. */ neededCrew: number; /** Buildings placed on the claim stake */ buildings: Map; /** An enum of the current state of the claim stake instance, either active or design */ state: StructureInstanceState; /** The resource production/consumption core */ productionCore: ProductionCore; }; export type ClaimStakeInstanceArgs = { /** The data version of this account. */ version: number; /** The owner of the claim stake instance */ owner: Address; /** The game id */ gameId: Address; /** The celestial body id */ celestialBodyId: Address; /** The claim stake cargo id */ claimStakeDefinitionId: ClaimStakeDefinitionIdArgs; /** The sequence id of the claim stake definitions */ claimStakeDefinitionSeqId: number; /** The sequence id of the building definitions */ buildingDefinitionSeqId: number; /** The sequence id of the system in which the claim stake is placed */ systemSeqId: number | bigint; /** Last time rent was collected */ lastRentClockTimestamp: number | bigint; /** Remaining seconds of construction (decrements while Active) */ constructionRemaining: number | bigint; /** * Active-time cursor for construction progression. * This timestamp is advanced only while the stake is Active. */ constructionProgressTimestamp: number | bigint; /** Rent balance */ rentBalance: number | bigint; /** Actual committed Crew for version 1. Version 0 contains unverified nominal stats. */ neededCrew: number; /** Buildings placed on the claim stake */ buildings: Map; /** An enum of the current state of the claim stake instance, either active or design */ state: StructureInstanceStateArgs; /** The resource production/consumption core */ productionCore: ProductionCoreArgs; }; /** Gets the encoder for {@link ClaimStakeInstanceArgs} account data. */ export function getClaimStakeInstanceEncoder(): Encoder { return transformEncoder( getStructEncoder([ ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['version', getU8Encoder()], ['owner', getAddressEncoder()], ['gameId', getAddressEncoder()], ['celestialBodyId', getAddressEncoder()], ['claimStakeDefinitionId', getClaimStakeDefinitionIdEncoder()], ['claimStakeDefinitionSeqId', getU32Encoder()], ['buildingDefinitionSeqId', getU32Encoder()], ['systemSeqId', getU64Encoder()], ['lastRentClockTimestamp', getI64Encoder()], ['constructionRemaining', getI64Encoder()], ['constructionProgressTimestamp', getI64Encoder()], ['rentBalance', getU64Encoder()], ['neededCrew', getU16Encoder()], ['buildings', getMapEncoder(getBuildingIdEncoder(), getU32Encoder())], ['state', getStructureInstanceStateEncoder()], ['productionCore', getProductionCoreEncoder()], ]), (value) => ({ ...value, discriminator: CLAIM_STAKE_INSTANCE_DISCRIMINATOR, }), ); } /** Gets the decoder for {@link ClaimStakeInstance} account data. */ export function getClaimStakeInstanceDecoder(): Decoder { return getStructDecoder([ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['version', getU8Decoder()], ['owner', getAddressDecoder()], ['gameId', getAddressDecoder()], ['celestialBodyId', getAddressDecoder()], ['claimStakeDefinitionId', getClaimStakeDefinitionIdDecoder()], ['claimStakeDefinitionSeqId', getU32Decoder()], ['buildingDefinitionSeqId', getU32Decoder()], ['systemSeqId', getU64Decoder()], ['lastRentClockTimestamp', getI64Decoder()], ['constructionRemaining', getI64Decoder()], ['constructionProgressTimestamp', getI64Decoder()], ['rentBalance', getU64Decoder()], ['neededCrew', getU16Decoder()], ['buildings', getMapDecoder(getBuildingIdDecoder(), getU32Decoder())], ['state', getStructureInstanceStateDecoder()], ['productionCore', getProductionCoreDecoder()], ]); } /** Gets the codec for {@link ClaimStakeInstance} account data. */ export function getClaimStakeInstanceCodec(): Codec< ClaimStakeInstanceArgs, ClaimStakeInstance > { return combineCodec( getClaimStakeInstanceEncoder(), getClaimStakeInstanceDecoder(), ); } export function decodeClaimStakeInstance( encodedAccount: EncodedAccount, ): Account; export function decodeClaimStakeInstance( encodedAccount: MaybeEncodedAccount, ): MaybeAccount; export function decodeClaimStakeInstance( encodedAccount: EncodedAccount | MaybeEncodedAccount, ): | Account | MaybeAccount { return decodeAccount( encodedAccount as MaybeEncodedAccount, getClaimStakeInstanceDecoder(), ); } export async function fetchClaimStakeInstance( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchMaybeClaimStakeInstance(rpc, address, config); assertAccountExists(maybeAccount); return maybeAccount; } export async function fetchMaybeClaimStakeInstance< TAddress extends string = string, >( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchEncodedAccount(rpc, address, config); return decodeClaimStakeInstance(maybeAccount); } export async function fetchAllClaimStakeInstance( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchAllMaybeClaimStakeInstance( rpc, addresses, config, ); assertAccountsExist(maybeAccounts); return maybeAccounts; } export async function fetchAllMaybeClaimStakeInstance( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); return maybeAccounts.map((maybeAccount) => decodeClaimStakeInstance(maybeAccount), ); }