/** * 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, getU16Decoder, getU16Encoder, getU64Decoder, getU64Encoder, 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'; export const QUEST_PROCESS_DISCRIMINATOR = new Uint8Array([ 204, 80, 96, 46, 233, 179, 161, 47, ]); export function getQuestProcessDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode( QUEST_PROCESS_DISCRIMINATOR, ); } /** * On-chain record of a crew quest being processed at a starbase. * * Field-for-field the `StarbaseUpgradeProcess` shape (upgrade_rs:8-34) minus the * upgrade-only `system` / `resource_id` / `quantity` fields and plus the crew payout * `reward_xp`. `KeyFor` / `KeyFor` are the typed owner * keys; `num_crew` is the crew committed to the quest (the amount * `reconcile_crew_allocation` moves out of the present pool while busy). */ export type QuestProcess = { discriminator: ReadonlyUint8Array; /** The data version of this account. */ version: number; /** The `Profile` key (the quest owner). */ profile: Address; /** The owning `StarbasePlayer` (the live-crew-counter choke-point). */ starbasePlayer: Address; /** * The starbase sequence id this quest is anchored to (staleness/refund check, exactly * as `StarbaseUpgradeProcess.is_stale`, upgrade_rs:33-38). */ starbaseSeqId: bigint; /** Number of crew committed to the quest. */ numCrew: number; /** * XP amount poured into the reward roster's accumulator on completion (the crew payout). * Named `reward_xp` because it is credited as XP via `folds.xp.pour_xp` — it grinds the * crew toward the perk-point milestones, it is NOT a direct perk-point mint (PR #732 * fourth review). Bounded by the existing `PERK_POINTS_MAX` ceiling as a defensive cap. */ rewardXp: number; /** * The roster page the reward MUST be credited to (PR #732 third review): pinned by the * owner at `StartQuest`, enforced at `CompleteQuest`. The permissionless cranker cannot * choose the distribution page (an empty/low-value page would burn the payout to dust), * nor omit the roster to destroy it. Reuses 2 bytes of the former `_pad: [u8; 5]`, so the * account size/layout is unchanged (every other field offset is identical). */ rewardPage: number; /** * Tail pad so `start_time` / `end_time` stay byte-flush under `#[repr(C, packed)]` and * the struct ends on a clean boundary (no semantic meaning). */ pad: Array; /** The quest start timestamp. */ startTime: bigint; /** The quest end timestamp (crew become free / payout claimable at/after this). */ endTime: bigint; }; export type QuestProcessArgs = { /** The data version of this account. */ version: number; /** The `Profile` key (the quest owner). */ profile: Address; /** The owning `StarbasePlayer` (the live-crew-counter choke-point). */ starbasePlayer: Address; /** * The starbase sequence id this quest is anchored to (staleness/refund check, exactly * as `StarbaseUpgradeProcess.is_stale`, upgrade_rs:33-38). */ starbaseSeqId: number | bigint; /** Number of crew committed to the quest. */ numCrew: number; /** * XP amount poured into the reward roster's accumulator on completion (the crew payout). * Named `reward_xp` because it is credited as XP via `folds.xp.pour_xp` — it grinds the * crew toward the perk-point milestones, it is NOT a direct perk-point mint (PR #732 * fourth review). Bounded by the existing `PERK_POINTS_MAX` ceiling as a defensive cap. */ rewardXp: number; /** * The roster page the reward MUST be credited to (PR #732 third review): pinned by the * owner at `StartQuest`, enforced at `CompleteQuest`. The permissionless cranker cannot * choose the distribution page (an empty/low-value page would burn the payout to dust), * nor omit the roster to destroy it. Reuses 2 bytes of the former `_pad: [u8; 5]`, so the * account size/layout is unchanged (every other field offset is identical). */ rewardPage: number; /** * Tail pad so `start_time` / `end_time` stay byte-flush under `#[repr(C, packed)]` and * the struct ends on a clean boundary (no semantic meaning). */ pad: Array; /** The quest start timestamp. */ startTime: number | bigint; /** The quest end timestamp (crew become free / payout claimable at/after this). */ endTime: number | bigint; }; /** Gets the encoder for {@link QuestProcessArgs} account data. */ export function getQuestProcessEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['version', getU8Encoder()], ['profile', getAddressEncoder()], ['starbasePlayer', getAddressEncoder()], ['starbaseSeqId', getU64Encoder()], ['numCrew', getU16Encoder()], ['rewardXp', getU8Encoder()], ['rewardPage', getU16Encoder()], ['pad', getArrayEncoder(getU8Encoder(), { size: 3 })], ['startTime', getI64Encoder()], ['endTime', getI64Encoder()], ]), (value) => ({ ...value, discriminator: QUEST_PROCESS_DISCRIMINATOR }), ); } /** Gets the decoder for {@link QuestProcess} account data. */ export function getQuestProcessDecoder(): FixedSizeDecoder { return getStructDecoder([ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['version', getU8Decoder()], ['profile', getAddressDecoder()], ['starbasePlayer', getAddressDecoder()], ['starbaseSeqId', getU64Decoder()], ['numCrew', getU16Decoder()], ['rewardXp', getU8Decoder()], ['rewardPage', getU16Decoder()], ['pad', getArrayDecoder(getU8Decoder(), { size: 3 })], ['startTime', getI64Decoder()], ['endTime', getI64Decoder()], ]); } /** Gets the codec for {@link QuestProcess} account data. */ export function getQuestProcessCodec(): FixedSizeCodec< QuestProcessArgs, QuestProcess > { return combineCodec(getQuestProcessEncoder(), getQuestProcessDecoder()); } export function decodeQuestProcess( encodedAccount: EncodedAccount, ): Account; export function decodeQuestProcess( encodedAccount: MaybeEncodedAccount, ): MaybeAccount; export function decodeQuestProcess( encodedAccount: EncodedAccount | MaybeEncodedAccount, ): Account | MaybeAccount { return decodeAccount( encodedAccount as MaybeEncodedAccount, getQuestProcessDecoder(), ); } export async function fetchQuestProcess( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchMaybeQuestProcess(rpc, address, config); assertAccountExists(maybeAccount); return maybeAccount; } export async function fetchMaybeQuestProcess( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchEncodedAccount(rpc, address, config); return decodeQuestProcess(maybeAccount); } export async function fetchAllQuestProcess( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchAllMaybeQuestProcess(rpc, addresses, config); assertAccountsExist(maybeAccounts); return maybeAccounts; } export async function fetchAllMaybeQuestProcess( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); return maybeAccounts.map((maybeAccount) => decodeQuestProcess(maybeAccount)); }