/** * 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, getI16Decoder, getI16Encoder, getI64Decoder, getI64Encoder, getStructDecoder, getStructEncoder, getU16Decoder, getU16Encoder, getU32Decoder, getU32Encoder, 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'; import { getCargoIdDecoder, getCargoIdEncoder, getRegionIdDecoder, getRegionIdEncoder, type CargoId, type CargoIdArgs, type RegionId, type RegionIdArgs, } from '../types'; export const MISSION_PROCESS_DISCRIMINATOR = new Uint8Array([ 81, 38, 83, 186, 107, 35, 161, 137, ]); export function getMissionProcessDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode( MISSION_PROCESS_DISCRIMINATOR, ); } /** * On-chain record of a mission being processed at a starbase. **188 B, `#[repr(C, packed)]`, align 1.** * Field order: status/identity → counters → stake → RNG commit → reward routing → timing → outcome → * the 4 appended Phase-2 faction-stance pins (stance_side/base_faction/sector_incumbent/pinned_outlaw). * Every multi-byte field byte-flush (the crew-record idiom); offsets are doc 10 §1.2 + doc 180 §10's grow. */ export type MissionProcess = { discriminator: ReadonlyUint8Array; /** off 0 — layout/schema version (mirrors `QuestProcess.version`). v0 = this layout. */ version: number; /** off 1 — stake-vault PDA bump (`(b"MissionVault", mission_key)`); stored to avoid re-derivation. */ bump: number; /** off 2 — `MissionStatus` (in-flight assertion + decoder/event convenience). */ status: number; /** off 3 — reserved (zero). */ outcomePad: number; /** off 4 — the mission owner (reward + injury target). Stamped from the VALIDATED starbase-player. */ profile: Address; /** off 36 — the live `busy_crew` counter the crew were reserved against (cross-checked, §below). */ starbasePlayer: Address; /** off 68 — staleness/refund check, verbatim `QuestProcess.starbase_seq_id`. */ starbaseSeqId: bigint; /** off 76 — the off-chain mission-catalog row this run instantiated (the editor's `templateId`). */ missionTemplateId: number; /** * off 80 — the sector this mission belongs to (the `RegionOrderAnchor` PDA key). PINNED at start * from the fleet/starbase location, never caller-chosen at settle (convention #2). */ regionId: RegionId; /** off 82 — crew committed (the `reconcile` magnitude), verbatim `QuestProcess.num_crew`. */ numCrew: number; /** off 84 — owner-pinned XP destination page, verbatim the quest fix. Required at settle when XP > 0. */ rewardPage: number; /** * off 86 — XP poured on WIN via `pour_xp`. **WIDENED u8 -> u16 vs `QuestProcess` (BUILD BLOCKER #0): * the quest path truncates at 255 AND clamps at `PERK_POINTS_MAX=10`; the mission settle does NEITHER.** */ rewardXp: number; /** * off 88 — THE committed success target, 0..=10000. Computed off-chain (same `formula.js` the editor * previews) and committed at start, BEFORE the deciding entropy exists. The roll compares to this. */ successBps: number; /** * off 90 — the slot `StartMission`/`ArmMissionSettle` landed in. The settle entropy is * `SlotHashes[commit_slot + REVEAL_DELAY]`. The anti-grind keystone. */ commitSlot: bigint; /** off 98 — ATLAS (Floyds) escrowed at start; forfeit on loss/abort, refunded on win (editor knob). */ stakeAtlas: bigint; /** * off 106 — the single PRIMARY staked resource type (0 = none); multi-resource stakes live in the * vault map (§4.1). This caches the primary leg for the no-map-load refund math. */ stakeResourceId: CargoId; /** off 108 — quantity of `stake_resource_id` escrowed (mirrored in the vault). */ stakeResourceQty: bigint; /** * off 116 — the emissions-fed treasury this mission's WIN payout draws from. Pinned at start to the * `(game, region_id)` treasury; settle validates the supplied treasury equals this. */ rewardPool: Address; /** * off 148 — the ATLAS (Floyds) paid on WIN, COMMITTED at start (the catalog's tier-scaled winAtlas). * On-chain so the per-epoch circuit-breaker — the only real inflation bound (00 §4 / H4) — caps it. * REFINEMENT over doc 10 §1.2, which omitted the reward amount: it must be committed to be * breaker-bounded (the settle has empty args + cannot trust the cranker for the payout size). */ rewardAtlas: bigint; /** off 156 — the off-chain Loot-Matrix table id rolled on win; settle EMITS `(loot_table_id, roll)`. */ lootTableId: number; /** off 160 — verbatim `QuestProcess.start_time`. */ startTime: bigint; /** off 168 — verbatim `QuestProcess.end_time`; settle is time-gated `now >= end_time`. */ endTime: bigint; /** off 176 — the settled draw (0..=9999) written at settle for the event/decoder/holosim echo. */ rollValue: number; /** off 178 — committed sector impact on WIN (+; off-chain PRE-SCALED = sectorDelta·tier_weight·regionMult). */ sectorWinDelta: number; /** off 180 — committed sector impact on LOSS (negative). The settle folds EXACTLY ONE into the anchor. */ sectorLossDelta: number; /** * off 182 — Phase-2 faction-stance: NARRATIVE intent. 0=INCUMBENT, 1=CHALLENGER, 255=NONE (untagged * mission → the whole stance block is skipped at settle; full back-compat). Committed at StartMission. */ stanceSide: number; /** * off 183 — the actor's faction at start, raw `Faction` repr as u8 (read from the VALIDATED * StarbasePlayer.faction — owner-signed, so re-citizenship between start and settle can't change it). */ baseFaction: number; /** * off 184 — the sector's rightful incumbent faction at start, raw `Faction` repr. Read TRUSTLESSLY * from `RegionTracker.regions[region_id].owner` (NEVER a caller arg). The own-faction gate is * `base_faction == sector_incumbent` (u8 equality — `Faction` is a niche enum, not `Pod`). */ sectorIncumbent: number; /** * off 185 — the RESOLVED outlaw status snapshotted at start (`outlaw==1 && now < pvp_until`); a * mid-mission `ClearOutlaw` cannot change this frozen byte. 0 when no OutlawFlag exists (fail-closed: * own-faction opposition stays BLOCKED). */ pinnedOutlaw: number; /** * off 186 — tail pad to the 188-byte boundary; forward-compat slack (reserved for the attrition trio * win_injury_bps/severity_table_id/overuse_band — a SEPARATE coordinated grow, doc-110 §3.2). */ pad: Array; }; export type MissionProcessArgs = { /** off 0 — layout/schema version (mirrors `QuestProcess.version`). v0 = this layout. */ version: number; /** off 1 — stake-vault PDA bump (`(b"MissionVault", mission_key)`); stored to avoid re-derivation. */ bump: number; /** off 2 — `MissionStatus` (in-flight assertion + decoder/event convenience). */ status: number; /** off 3 — reserved (zero). */ outcomePad: number; /** off 4 — the mission owner (reward + injury target). Stamped from the VALIDATED starbase-player. */ profile: Address; /** off 36 — the live `busy_crew` counter the crew were reserved against (cross-checked, §below). */ starbasePlayer: Address; /** off 68 — staleness/refund check, verbatim `QuestProcess.starbase_seq_id`. */ starbaseSeqId: number | bigint; /** off 76 — the off-chain mission-catalog row this run instantiated (the editor's `templateId`). */ missionTemplateId: number; /** * off 80 — the sector this mission belongs to (the `RegionOrderAnchor` PDA key). PINNED at start * from the fleet/starbase location, never caller-chosen at settle (convention #2). */ regionId: RegionIdArgs; /** off 82 — crew committed (the `reconcile` magnitude), verbatim `QuestProcess.num_crew`. */ numCrew: number; /** off 84 — owner-pinned XP destination page, verbatim the quest fix. Required at settle when XP > 0. */ rewardPage: number; /** * off 86 — XP poured on WIN via `pour_xp`. **WIDENED u8 -> u16 vs `QuestProcess` (BUILD BLOCKER #0): * the quest path truncates at 255 AND clamps at `PERK_POINTS_MAX=10`; the mission settle does NEITHER.** */ rewardXp: number; /** * off 88 — THE committed success target, 0..=10000. Computed off-chain (same `formula.js` the editor * previews) and committed at start, BEFORE the deciding entropy exists. The roll compares to this. */ successBps: number; /** * off 90 — the slot `StartMission`/`ArmMissionSettle` landed in. The settle entropy is * `SlotHashes[commit_slot + REVEAL_DELAY]`. The anti-grind keystone. */ commitSlot: number | bigint; /** off 98 — ATLAS (Floyds) escrowed at start; forfeit on loss/abort, refunded on win (editor knob). */ stakeAtlas: number | bigint; /** * off 106 — the single PRIMARY staked resource type (0 = none); multi-resource stakes live in the * vault map (§4.1). This caches the primary leg for the no-map-load refund math. */ stakeResourceId: CargoIdArgs; /** off 108 — quantity of `stake_resource_id` escrowed (mirrored in the vault). */ stakeResourceQty: number | bigint; /** * off 116 — the emissions-fed treasury this mission's WIN payout draws from. Pinned at start to the * `(game, region_id)` treasury; settle validates the supplied treasury equals this. */ rewardPool: Address; /** * off 148 — the ATLAS (Floyds) paid on WIN, COMMITTED at start (the catalog's tier-scaled winAtlas). * On-chain so the per-epoch circuit-breaker — the only real inflation bound (00 §4 / H4) — caps it. * REFINEMENT over doc 10 §1.2, which omitted the reward amount: it must be committed to be * breaker-bounded (the settle has empty args + cannot trust the cranker for the payout size). */ rewardAtlas: number | bigint; /** off 156 — the off-chain Loot-Matrix table id rolled on win; settle EMITS `(loot_table_id, roll)`. */ lootTableId: number; /** off 160 — verbatim `QuestProcess.start_time`. */ startTime: number | bigint; /** off 168 — verbatim `QuestProcess.end_time`; settle is time-gated `now >= end_time`. */ endTime: number | bigint; /** off 176 — the settled draw (0..=9999) written at settle for the event/decoder/holosim echo. */ rollValue: number; /** off 178 — committed sector impact on WIN (+; off-chain PRE-SCALED = sectorDelta·tier_weight·regionMult). */ sectorWinDelta: number; /** off 180 — committed sector impact on LOSS (negative). The settle folds EXACTLY ONE into the anchor. */ sectorLossDelta: number; /** * off 182 — Phase-2 faction-stance: NARRATIVE intent. 0=INCUMBENT, 1=CHALLENGER, 255=NONE (untagged * mission → the whole stance block is skipped at settle; full back-compat). Committed at StartMission. */ stanceSide: number; /** * off 183 — the actor's faction at start, raw `Faction` repr as u8 (read from the VALIDATED * StarbasePlayer.faction — owner-signed, so re-citizenship between start and settle can't change it). */ baseFaction: number; /** * off 184 — the sector's rightful incumbent faction at start, raw `Faction` repr. Read TRUSTLESSLY * from `RegionTracker.regions[region_id].owner` (NEVER a caller arg). The own-faction gate is * `base_faction == sector_incumbent` (u8 equality — `Faction` is a niche enum, not `Pod`). */ sectorIncumbent: number; /** * off 185 — the RESOLVED outlaw status snapshotted at start (`outlaw==1 && now < pvp_until`); a * mid-mission `ClearOutlaw` cannot change this frozen byte. 0 when no OutlawFlag exists (fail-closed: * own-faction opposition stays BLOCKED). */ pinnedOutlaw: number; /** * off 186 — tail pad to the 188-byte boundary; forward-compat slack (reserved for the attrition trio * win_injury_bps/severity_table_id/overuse_band — a SEPARATE coordinated grow, doc-110 §3.2). */ pad: Array; }; /** Gets the encoder for {@link MissionProcessArgs} account data. */ export function getMissionProcessEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['version', getU8Encoder()], ['bump', getU8Encoder()], ['status', getU8Encoder()], ['outcomePad', getU8Encoder()], ['profile', getAddressEncoder()], ['starbasePlayer', getAddressEncoder()], ['starbaseSeqId', getU64Encoder()], ['missionTemplateId', getU32Encoder()], ['regionId', getRegionIdEncoder()], ['numCrew', getU16Encoder()], ['rewardPage', getU16Encoder()], ['rewardXp', getU16Encoder()], ['successBps', getU16Encoder()], ['commitSlot', getU64Encoder()], ['stakeAtlas', getU64Encoder()], ['stakeResourceId', getCargoIdEncoder()], ['stakeResourceQty', getU64Encoder()], ['rewardPool', getAddressEncoder()], ['rewardAtlas', getU64Encoder()], ['lootTableId', getU32Encoder()], ['startTime', getI64Encoder()], ['endTime', getI64Encoder()], ['rollValue', getU16Encoder()], ['sectorWinDelta', getI16Encoder()], ['sectorLossDelta', getI16Encoder()], ['stanceSide', getU8Encoder()], ['baseFaction', getU8Encoder()], ['sectorIncumbent', getU8Encoder()], ['pinnedOutlaw', getU8Encoder()], ['pad', getArrayEncoder(getU8Encoder(), { size: 2 })], ]), (value) => ({ ...value, discriminator: MISSION_PROCESS_DISCRIMINATOR }), ); } /** Gets the decoder for {@link MissionProcess} account data. */ export function getMissionProcessDecoder(): FixedSizeDecoder { return getStructDecoder([ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['version', getU8Decoder()], ['bump', getU8Decoder()], ['status', getU8Decoder()], ['outcomePad', getU8Decoder()], ['profile', getAddressDecoder()], ['starbasePlayer', getAddressDecoder()], ['starbaseSeqId', getU64Decoder()], ['missionTemplateId', getU32Decoder()], ['regionId', getRegionIdDecoder()], ['numCrew', getU16Decoder()], ['rewardPage', getU16Decoder()], ['rewardXp', getU16Decoder()], ['successBps', getU16Decoder()], ['commitSlot', getU64Decoder()], ['stakeAtlas', getU64Decoder()], ['stakeResourceId', getCargoIdDecoder()], ['stakeResourceQty', getU64Decoder()], ['rewardPool', getAddressDecoder()], ['rewardAtlas', getU64Decoder()], ['lootTableId', getU32Decoder()], ['startTime', getI64Decoder()], ['endTime', getI64Decoder()], ['rollValue', getU16Decoder()], ['sectorWinDelta', getI16Decoder()], ['sectorLossDelta', getI16Decoder()], ['stanceSide', getU8Decoder()], ['baseFaction', getU8Decoder()], ['sectorIncumbent', getU8Decoder()], ['pinnedOutlaw', getU8Decoder()], ['pad', getArrayDecoder(getU8Decoder(), { size: 2 })], ]); } /** Gets the codec for {@link MissionProcess} account data. */ export function getMissionProcessCodec(): FixedSizeCodec< MissionProcessArgs, MissionProcess > { return combineCodec(getMissionProcessEncoder(), getMissionProcessDecoder()); } export function decodeMissionProcess( encodedAccount: EncodedAccount, ): Account; export function decodeMissionProcess( encodedAccount: MaybeEncodedAccount, ): MaybeAccount; export function decodeMissionProcess( encodedAccount: EncodedAccount | MaybeEncodedAccount, ): Account | MaybeAccount { return decodeAccount( encodedAccount as MaybeEncodedAccount, getMissionProcessDecoder(), ); } export async function fetchMissionProcess( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchMaybeMissionProcess(rpc, address, config); assertAccountExists(maybeAccount); return maybeAccount; } export async function fetchMaybeMissionProcess< TAddress extends string = string, >( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchEncodedAccount(rpc, address, config); return decodeMissionProcess(maybeAccount); } export async function fetchAllMissionProcess( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchAllMaybeMissionProcess( rpc, addresses, config, ); assertAccountsExist(maybeAccounts); return maybeAccounts; } export async function fetchAllMaybeMissionProcess( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); return maybeAccounts.map((maybeAccount) => decodeMissionProcess(maybeAccount), ); }