@aephia/atlas-kit 0.6.0-next.144 → 0.6.0-next.146

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 (47) hide show
  1. package/dist/claim-stakes/actions/index.d.ts +24 -0
  2. package/dist/claim-stakes/actions/index.d.ts.map +1 -1
  3. package/dist/claim-stakes/actions/index.js +108 -53
  4. package/dist/claim-stakes/actions/index.js.map +1 -1
  5. package/dist/fleets/actions/index.d.ts +6 -2
  6. package/dist/fleets/actions/index.d.ts.map +1 -1
  7. package/dist/fleets/actions/index.js +20 -4
  8. package/dist/fleets/actions/index.js.map +1 -1
  9. package/dist/internal/c4/claim-stake-storage.d.ts +45 -0
  10. package/dist/internal/c4/claim-stake-storage.d.ts.map +1 -0
  11. package/dist/internal/c4/claim-stake-storage.js +207 -0
  12. package/dist/internal/c4/claim-stake-storage.js.map +1 -0
  13. package/dist/internal/planning/claim-stake-storage-actions.d.ts +12 -0
  14. package/dist/internal/planning/claim-stake-storage-actions.d.ts.map +1 -0
  15. package/dist/internal/planning/claim-stake-storage-actions.js +63 -0
  16. package/dist/internal/planning/claim-stake-storage-actions.js.map +1 -0
  17. package/dist/internal/planning/currency-cache-guard.d.ts +3 -2
  18. package/dist/internal/planning/currency-cache-guard.d.ts.map +1 -1
  19. package/dist/internal/planning/currency-cache-guard.js +28 -3
  20. package/dist/internal/planning/currency-cache-guard.js.map +1 -1
  21. package/dist/internal/planning/plan-guards.d.ts.map +1 -1
  22. package/dist/internal/planning/plan-guards.js +6 -0
  23. package/dist/internal/planning/plan-guards.js.map +1 -1
  24. package/dist/internal/planning/profile-storage-funding-guard.d.ts +3 -2
  25. package/dist/internal/planning/profile-storage-funding-guard.d.ts.map +1 -1
  26. package/dist/internal/planning/profile-storage-funding-guard.js +61 -23
  27. package/dist/internal/planning/profile-storage-funding-guard.js.map +1 -1
  28. package/dist/internal/planning/region-access.d.ts +17 -0
  29. package/dist/internal/planning/region-access.d.ts.map +1 -1
  30. package/dist/internal/planning/region-access.js +69 -11
  31. package/dist/internal/planning/region-access.js.map +1 -1
  32. package/dist/internal/planning/storage-action-readers.d.ts.map +1 -1
  33. package/dist/internal/planning/storage-action-readers.js +13 -0
  34. package/dist/internal/planning/storage-action-readers.js.map +1 -1
  35. package/dist/internal/planning/storage-actions.d.ts +4 -0
  36. package/dist/internal/planning/storage-actions.d.ts.map +1 -1
  37. package/dist/internal/planning/storage-actions.js +2 -2
  38. package/dist/internal/planning/storage-actions.js.map +1 -1
  39. package/dist/planning/execution.d.ts.map +1 -1
  40. package/dist/planning/execution.js +13 -2
  41. package/dist/planning/execution.js.map +1 -1
  42. package/dist/planning/index.d.ts +16 -1
  43. package/dist/planning/index.d.ts.map +1 -1
  44. package/dist/planning/index.js +2 -2
  45. package/dist/planning/index.js.map +1 -1
  46. package/dist/planning/plan-construction.js +1 -1
  47. package/package.json +1 -1
