@aephia/atlas-kit 0.6.0-next.36 → 0.6.0-next.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/dist/combat/actions/index.d.ts.map +1 -1
  2. package/dist/combat/actions/index.js +16 -3
  3. package/dist/combat/actions/index.js.map +1 -1
  4. package/dist/crafting/actions/index.d.ts.map +1 -1
  5. package/dist/crafting/actions/index.js +36 -13
  6. package/dist/crafting/actions/index.js.map +1 -1
  7. package/dist/fleets/actions/index.d.ts +24 -15
  8. package/dist/fleets/actions/index.d.ts.map +1 -1
  9. package/dist/fleets/actions/index.js +90 -49
  10. package/dist/fleets/actions/index.js.map +1 -1
  11. package/dist/internal/c4/character-registration.d.ts.map +1 -1
  12. package/dist/internal/c4/character-registration.js +2 -0
  13. package/dist/internal/c4/character-registration.js.map +1 -1
  14. package/dist/internal/c4/crafting-process-codec.d.ts +13 -0
  15. package/dist/internal/c4/crafting-process-codec.d.ts.map +1 -0
  16. package/dist/internal/c4/crafting-process-codec.js +34 -0
  17. package/dist/internal/c4/crafting-process-codec.js.map +1 -0
  18. package/dist/internal/c4/crafting.d.ts +10 -0
  19. package/dist/internal/c4/crafting.d.ts.map +1 -1
  20. package/dist/internal/c4/crafting.js +22 -5
  21. package/dist/internal/c4/crafting.js.map +1 -1
  22. package/dist/internal/c4/fleet-arrival.d.ts +27 -0
  23. package/dist/internal/c4/fleet-arrival.d.ts.map +1 -0
  24. package/dist/internal/c4/fleet-arrival.js +39 -0
  25. package/dist/internal/c4/fleet-arrival.js.map +1 -0
  26. package/dist/internal/c4/fleet-creation.js +1 -1
  27. package/dist/internal/c4/fleet-creation.js.map +1 -1
  28. package/dist/internal/c4/game.d.ts +2 -0
  29. package/dist/internal/c4/game.d.ts.map +1 -1
  30. package/dist/internal/c4/game.js +5 -0
  31. package/dist/internal/c4/game.js.map +1 -1
  32. package/dist/internal/c4/market.d.ts +1 -1
  33. package/dist/internal/c4/market.d.ts.map +1 -1
  34. package/dist/internal/c4/market.js +2 -0
  35. package/dist/internal/c4/market.js.map +1 -1
  36. package/dist/internal/c4/profile-permissions.d.ts +1 -1
  37. package/dist/internal/c4/profile-permissions.d.ts.map +1 -1
  38. package/dist/internal/c4/profile-permissions.js +1 -0
  39. package/dist/internal/c4/profile-permissions.js.map +1 -1
  40. package/dist/internal/c4/runtime-bindings.d.ts +3 -0
  41. package/dist/internal/c4/runtime-bindings.d.ts.map +1 -0
  42. package/dist/internal/c4/runtime-bindings.js +4 -0
  43. package/dist/internal/c4/runtime-bindings.js.map +1 -0
  44. package/dist/internal/c4/scanning.d.ts +1 -1
  45. package/dist/internal/c4/scanning.d.ts.map +1 -1
  46. package/dist/internal/c4/scanning.js +2 -0
  47. package/dist/internal/c4/scanning.js.map +1 -1
  48. package/dist/internal/c4/ship-stats.js +2 -2
  49. package/dist/internal/c4/ship-stats.js.map +1 -1
  50. package/dist/internal/planning/action-runtime.d.ts +38 -0
  51. package/dist/internal/planning/action-runtime.d.ts.map +1 -0
  52. package/dist/internal/planning/action-runtime.js +63 -0
  53. package/dist/internal/planning/action-runtime.js.map +1 -0
  54. package/dist/internal/planning/arrival-guards.d.ts +20 -0
  55. package/dist/internal/planning/arrival-guards.d.ts.map +1 -0
  56. package/dist/internal/planning/arrival-guards.js +231 -0
  57. package/dist/internal/planning/arrival-guards.js.map +1 -0
  58. package/dist/internal/planning/authorization-adapter.d.ts +2 -0
  59. package/dist/internal/planning/authorization-adapter.d.ts.map +1 -1
  60. package/dist/internal/planning/authorization-adapter.js +49 -0
  61. package/dist/internal/planning/authorization-adapter.js.map +1 -1
  62. package/dist/internal/planning/democracy-history.d.ts +51 -0
  63. package/dist/internal/planning/democracy-history.d.ts.map +1 -0
  64. package/dist/internal/planning/democracy-history.js +202 -0
  65. package/dist/internal/planning/democracy-history.js.map +1 -0
  66. package/dist/internal/planning/fleet-arrival.d.ts +49 -0
  67. package/dist/internal/planning/fleet-arrival.d.ts.map +1 -0
  68. package/dist/internal/planning/fleet-arrival.js +134 -0
  69. package/dist/internal/planning/fleet-arrival.js.map +1 -0
  70. package/dist/internal/planning/governance-fees.d.ts +64 -0
  71. package/dist/internal/planning/governance-fees.d.ts.map +1 -0
  72. package/dist/internal/planning/governance-fees.js +239 -0
  73. package/dist/internal/planning/governance-fees.js.map +1 -0
  74. package/dist/internal/planning/runtime-guards.d.ts +43 -0
  75. package/dist/internal/planning/runtime-guards.d.ts.map +1 -0
  76. package/dist/internal/planning/runtime-guards.js +552 -0
  77. package/dist/internal/planning/runtime-guards.js.map +1 -0
  78. package/dist/internal/planning/xp-runtime.d.ts +22 -0
  79. package/dist/internal/planning/xp-runtime.d.ts.map +1 -0
  80. package/dist/internal/planning/xp-runtime.js +102 -0
  81. package/dist/internal/planning/xp-runtime.js.map +1 -0
  82. package/dist/markets/actions/index.d.ts.map +1 -1
  83. package/dist/markets/actions/index.js +41 -16
  84. package/dist/markets/actions/index.js.map +1 -1
  85. package/dist/planning/assembly.d.ts.map +1 -1
  86. package/dist/planning/assembly.js +4 -0
  87. package/dist/planning/assembly.js.map +1 -1
  88. package/dist/planning/execution.d.ts.map +1 -1
  89. package/dist/planning/execution.js +34 -1
  90. package/dist/planning/execution.js.map +1 -1
  91. package/dist/planning/index.d.ts +28 -4
  92. package/dist/planning/index.d.ts.map +1 -1
  93. package/dist/planning/index.js +42 -12
  94. package/dist/planning/index.js.map +1 -1
  95. package/dist/registry/xp-runtime.d.ts +4 -0
  96. package/dist/registry/xp-runtime.d.ts.map +1 -0
  97. package/dist/registry/xp-runtime.js +14 -0
  98. package/dist/registry/xp-runtime.js.map +1 -0
  99. package/dist/scanning/index.d.ts +1 -1
  100. package/dist/scanning/index.d.ts.map +1 -1
  101. package/package.json +2 -2