@@ -242,6 +242,13 @@ interface FleetSnapshot extends Omit<ResolvedFleetAccountData, 'ownerProfile'> {
242
242
  * The new Claim Stake's rent settlement authority must not exist and stays
243
243
  * guarded absent until signing.
244
244
  *
245
+ * The program funds the new stake to its rent floor, the size it can reach
246
+ * once Deactivated with a cargo line for each resource it produces, and the
247
+ * Planet's claimed plot from the Profile vault with the signing key. The Plan
248
+ * bounds that debit; when it is positive the key must be Profile AUTH or hold
249
+ * `drainSolVault`, and the Profile needs that many lamports above its rent
250
+ * reserve. Execution checks again before signing.
251
+ *
245
252
  * @example
246
253
  * ```ts
247
254
  * declare const ctx: SageContext;
@@ -266,6 +273,11 @@ export declare function planPlaceClaimStake(ctx: SageContext, body: CelestialBod
266
273
  * the planner checks the fresh Starbase Player pod. Rent synchronization and
267
274
  * the final concurrent sequence race remain chain-authoritative.
268
275
  *
276
+ * Entering a design adds the design state and an entry for each building id
277
+ * the design does not yet hold. The program funds that growth, up to the
278
+ * stake's rent floor, from the Profile vault with the signing key; the Plan
279
+ * bounds the debit with the same key and balance checks as placement.
280
+ *
269
281
  * Requires Game 2 and its existing canonical Claim Stake XP ledger.
270
282
  * Missing XP state must be repaired outside this Plan; no accounts are created.
271
283
  *
@@ -290,6 +302,12 @@ export declare function planClaimStakeBuildingChanges(ctx: SageContext, stake: C
290
302
  * CurrencyCache, and a known positive rent balance. Rent timing and the final
291
303
  * crew/building validation remain chain-authoritative.
292
304
  *
305
+ * Finalization can draw Profile storage this Plan does not bound: a removed
306
+ * building's refund can open a Starbase Player cargo line, and a final layout
307
+ * that produces a new resource raises the stake's rent floor. The program
308
+ * funds both from the Profile vault with the signing key, so simulate before
309
+ * signing.
310
+ *
293
311
  * Requires Game 2 and its existing canonical Claim Stake XP ledger.
294
312
  * The Character XP budget and configuration must also be reconciled.
295
313
  * Missing XP state must be repaired outside this Plan; no accounts are created.
@@ -400,6 +418,12 @@ export declare function planTopUpClaimStakeRent(ctx: SageContext, stake: ClaimSt
400
418
  * chain remains authoritative for range, duration, permission bits, concurrent
401
419
  * state changes, and transfer arithmetic.
402
420
  *
421
+ * The Fleet stores the requested load and unload lines while the transfer
422
+ * runs. The program settles the Fleet and stake together: the stake's lamports
423
+ * above its rent floor fund the Fleet first and the Profile vault, with the
424
+ * signing key, funds the rest. The Plan bounds that debit with the same key and
425
+ * balance checks as placement.
426
+ *
403
427
  * Requires Game 2 and its existing canonical Claim Stake XP ledger.
404
428
  * Missing XP state must be repaired outside this Plan; no accounts are created.
405
429
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/claim-stakes/actions/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,KAAK,EAAc,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAuCtD,OAAO,EAKL,KAAK,wBAAwB,EAC7B,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAE7B,MAAM,4BAA4B,CAAC;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,OAAO,CAAC,IAAI,CAAC,CA4Pf;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,kCAAkC,CACtD,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE,kBAAkB,EACzB,KAAK,EAAE,yCAAyC,GAC/C,OAAO,CAAC,IAAI,CAAC,CAuNf"}
@@ -15,6 +15,9 @@ import { deriveProfileFactionAddress, profileFactionIdentityAccountDefinition, }
15
15
  import { deriveStarbasePlayerAddress, starbasePlayerAccountDefinition, } from '../../internal/c4/starbase.js';
16
16
  import { celestialBodyAccountDefinition, deriveCelestialBodyAddress, deriveStarSystemAddress, starSystemAccountDefinition, } from '../../internal/c4/world.js';
17
17
  import { resolveXpRuntime } from '../../internal/planning/xp-runtime.js';
18
+ import { readClaimStakeStorageAction } from '../../internal/planning/claim-stake-storage-actions.js';
19
+ import { RENT_ADDRESS } from '../../internal/planning/rent.js';
20
+ import { planStorageFunding } from '../../internal/planning/storage-actions.js';
18
21
  import { requireDisabledStakeRent, requireNewStakeRent, } from '../../internal/planning/rent-catalog.js';
19
22
  import { deriveStructureXpAccrualAddress } from '../../internal/c4/pda.js';
20
23
  import { requireProfileStarbasePlayer } from '../../internal/planning/starbase-player-owner.js';
@@ -268,6 +271,13 @@ function findHub(configuration, id, game) {
268
271
  * The new Claim Stake's rent settlement authority must not exist and stays
269
272
  * guarded absent until signing.
270
273
  *
274
+ * The program funds the new stake to its rent floor, the size it can reach
275
+ * once Deactivated with a cargo line for each resource it produces, and the
276
+ * Planet's claimed plot from the Profile vault with the signing key. The Plan
277
+ * bounds that debit; when it is positive the key must be Profile AUTH or hold
278
+ * `drainSolVault`, and the Profile needs that many lamports above its rent
279
+ * reserve. Execution checks again before signing.
280
+ *
271
281
  * @example
272
282
  * ```ts
273
283
  * declare const ctx: SageContext;
@@ -397,7 +407,24 @@ export async function planPlaceClaimStake(ctx, body, player, input) {
397
407
  fail(`Character ${character} has ${String(currentCharacter.atlasRaw)} raw ATLAS, below the ${String(placementFee)} raw placement fee plus ${String(rentDeposit)} raw initial rent. Add ATLAS or lower the rent, then retry.`, character);
398
408
  const profileFaction = await deriveProfileFactionAddress(options.authorization.profile);
399
409
  const currencyCache = await deriveCurrencyCache(game).then(([address]) => address);
400
- const description = `Place ${definition.name} on Planet ${body.name} (${body.address}) with bundled hub ${hub.name}, ${String(hub.neededCrew)} crew, a ${String(placementFee)} raw ATLAS placement fee and ${String(rentDeposit)} raw initial rent.`;
410
+ const instruction = adaptPlaceClaimStakeInstruction({
411
+ authorization: options.authorization,
412
+ celestialBody: body.address,
413
+ character,
414
+ claimStakeDefinitionId: definition.id,
415
+ claimStakeInstance: options.claimStake,
416
+ currencyCache,
417
+ game,
418
+ hubBuildingId: hub.id,
419
+ initialRentAmount: options.initialRentAmount ?? null,
420
+ profileFaction,
421
+ rentAuthority: rent.rentAuthority,
422
+ systemAndStarbasePlayerStarbasePlayer: player.address,
423
+ systemAndStarbasePlayerSystem: body.system.address,
424
+ });
425
+ // The new stake and the claimed plot are funded from the Profile vault.
426
+ const storage = await planClaimStakeStorage(ctx, instruction, options.authorization.profile, [freshGame.account, currentBodyAccount, currentSystemAccount], 'Claim Stake placement');
427
+ const description = `Place ${definition.name} on Planet ${body.name} (${body.address}) with bundled hub ${hub.name}, ${String(hub.neededCrew)} crew, a ${String(placementFee)} raw ATLAS placement fee and ${String(rentDeposit)} raw initial rent. ${storage.disclosure}`;
401
428
  return buildPlannerPlan({
402
429
  kind: 'claim-stakes.place',
403
430
  preconditions: [
@@ -410,31 +437,36 @@ export async function planPlaceClaimStake(ctx, body, player, input) {
410
437
  ])),
411
438
  accountAbsentPrecondition(options.claimStake, 'The caller-supplied Claim Stake signer address remains unallocated.'),
412
439
  ...rent.guards,
440
+ storage.guard,
413
441
  ],
414
442
  steps: [
415
443
  {
416
444
  describes: description,
417
- instruction: adaptPlaceClaimStakeInstruction({
418
- authorization: options.authorization,
419
- celestialBody: body.address,
420
- character,
421
- claimStakeDefinitionId: definition.id,
422
- claimStakeInstance: options.claimStake,
423
- currencyCache,
424
- game,
425
- hubBuildingId: hub.id,
426
- initialRentAmount: options.initialRentAmount ?? null,
427
- profileFaction,
428
- rentAuthority: rent.rentAuthority,
429
- systemAndStarbasePlayerStarbasePlayer: player.address,
430
- systemAndStarbasePlayerSystem: body.system.address,
431
- }),
445
+ instruction,
432
446
  signers: [options.authorization.authority, options.claimStake],
433
447
  },
434
448
  ],
435
449
  summary: description,
436
450
  });
437
451
  }
452
+ /** Plans a Claim Stake action's Profile storage funding from the fresh
453
+ * accounts the planner already read, plus the Profile and Rent sysvar. */
454
+ async function planClaimStakeStorage(ctx, instruction, profile, known, label) {
455
+ const [profileAccount, rentAccount] = await readContextRawAccounts(ctx, [
456
+ profile,
457
+ RENT_ADDRESS,
458
+ ]);
459
+ const accounts = new Map([
460
+ ...known.map((raw) => [raw.address, raw]),
461
+ [profile, profileAccount],
462
+ [RENT_ADDRESS, rentAccount],
463
+ ]);
464
+ return planStorageFunding({
465
+ action: readClaimStakeStorageAction(instruction, accounts),
466
+ accounts,
467
+ label,
468
+ });
469
+ }
438
470
  /** The ATLAS placement fee: the Planet's U32F32 base fee for the Starbase
439
471
  * level and tier, times the definition's U8F56 multiplier, rounded to the
440
472
  * nearest raw unit with halves rounded up. */
@@ -648,6 +680,11 @@ function buildingDescription(change, name) {
648
680
  * the planner checks the fresh Starbase Player pod. Rent synchronization and
649
681
  * the final concurrent sequence race remain chain-authoritative.
650
682
  *
683
+ * Entering a design adds the design state and an entry for each building id
684
+ * the design does not yet hold. The program funds that growth, up to the
685
+ * stake's rent floor, from the Profile vault with the signing key; the Plan
686
+ * bounds the debit with the same key and balance checks as placement.
687
+ *
651
688
  * Requires Game 2 and its existing canonical Claim Stake XP ledger.
652
689
  * Missing XP state must be repaired outside this Plan; no accounts are created.
653
690
  *
@@ -862,8 +899,25 @@ export async function planClaimStakeBuildingChanges(ctx, stake, input) {
862
899
  fail(`The resulting Claim Stake design provides ${String(resourceStorageRaw)} raw storage capacity, below the fresh known cargo usage of ${String(currentStake.production.cargoPod.storageCost)}. Keep enough storage buildings, remove cargo, refresh the Claim Stake, and retry building changes.`, stake.address);
863
900
  }
864
901
  const currencyCache = await claimStakeCurrencyCache(game);
865
- const description = `Change buildings on Claim Stake ${stake.address}: ${descriptions.join('; ')}.`;
866
902
  const xp = await resolveClaimStakeXp(ctx, game, stake.address);
903
+ const instruction = adaptClaimStakeBuildingChangesInstruction({
904
+ ...xp.accounts,
905
+ authorization: options.authorization,
906
+ buildingChanges: options.buildingChanges.map(({ buildingId, kind, quantity }) => [buildingId, kind === 'add' ? quantity : -quantity]),
907
+ celestialBody: stake.body.address,
908
+ claimStakeInstance: stake.address,
909
+ currencyCache,
910
+ factionOwnership: ownership,
911
+ game,
912
+ profileFaction,
913
+ ...rent.accounts,
914
+ sequenceId,
915
+ starbasePlayer: player,
916
+ system,
917
+ });
918
+ // The grown design is funded from the Profile vault.
919
+ const storage = await planClaimStakeStorage(ctx, instruction, profile, [stakeAccount], 'Claim Stake building changes');
920
+ const description = `Change buildings on Claim Stake ${stake.address}: ${descriptions.join('; ')}. ${storage.disclosure}`;
867
921
  return buildPlannerPlan({
868
922
  kind: 'claim-stakes.building-changes',
869
923
  preconditions: [
@@ -879,25 +933,12 @@ export async function planClaimStakeBuildingChanges(ctx, stake, input) {
879
933
  ownershipPrecondition,
880
934
  xp.guard,
881
935
  ...rent.guards,
936
+ storage.guard,
882
937
  ],
883
938
  steps: [
884
939
  {
885
940
  describes: description,
886
- instruction: adaptClaimStakeBuildingChangesInstruction({
887
- ...xp.accounts,
888
- authorization: options.authorization,
889
- buildingChanges: options.buildingChanges.map(({ buildingId, kind, quantity }) => [buildingId, kind === 'add' ? quantity : -quantity]),
890
- celestialBody: stake.body.address,
891
- claimStakeInstance: stake.address,
892
- currencyCache,
893
- factionOwnership: ownership,
894
- game,
895
- profileFaction,
896
- ...rent.accounts,
897
- sequenceId,
898
- starbasePlayer: player,
899
- system,
900
- }),
941
+ instruction,
901
942
  signers: [options.authorization.authority],
902
943
  },
903
944
  ],
@@ -911,6 +952,12 @@ export async function planClaimStakeBuildingChanges(ctx, stake, input) {
911
952
  * CurrencyCache, and a known positive rent balance. Rent timing and the final
912
953
  * crew/building validation remain chain-authoritative.
913
954
  *
955
+ * Finalization can draw Profile storage this Plan does not bound: a removed
956
+ * building's refund can open a Starbase Player cargo line, and a final layout
957
+ * that produces a new resource raises the stake's rent floor. The program
958
+ * funds both from the Profile vault with the signing key, so simulate before
959
+ * signing.
960
+ *
914
961
  * Requires Game 2 and its existing canonical Claim Stake XP ledger.
915
962
  * The Character XP budget and configuration must also be reconciled.
916
963
  * Missing XP state must be repaired outside this Plan; no accounts are created.
@@ -969,7 +1016,7 @@ export async function planFinalizeClaimStakeBuildingChanges(ctx, stake, input) {
969
1016
  const currencyCache = await claimStakeCurrencyCache(game);
970
1017
  const { currentSystem, extraAccounts: [currencyCandidate], player, playerAccount, systemAccount, } = await readStakeStarbase(ctx, stake, game, system, character, profile, action, [currencyCache]);
971
1018
  const currencyGuard = await requireCurrencyCache(currencyCandidate, currencyCache, game, action, 'Claim Stake finalization');
972
- const description = `Finalize building changes on Claim Stake ${stake.address}.`;
1019
+ const description = `Finalize building changes on Claim Stake ${stake.address}. A building refund that opens a Starbase Player cargo line, or a new resource that raises the stake's rent floor, is funded from the Profile vault with the signing key, which this Plan does not bound; simulate before signing.`;
973
1020
  const xp = await resolveClaimStakeXp(ctx, game, stake.address, character);
974
1021
  return buildPlannerPlan({
975
1022
  kind: 'claim-stakes.finalize-building-changes',
@@ -1368,6 +1415,12 @@ function describeCargoRequests(direction, requests) {
1368
1415
  * chain remains authoritative for range, duration, permission bits, concurrent
1369
1416
  * state changes, and transfer arithmetic.
1370
1417
  *
1418
+ * The Fleet stores the requested load and unload lines while the transfer
1419
+ * runs. The program settles the Fleet and stake together: the stake's lamports
1420
+ * above its rent floor fund the Fleet first and the Profile vault, with the
1421
+ * signing key, funds the rest. The Plan bounds that debit with the same key and
1422
+ * balance checks as placement.
1423
+ *
1371
1424
  * Requires Game 2 and its existing canonical Claim Stake XP ledger.
1372
1425
  * Missing XP state must be repaired outside this Plan; no accounts are created.
1373
1426
  *
@@ -1464,8 +1517,27 @@ export async function planStartClaimStakeFleetTransfer(ctx, fleet, stake, input)
1464
1517
  ...describeCargoRequests('load', options.load),
1465
1518
  ...describeCargoRequests('unload', options.unload),
1466
1519
  ];
1467
- const description = `Start fleet ${fleet.name}'s transfer to Claim Stake ${stake.address}: ${descriptions.join('; ')}. Loaded cargo, including Fuel and Ammunition, arrives in the Fleet cargo hold; unloads come from the cargo hold only. Range and transfer duration remain chain-authoritative.`;
1468
1520
  const xp = await resolveClaimStakeXp(ctx, game, stake.address);
1521
+ const instruction = adaptStartClaimStakeFleetTransferInstruction({
1522
+ ...xp.accounts,
1523
+ authorization: options.authorization,
1524
+ celestialBody: stake.body.address,
1525
+ character,
1526
+ claimStakeInstance: stake.address,
1527
+ ...(crewCandidate === undefined ? {} : { crewBinding }),
1528
+ currencyCache,
1529
+ fleet: fleet.address,
1530
+ game,
1531
+ ...rent.accounts,
1532
+ systemAndStarbasePlayerStarbasePlayer: player,
1533
+ systemAndStarbasePlayerSystem: system,
1534
+ toLoad: options.load.map(({ amount, cargoId }) => [cargoId, amount]),
1535
+ toUnload: options.unload.map(({ amount, cargoId }) => [cargoId, amount]),
1536
+ });
1537
+ // The Fleet's transfer state is funded first from the stake's surplus over
1538
+ // its rent floor, then from the Profile vault.
1539
+ const storage = await planClaimStakeStorage(ctx, instruction, profile, [fleetAccount, stakeAccount], 'Claim Stake Fleet transfer start');
1540
+ const description = `Start fleet ${fleet.name}'s transfer to Claim Stake ${stake.address}: ${descriptions.join('; ')}. Loaded cargo, including Fuel and Ammunition, arrives in the Fleet cargo hold; unloads come from the cargo hold only. Range and transfer duration remain chain-authoritative. ${storage.disclosure}`;
1469
1541
  return buildPlannerPlan({
1470
1542
  kind: 'claim-stakes.start-fleet-transfer',
1471
1543
  preconditions: [
@@ -1485,29 +1557,12 @@ export async function planStartClaimStakeFleetTransfer(ctx, fleet, stake, input)
1485
1557
  ])),
1486
1558
  currencyGuard,
1487
1559
  ...rent.guards,
1560
+ storage.guard,
1488
1561
  ],
1489
1562
  steps: [
1490
1563
  {
1491
1564
  describes: description,
1492
- instruction: adaptStartClaimStakeFleetTransferInstruction({
1493
- ...xp.accounts,
1494
- authorization: options.authorization,
1495
- celestialBody: stake.body.address,
1496
- character,
1497
- claimStakeInstance: stake.address,
1498
- ...(crewCandidate === undefined ? {} : { crewBinding }),
1499
- currencyCache,
1500
- fleet: fleet.address,
1501
- game,
1502
- ...rent.accounts,
1503
- systemAndStarbasePlayerStarbasePlayer: player,
1504
- systemAndStarbasePlayerSystem: system,
1505
- toLoad: options.load.map(({ amount, cargoId }) => [cargoId, amount]),
1506
- toUnload: options.unload.map(({ amount, cargoId }) => [
1507
- cargoId,
1508
- amount,
1509
- ]),
1510
- }),
1565
+ instruction,
1511
1566
  signers: [options.authorization.authority],
1512
1567
  },
1513
1568
  ],