@@ -0,0 +1,134 @@
1
+ import { SageSdkError } from '../../client/errors.js';
2
+ import { readContextRawAccounts } from '../../client/reconciliation.js';
3
+ import { decodeFleetArrival, } from '../c4/fleet-arrival.js';
4
+ import { findCharacterPda, characterAccountDefinition, profileAccountDefinition, } from '../c4/identity.js';
5
+ import { deriveRegionTrackerAddress, regionTrackerAccountDefinition, } from '../c4/factions.js';
6
+ import { PROFILE_SCOPE, SAGE_SCOPE } from '../c4/profile-permissions.js';
7
+ import { requireGameAddress } from '../game-context.js';
8
+ import { CLOCK_ADDRESS, readClock } from './faction-enrollment.js';
9
+ import { resolveXpRuntime } from './xp-runtime.js';
10
+ function fail(address, reason) {
11
+ throw new SageSdkError('ACTION_PRECONDITION_FAILED', `Arrival settlement ${reason}. Refresh the Fleet and prepare a new arrival Plan after completed travel.`, { address });
12
+ }
13
+ function required(raw, address) {
14
+ if (!raw || raw.address !== address || raw.executable)
15
+ fail(address, `requires the existing non-executable account ${address}`);
16
+ return raw;
17
+ }
18
+ /** Read fresh movement, chain time and direct authority without retaining signer data. */
19
+ export async function resolveFleetArrival(ctx, fleetAddress, options) {
20
+ const game = requireGameAddress(ctx);
21
+ const [fleetRaw, clockRaw] = await readContextRawAccounts(ctx, [
22
+ fleetAddress,
23
+ CLOCK_ADDRESS,
24
+ ]);
25
+ const fleet = await decodeFleetArrival(required(fleetRaw, fleetAddress));
26
+ if (fleet.game !== game || fleet.canonical !== fleetAddress)
27
+ fail(fleetAddress, 'requires the canonical Fleet for the configured Game');
28
+ const journey = fleet.journey;
29
+ if (!journey)
30
+ fail(fleetAddress, 'requires a travelling Fleet; Idle and other non-travel states have no arrival to settle');
31
+ const now = readClock(required(clockRaw, CLOCK_ADDRESS));
32
+ if (journey.kind === 'subwarp'
33
+ ? journey.duration < 0n
34
+ : journey.arrival < journey.departure)
35
+ fail(fleetAddress, 'found invalid journey timing');
36
+ if (now < journey.departure ||
37
+ (journey.kind === 'subwarp'
38
+ ? (now - journey.departure) * (1n << 56n) < journey.duration
39
+ : now < journey.arrival))
40
+ fail(fleetAddress, 'cannot stop an unfinished journey that has not yet arrived; wait for chain time to reach the destination or choose the separate intentional early-stop action');
41
+ const character = await findCharacterPda(fleet.profile, game);
42
+ // Only the authorized route consumes Character XP. Legacy funders must receive
43
+ // an authorization remedy even when the XP budget is missing.
44
+ const xp = await resolveXpRuntime(ctx, {
45
+ game,
46
+ ...(options.authorization ? { character } : {}),
47
+ });
48
+ if (xp.gameVersion === 2 && journey.kind === 'warp')
49
+ fail(fleetAddress, 'for Game version 2 warp is unsupported; wait for a separately supported warp settlement route');
50
+ if (xp.gameVersion === 2 && !options.authorization)
51
+ fail(fleetAddress, 'for this XP-era subwarp requires explicit Profile authorization; supply { authorization } rather than a funder');
52
+ if (xp.gameVersion === 0 && options.authorization)
53
+ fail(fleetAddress, 'on legacy Game version 0 requires an explicit funder; use the legacy { funder } route');
54
+ const regionTracker = options.authorization
55
+ ? await deriveRegionTrackerAddress(game)
56
+ : undefined;
57
+ const addresses = [
58
+ character,
59
+ ...(options.authorization ? [fleet.profile, regionTracker] : []),
60
+ ];
61
+ const accounts = await readContextRawAccounts(ctx, addresses);
62
+ const characterData = characterAccountDefinition.decode(required(accounts[0], character));
63
+ if (characterData.game !== game ||
64
+ characterData.playerProfile !== fleet.profile)
65
+ fail(character, 'requires the canonical Character for this Game and owning Profile');
66
+ let intent;
67
+ if (options.authorization) {
68
+ const authorization = options.authorization;
69
+ if (authorization.certificate !== undefined ||
70
+ authorization.profile !== fleet.profile ||
71
+ fleet.subProfile !== SAGE_SCOPE)
72
+ fail(fleetAddress, 'supports only the owning Profile and its direct key, without a certificate or delegated sub-Profile');
73
+ if (!Number.isInteger(authorization.keyIndex) ||
74
+ authorization.keyIndex < 0 ||
75
+ authorization.keyIndex > 65535)
76
+ fail(fleet.profile, 'requires a valid direct Profile key index');
77
+ const profile = profileAccountDefinition.decode(required(accounts[1], fleet.profile));
78
+ const key = profile.keys[authorization.keyIndex];
79
+ if (!key || key.address !== authorization.authority)
80
+ fail(fleet.profile, 'requires the current direct key index for the selected authority');
81
+ if (key.expiresAtRaw >= 0n && key.expiresAtRaw < now)
82
+ fail(fleet.profile, 'cannot use an expired Profile key; renew it or select an unexpired direct key');
83
+ if (!((key.scope === PROFILE_SCOPE && (key.permissionsRaw & 1n) !== 0n) ||
84
+ (key.scope === SAGE_SCOPE && (key.permissionsRaw & (1n << 10n)) !== 0n)))
85
+ fail(fleet.profile, 'requires direct Profile AUTH or SAGE moveFleet permission; select an appropriately scoped key');
86
+ const tracker = regionTrackerAccountDefinition.decode(required(accounts[2], regionTracker));
87
+ if (tracker.game !== game)
88
+ fail(regionTracker, 'requires the canonical RegionTracker bound to this Game');
89
+ intent = {
90
+ fleet: fleetAddress,
91
+ game,
92
+ profile: fleet.profile,
93
+ journey,
94
+ route: 'authorized',
95
+ authorization: {
96
+ profile: authorization.profile,
97
+ authority: authorization.authority,
98
+ keyIndex: authorization.keyIndex,
99
+ },
100
+ };
101
+ }
102
+ else
103
+ intent = {
104
+ fleet: fleetAddress,
105
+ game,
106
+ profile: fleet.profile,
107
+ journey,
108
+ route: 'legacy',
109
+ funder: options.funder,
110
+ };
111
+ return { intent, character, regionTracker, xp };
112
+ }
113
+ /** Recheck only the selected journey/authority, permitting unrelated Fleet and XP changes. */
114
+ export async function validateFleetArrivalIntent(ctx, intent) {
115
+ const current = await resolveFleetArrival(ctx, intent.fleet, intent.route === 'authorized'
116
+ ? { authorization: intent.authorization }
117
+ : { funder: intent.funder });
118
+ const a = intent.journey, b = current.intent.journey;
119
+ if (current.intent.game !== intent.game ||
120
+ current.intent.profile !== intent.profile ||
121
+ a.kind !== b.kind ||
122
+ a.departure !== b.departure ||
123
+ a.from.x !== b.from.x ||
124
+ a.from.y !== b.from.y ||
125
+ a.to.x !== b.to.x ||
126
+ a.to.y !== b.to.y ||
127
+ (a.kind === 'subwarp' &&
128
+ b.kind === 'subwarp' &&
129
+ a.duration !== b.duration) ||
130
+ (a.kind === 'warp' && b.kind === 'warp' && a.arrival !== b.arrival))
131
+ fail(intent.fleet, 'journey or ownership changed after planning');
132
+ return current;
133
+ }
134
+ //# sourceMappingURL=fleet-arrival.js.map
@@ -0,0 +1 @@
1
+ {"version":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AK,CAAC,CAAC,IAAI;QACjB,CAAC,CAAC,SAAS,KAAK,CAAC,CAAC,SAAS;QAC3B,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;QACjB,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;QACjB,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS;YACnB,CAAC,CAAC,IAAI,KAAK,SAAS;YACpB,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,QAAQ,CAAC;QAC5B,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,CAAC;QAEnE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,6CAA6C,CAAC,CAAC;IACpE,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,64 @@
1
+ import type { Address, SageContext } from '../../client/contracts.js';
2
+ import { type CraftingProcessAccountData } from '../c4/crafting.js';
3
+ import type { ResolvedDemocracyHistory } from './democracy-history.js';
4
+ export interface FeeRequest {
5
+ readonly game: Address;
6
+ readonly system: Address;
7
+ readonly starbaseSeqId: bigint;
8
+ readonly mode: 'market' | 'crafting-start' | 'crafting-complete';
9
+ readonly hasHab?: boolean;
10
+ readonly process?: Address;
11
+ }
12
+ export interface FeeParams {
13
+ readonly craftingFeeBps: number;
14
+ readonly localMarketFeeBps: number;
15
+ readonly localTreasuryShareBps: number;
16
+ readonly treasuryDistributionBps?: number;
17
+ }
18
+ export interface FeeIntent {
19
+ readonly request: FeeRequest;
20
+ readonly governance?: {
21
+ readonly address: Address;
22
+ readonly state: 'absent' | 'initialized';
23
+ readonly version?: number;
24
+ readonly enabled?: number;
25
+ readonly controllerFaction?: number;
26
+ readonly starbaseSeqId?: bigint;
27
+ readonly activeParams?: FeeParams;
28
+ };
29
+ readonly currencyCache?: {
30
+ readonly address: Address;
31
+ readonly version: number;
32
+ };
33
+ readonly treasury?: {
34
+ readonly address: Address;
35
+ readonly state: 'absent' | 'initialized';
36
+ readonly version?: number;
37
+ readonly governance?: Address;
38
+ };
39
+ readonly process?: {
40
+ readonly address: Address;
41
+ readonly version: number;
42
+ readonly feeRecipient?: 'atlas' | 'dao-atlas';
43
+ readonly feeGovernance?: Address;
44
+ readonly feeSnapshot?: CraftingProcessAccountData['feeSnapshot'];
45
+ };
46
+ readonly quote: {
47
+ readonly source: 'default' | 'governance' | 'history-policy' | 'history-generation' | 'history-disabled' | 'process-snapshot' | 'legacy-process';
48
+ readonly params?: FeeParams;
49
+ };
50
+ }
51
+ export interface ResolvedGovernanceFees {
52
+ readonly intent: FeeIntent;
53
+ readonly accounts: {
54
+ readonly starbaseGovernance?: Address;
55
+ readonly currencyCache?: Address;
56
+ readonly starbaseTreasury?: Address;
57
+ };
58
+ readonly description: string;
59
+ }
60
+ /** Resolve current fee accounts and a finite quote without creating or funding anything. */
61
+ export declare function resolveGovernanceFees(ctx: SageContext, request: FeeRequest, history: ResolvedDemocracyHistory): Promise<ResolvedGovernanceFees>;
62
+ /** Compare finite serialized fields; mutable shared balances are deliberately absent. */
63
+ export declare function matchGovernanceFeesIntent(expected: FeeIntent, actual: FeeIntent): boolean;
64
+ //# sourceMappingURL=governance-fees.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"governance-fees.d.ts","sourceRoot":"","sources":["../../../src/internal/planning/governance-fees.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,OAAO,EAEP,WAAW,EACZ,MAAM,2BAA2B,CAAC;AAiBnC,OAAO,EAEL,KAAK,0BAA0B,EAChC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK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ACD,yFAAyF;AACzF,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,SAAS,EACnB,MAAM,EAAE,SAAS,GAChB,OAAO,CAcT"}
@@ -0,0 +1,239 @@
1
+ import { getAddressEncoder, getProgramDerivedAddress, getU64Encoder, } from '@solana/kit';
2
+ import { SageSdkError } from '../../client/errors.js';
3
+ import { readContextRawAccounts } from '../../client/reconciliation.js';
4
+ import { CURRENCY_CONFIG_CACHE_DISCRIMINATOR, SAGE_PROGRAM_ADDRESS, STARBASE_GOVERNANCE_DISCRIMINATOR, STARBASE_TREASURY_DISCRIMINATOR, getCurrencyConfigCacheDecoder, getStarbaseGovernanceDecoder, getStarbaseTreasuryDecoder, } from '../c4/runtime-bindings.js';
5
+ import { deriveStarSystemAddress, starSystemAccountDefinition, } from '../c4/world.js';
6
+ import { craftingProcessAccountDefinition, } from '../c4/crafting.js';
7
+ function requireFee(condition, reason) {
8
+ if (!condition)
9
+ throw new SageSdkError('ACTION_PRECONDITION_FAILED', `${reason} Refresh the Starbase fee configuration and recreate this action; ask its operator to initialize missing fee-routing accounts.`);
10
+ }
11
+ async function derive(literal, scope, sequence) {
12
+ return getProgramDerivedAddress({
13
+ programAddress: SAGE_PROGRAM_ADDRESS,
14
+ seeds: [
15
+ new TextEncoder().encode(literal),
16
+ getAddressEncoder().encode(scope),
17
+ ...(sequence === undefined ? [] : [getU64Encoder().encode(sequence)]),
18
+ ],
19
+ });
20
+ }
21
+ function decode(raw, address, discriminator, decoder) {
22
+ requireFee(raw &&
23
+ raw.address === address &&
24
+ raw.owner === SAGE_PROGRAM_ADDRESS &&
25
+ !raw.executable, `Fee-routing account ${address} is missing or has an unexpected owner or address.`);
26
+ requireFee(discriminator.every((byte, index) => raw.data[index] === byte), `Fee-routing account ${address} has the wrong discriminator.`);
27
+ try {
28
+ const [value, consumed] = decoder.read(raw.data, 0);
29
+ requireFee(consumed === raw.data.length, `Fee-routing account ${address} has trailing bytes.`);
30
+ return value;
31
+ }
32
+ catch (cause) {
33
+ if (cause instanceof SageSdkError)
34
+ throw cause;
35
+ throw new SageSdkError('ACTION_PRECONDITION_FAILED', `Fee-routing account ${address} cannot be decoded. Refresh the deployment and recreate this action with supported account data.`);
36
+ }
37
+ }
38
+ function params(value) {
39
+ return {
40
+ craftingFeeBps: value.craftingFeeBps,
41
+ localMarketFeeBps: value.localMarketFeeBps,
42
+ localTreasuryShareBps: value.localTreasuryShareBps,
43
+ treasuryDistributionBps: value.treasuryDistributionBps,
44
+ };
45
+ }
46
+ function description(intent) {
47
+ const quote = intent.quote;
48
+ if (!quote.params)
49
+ return 'Legacy Crafting Process has no captured governance fee snapshot. No governed fee amount or recipient is inferred from synthetic defaults.';
50
+ const value = quote.params;
51
+ return `Fee policy source: ${quote.source}. Recipe fee multiplier: ${value.craftingFeeBps} basis points (10,000 = 1×); Local Market fee: ${value.localMarketFeeBps} basis points of executed ATLAS value; local Treasury share: ${value.localTreasuryShareBps} basis points of governed fees.${intent.process?.feeRecipient ? ` Captured original recipe recipient: ${intent.process.feeRecipient}.` : ''}${intent.treasury?.state === 'initialized' ? ` Treasury: ${intent.treasury.address}.` : ''} These rates do not predict an executed debit and can race a policy change after validation.`;
52
+ }
53
+ /** Resolve current fee accounts and a finite quote without creating or funding anything. */
54
+ export async function resolveGovernanceFees(ctx, request, history) {
55
+ requireFee(history.intent.game === request.game &&
56
+ history.intent.system === request.system, 'Fee and history scopes do not match.');
57
+ requireFee(request.mode === 'crafting-complete'
58
+ ? request.process !== undefined
59
+ : request.process === undefined, 'The fee route has an invalid Crafting Process selection.');
60
+ const [governanceAddress, governanceBump] = await derive('StarbaseGovernance', request.system, request.starbaseSeqId);
61
+ const [cacheAddress, cacheBump] = await derive('CurrencyConfig', request.game);
62
+ const needsCache = request.mode !== 'crafting-start' || request.hasHab === true;
63
+ const firstAddresses = request.mode === 'crafting-complete'
64
+ ? [request.process, cacheAddress]
65
+ : [
66
+ governanceAddress,
67
+ ...(needsCache ? [cacheAddress] : []),
68
+ request.system,
69
+ ];
70
+ const read = async (addresses) => {
71
+ const rows = await readContextRawAccounts(ctx, addresses, {
72
+ commitment: 'confirmed',
73
+ });
74
+ requireFee(rows.length === addresses.length &&
75
+ rows.every((raw, index) => !raw ||
76
+ (raw.address === addresses[index] && raw.slot >= history.slot)), 'Fee-routing reads are incomplete or older than their history context.');
77
+ return rows;
78
+ };
79
+ const rows = await read(firstAddresses);
80
+ if (request.mode !== 'crafting-complete') {
81
+ const raw = rows[rows.length - 1];
82
+ requireFee(raw && !raw.executable, 'The fee route System account is missing or invalid.');
83
+ const system = starSystemAccountDefinition.decode(raw);
84
+ const canonical = await deriveStarSystemAddress(request.game, system.systemId);
85
+ requireFee(raw.address === request.system &&
86
+ canonical === request.system &&
87
+ system.game === request.game &&
88
+ system.sequenceId === request.starbaseSeqId &&
89
+ system.starbase !== undefined, 'The fee route System does not match its canonical address, Game or active Starbase sequence.');
90
+ }
91
+ let currencyCache;
92
+ if (needsCache) {
93
+ const value = decode(rows[1], cacheAddress, CURRENCY_CONFIG_CACHE_DISCRIMINATOR, getCurrencyConfigCacheDecoder());
94
+ requireFee(value.gameId === request.game && value.bump === cacheBump, 'CurrencyCache does not match the configured Game or canonical PDA bump.');
95
+ currencyCache = { address: cacheAddress, version: value.version };
96
+ }
97
+ let governance;
98
+ let process;
99
+ let quote;
100
+ let treasuryGovernance;
101
+ let treasuryRequired = false;
102
+ if (request.mode === 'crafting-complete') {
103
+ const raw = rows[0];
104
+ requireFee(raw && raw.address === request.process && !raw.executable, 'The selected Crafting Process is missing or invalid.');
105
+ const value = craftingProcessAccountDefinition.decode(raw);
106
+ requireFee(value.system === request.system &&
107
+ value.starbaseSequenceId === request.starbaseSeqId, 'The Crafting Process belongs to a different System or Starbase generation.');
108
+ process = {
109
+ address: request.process,
110
+ version: value.version,
111
+ ...(value.feeRecipient === undefined
112
+ ? {}
113
+ : { feeRecipient: value.feeRecipient }),
114
+ ...(value.feeGovernance === undefined
115
+ ? {}
116
+ : { feeGovernance: value.feeGovernance }),
117
+ ...(value.feeSnapshot === undefined
118
+ ? {}
119
+ : { feeSnapshot: value.feeSnapshot }),
120
+ };
121
+ quote = value.feeSnapshot
122
+ ? {
123
+ source: 'process-snapshot',
124
+ params: {
125
+ craftingFeeBps: value.feeSnapshot.craftingFeeBasisPoints,
126
+ localMarketFeeBps: value.feeSnapshot.localMarketFeeBasisPoints,
127
+ localTreasuryShareBps: value.feeSnapshot.localTreasuryShareBasisPoints,
128
+ },
129
+ }
130
+ : { source: 'legacy-process' };
131
+ treasuryGovernance = value.feeGovernance;
132
+ treasuryRequired = treasuryGovernance !== undefined;
133
+ }
134
+ else {
135
+ const raw = rows[0];
136
+ const value = raw
137
+ ? decode(raw, governanceAddress, STARBASE_GOVERNANCE_DISCRIMINATOR, getStarbaseGovernanceDecoder())
138
+ : undefined;
139
+ if (value) {
140
+ requireFee(value.version === 2 || value.version === 3, 'Starbase governance has an unsupported schema version.');
141
+ requireFee(value.gameId === request.game &&
142
+ value.system === request.system &&
143
+ value.starbaseSeqId === request.starbaseSeqId &&
144
+ value.bump === governanceBump &&
145
+ value.enabled <= 1, 'Starbase governance has invalid scope, sequence, bump or enabled state.');
146
+ requireFee(!(value.version === 3 && history.intent.state === 'absent'), 'This Starbase governance requires initialized daily Democracy history.');
147
+ governance = {
148
+ address: governanceAddress,
149
+ state: 'initialized',
150
+ version: value.version,
151
+ enabled: value.enabled,
152
+ controllerFaction: value.controllerFaction,
153
+ starbaseSeqId: value.starbaseSeqId,
154
+ ...(history.intent.state === 'absent' && value.enabled === 1
155
+ ? { activeParams: params(value.activeParams) }
156
+ : {}),
157
+ };
158
+ }
159
+ else
160
+ governance = { address: governanceAddress, state: 'absent' };
161
+ if (history.intent.state === 'initialized')
162
+ quote = {
163
+ source: history.intent.enabled === 0
164
+ ? 'history-disabled'
165
+ : history.intent.generation
166
+ ? 'history-generation'
167
+ : 'history-policy',
168
+ params: params(history.intent.effectiveParams),
169
+ };
170
+ else if (value?.enabled)
171
+ quote = { source: 'governance', params: params(value.activeParams) };
172
+ else
173
+ quote = {
174
+ source: 'default',
175
+ params: {
176
+ craftingFeeBps: 10000,
177
+ localMarketFeeBps: 0,
178
+ localTreasuryShareBps: 0,
179
+ treasuryDistributionBps: 0,
180
+ },
181
+ };
182
+ if (request.mode === 'market') {
183
+ treasuryGovernance = governanceAddress;
184
+ treasuryRequired = quote.params.localTreasuryShareBps > 0;
185
+ }
186
+ }
187
+ let treasury;
188
+ if (treasuryGovernance) {
189
+ const [treasuryAddress, treasuryBump] = await derive('StarbaseTreasury', treasuryGovernance);
190
+ const [raw] = await read([treasuryAddress]);
191
+ if (raw) {
192
+ const value = decode(raw, treasuryAddress, STARBASE_TREASURY_DISCRIMINATOR, getStarbaseTreasuryDecoder());
193
+ requireFee(value.governance === treasuryGovernance &&
194
+ value.bump === treasuryBump &&
195
+ (request.mode !== 'market' || governance?.state === 'initialized'), 'Starbase Treasury does not match its governance or canonical PDA.');
196
+ treasury = {
197
+ address: treasuryAddress,
198
+ state: 'initialized',
199
+ version: value.version,
200
+ governance: value.governance,
201
+ };
202
+ }
203
+ else {
204
+ requireFee(!treasuryRequired, 'This fee route requires a Starbase Treasury that has not been initialized.');
205
+ treasury = { address: treasuryAddress, state: 'absent' };
206
+ }
207
+ }
208
+ const intent = {
209
+ request: { ...request },
210
+ ...(governance ? { governance } : {}),
211
+ ...(currencyCache ? { currencyCache } : {}),
212
+ ...(treasury ? { treasury } : {}),
213
+ ...(process ? { process } : {}),
214
+ quote,
215
+ };
216
+ return {
217
+ intent,
218
+ accounts: {
219
+ ...(request.mode === 'crafting-complete'
220
+ ? {}
221
+ : { starbaseGovernance: governanceAddress }),
222
+ ...(currencyCache ? { currencyCache: cacheAddress } : {}),
223
+ ...(treasury?.state === 'initialized'
224
+ ? { starbaseTreasury: treasury.address }
225
+ : {}),
226
+ },
227
+ description: description(intent),
228
+ };
229
+ }
230
+ /** Compare finite serialized fields; mutable shared balances are deliberately absent. */
231
+ export function matchGovernanceFeesIntent(expected, actual) {
232
+ const canonical = (value) => JSON.stringify(value, (_key, field) => typeof field === 'bigint'
233
+ ? field.toString()
234
+ : field && typeof field === 'object' && !Array.isArray(field)
235
+ ? Object.fromEntries(Object.entries(field).sort(([left], [right]) => left.localeCompare(right)))
236
+ : field);
237
+ return canonical(expected) === canonical(actual);
238
+ }
239
+ //# sourceMappingURL=governance-fees.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"governance-fees.js","sourceRoot":"","sources":["../../../src/internal/planning/governance-fees.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,aAAa,GAGd,MAAM,aAAa,CAAC;AAMrB,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EACL,mCAAmC,EAEnC,oBAAoB,EACpB,iCAAiC,EACjC,+BAA+B,EAC/B,6BAA6B,EAC7B,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,uBAAuB,EACvB,2BAA2B,GAC5B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,gCAAgC,GAEjC,MAAM,mBAAmB,CAAC;AAkE3B,SAAS,UAAU,CAAC,SAAkB,EAAE,MAAc;IACpD,IAAI,CAAC,SAAS;QACZ,MAAM,IAAI,YAAY,CACpB,4BAA4B,EAC5B,GAAG,MAAM,gIAAgI,CAC1I,CAAC;AACN,CAAC;AACD,KAAK,UAAU,MAAM,CAAC,OAAe,EAAE,KAAc,EAAE,QAAiB;IACtE,OAAO,wBAAwB,CAAC;QAC9B,cAAc,EAAE,oBAAoB;QACpC,KAAK,EAAE;YACL,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC;YACjC,iBAAiB,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC;YACjC,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,E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BACnC,CAAC,CAAC,EAAE,gBAAgB,EAAE,QAAQ,CAAC,OAAO,EAAE;gBACxC,CAAC,CAAC,EAAE,CAAC;SACR;QACD,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC;KACjC,CAAC;AACJ,CAAC;AACD,yFAAyF;AACzF,MAAM,UAAU,yBAAyB,CACvC,QAAmB,EACnB,MAAiB;IAEjB,MAAM,SAAS,GAAG,CAAC,KAAc,EAAU,EAAE,CAC3C,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,KAAc,EAAE,EAAE,CAC7C,OAAO,KAAK,KAAK,QAAQ;QACvB,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE;QAClB,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YAC3D,CAAC,CAAC,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,CAC7C,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAC1B,CACF;YACH,CAAC,CAAC,KAAK,CACZ,CAAC;IACJ,OAAO,SAAS,CAAC,QAAQ,CAAC,KAAK,SAAS,CAAC,MAAM,CAAC,CAAC;AACnD,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { type Address } from '@solana/kit';
2
+ import type { SageContext } from '../../client/contracts.js';
3
+ import type { PlanPrecondition, PlanStep } from '../../planning/index.js';
4
+ import { type HistoryIntent, type ResolvedDemocracyHistory } from './democracy-history.js';
5
+ import { type XpRuntimeIntent, type XpRuntimeAccounts } from './xp-runtime.js';
6
+ import { resolveGovernanceFees, type FeeIntent } from './governance-fees.js';
7
+ type FeeAccounts = Awaited<ReturnType<typeof resolveGovernanceFees>>['accounts'];
8
+ type BaseGuard = {
9
+ readonly address: Address;
10
+ readonly describes: string;
11
+ readonly dataHash?: never;
12
+ };
13
+ /** Finite runtime eligibility and consumed fee routes, excluding changing balances. */
14
+ export type RuntimeGuard = BaseGuard & ({
15
+ readonly kind: 'democracy-history';
16
+ readonly intent: HistoryIntent;
17
+ readonly accounts: ResolvedDemocracyHistory['accounts'];
18
+ } | {
19
+ readonly kind: 'xp-runtime';
20
+ readonly intent: XpRuntimeIntent;
21
+ readonly accounts: XpRuntimeAccounts;
22
+ } | {
23
+ readonly kind: 'governance-fees';
24
+ readonly intent: FeeIntent;
25
+ readonly accounts: FeeAccounts;
26
+ });
27
+ export type RuntimeWire<T> = T extends bigint ? string : T extends Address ? string : T extends object ? {
28
+ readonly [K in keyof T]: RuntimeWire<T[K]>;
29
+ } : T;
30
+ export type RuntimeGuardJson = RuntimeWire<RuntimeGuard>;
31
+ export declare function isRuntimeGuard(value: {
32
+ readonly kind?: unknown;
33
+ }): value is RuntimeGuard;
34
+ /** Strict nested runtime parsing applies both to factory values and persisted JSON. */
35
+ export declare function normalizeRuntimeGuard(value: unknown, field: string, wire?: boolean): RuntimeGuard;
36
+ /** Bigints use canonical decimal strings; schema validation excludes arbitrary object graphs. */
37
+ export declare function runtimeGuardToJSON(guard: RuntimeGuard): RuntimeGuardJson;
38
+ /** Resolve canonical accounts again; shared balances and XP counters are not compared. */
39
+ export declare function revalidateRuntimeGuards(ctx: SageContext, guards: readonly RuntimeGuard[]): Promise<void>;
40
+ /** Old layouts and unguarded persisted instructions fail before assembly or signing. */
41
+ export declare function validateRuntimeInstructions(steps: readonly PlanStep[], preconditions: readonly PlanPrecondition[]): void;
42
+ export {};
43
+ //# sourceMappingURL=runtime-guards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-guards.d.ts","sourceRoot":"","sources":["../../../src/internal/planning/runtime-guards.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,OAAO,EAGb,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2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