@aephia/atlas-kit 0.8.0-next.26 → 0.8.0-next.28
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.
- package/dist/claim-stakes/actions/index.d.ts +89 -0
- package/dist/claim-stakes/actions/index.d.ts.map +1 -1
- package/dist/claim-stakes/actions/index.js +290 -2
- package/dist/claim-stakes/actions/index.js.map +1 -1
- package/dist/claim-stakes/index.d.ts +1 -1
- package/dist/claim-stakes/index.d.ts.map +1 -1
- package/dist/claim-stakes/index.js +1 -1
- package/dist/claim-stakes/index.js.map +1 -1
- package/dist/crafting/actions/habs.d.ts +47 -0
- package/dist/crafting/actions/habs.d.ts.map +1 -1
- package/dist/crafting/actions/habs.js +101 -2
- package/dist/crafting/actions/habs.js.map +1 -1
- package/dist/crafting/actions/index.d.ts +1 -1
- package/dist/crafting/actions/index.d.ts.map +1 -1
- package/dist/crafting/actions/index.js +1 -1
- package/dist/crafting/actions/index.js.map +1 -1
- package/dist/crafting/index.d.ts +1 -1
- package/dist/crafting/index.d.ts.map +1 -1
- package/dist/crafting/index.js +1 -1
- package/dist/crafting/index.js.map +1 -1
- package/dist/internal/c4/claim-stake.d.ts +8 -0
- package/dist/internal/c4/claim-stake.d.ts.map +1 -1
- package/dist/internal/c4/claim-stake.js +5 -0
- package/dist/internal/c4/claim-stake.js.map +1 -1
- package/dist/internal/c4/crafting.d.ts +8 -0
- package/dist/internal/c4/crafting.d.ts.map +1 -1
- package/dist/internal/c4/crafting.js +5 -0
- package/dist/internal/c4/crafting.js.map +1 -1
- package/dist/internal/c4/discriminators.d.ts +3 -0
- package/dist/internal/c4/discriminators.d.ts.map +1 -1
- package/dist/internal/c4/discriminators.js +7 -1
- package/dist/internal/c4/discriminators.js.map +1 -1
- package/dist/internal/c4/runtime-bindings.d.ts +1 -1
- package/dist/internal/c4/runtime-bindings.d.ts.map +1 -1
- package/dist/internal/c4/runtime-bindings.js +1 -1
- package/dist/internal/c4/runtime-bindings.js.map +1 -1
- package/dist/internal/planning/authorization-adapter.d.ts +46 -0
- package/dist/internal/planning/authorization-adapter.d.ts.map +1 -1
- package/dist/internal/planning/authorization-adapter.js +68 -1
- package/dist/internal/planning/authorization-adapter.js.map +1 -1
- package/dist/internal/planning/building-xp.d.ts +50 -0
- package/dist/internal/planning/building-xp.d.ts.map +1 -0
- package/dist/internal/planning/building-xp.js +166 -0
- package/dist/internal/planning/building-xp.js.map +1 -0
- package/dist/internal/planning/currency-cache-guard.d.ts.map +1 -1
- package/dist/internal/planning/currency-cache-guard.js +4 -1
- package/dist/internal/planning/currency-cache-guard.js.map +1 -1
- package/dist/internal/planning/plan-guards.d.ts.map +1 -1
- package/dist/internal/planning/plan-guards.js +1 -0
- package/dist/internal/planning/plan-guards.js.map +1 -1
- package/dist/internal/planning/rent-catalog.d.ts.map +1 -1
- package/dist/internal/planning/rent-catalog.js +19 -1
- package/dist/internal/planning/rent-catalog.js.map +1 -1
- package/dist/internal/planning/runtime-guards.d.ts.map +1 -1
- package/dist/internal/planning/runtime-guards.js +37 -10
- package/dist/internal/planning/runtime-guards.js.map +1 -1
- package/dist/planning/execution.d.ts.map +1 -1
- package/dist/planning/execution.js +14 -0
- package/dist/planning/execution.js.map +1 -1
- package/dist/planning/index.d.ts +11 -0
- package/dist/planning/index.d.ts.map +1 -1
- package/dist/planning/index.js.map +1 -1
- package/dist/planning/plan-validation.d.ts.map +1 -1
- package/dist/planning/plan-validation.js +4 -0
- package/dist/planning/plan-validation.js.map +1 -1
- package/package.json +1 -1
|
@@ -169,6 +169,17 @@ export interface PlanTopUpClaimStakeRentOptions {
|
|
|
169
169
|
readonly amount: bigint;
|
|
170
170
|
readonly authorization: PlanAuthorization;
|
|
171
171
|
}
|
|
172
|
+
/** Exact inputs for settling one owned Claim Stake's Building XP.
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```ts
|
|
176
|
+
* declare const authorization: PlanAuthorization;
|
|
177
|
+
* const options: PlanSettleClaimStakeBuildingXpOptions = { authorization };
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
export interface PlanSettleClaimStakeBuildingXpOptions {
|
|
181
|
+
readonly authorization: PlanAuthorization;
|
|
182
|
+
}
|
|
172
183
|
/** One exact raw cargo request for starting a Claim Stake Fleet transfer.
|
|
173
184
|
*
|
|
174
185
|
* @example
|
|
@@ -243,6 +254,17 @@ export interface PlanExitClaimStakeFleetTransferOptions {
|
|
|
243
254
|
readonly atUnixSeconds: bigint;
|
|
244
255
|
readonly funder: Address;
|
|
245
256
|
}
|
|
257
|
+
/** Options for {@link planSettleClaimStakeProduction}. The `funder` is the
|
|
258
|
+
* only signer; any wallet may bring any Claim Stake's production up to date.
|
|
259
|
+
* @example
|
|
260
|
+
* ```ts
|
|
261
|
+
* declare const funder: Address;
|
|
262
|
+
* const options: PlanSettleClaimStakeProductionOptions = { funder };
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
export interface PlanSettleClaimStakeProductionOptions {
|
|
266
|
+
readonly funder: Address;
|
|
267
|
+
}
|
|
246
268
|
interface FleetSnapshot extends Omit<ResolvedFleetAccountData, 'ownerProfile'> {
|
|
247
269
|
readonly kind: 'fleet';
|
|
248
270
|
readonly address: Address;
|
|
@@ -453,6 +475,35 @@ export declare function planDeconstructClaimStake(ctx: SageContext, stake: Claim
|
|
|
453
475
|
* ```
|
|
454
476
|
*/
|
|
455
477
|
export declare function planTopUpClaimStakeRent(ctx: SageContext, stake: ClaimStakeSnapshot, input: PlanTopUpClaimStakeRentOptions): Promise<Plan>;
|
|
478
|
+
/** Plans settling the Building XP one owned Claim Stake has earned.
|
|
479
|
+
*
|
|
480
|
+
* The game first brings the stake's rent and production up to date, which
|
|
481
|
+
* records any further paid operational time, then pays its recorded
|
|
482
|
+
* operational work to the owner's Character as Building XP, up to the
|
|
483
|
+
* Character's remaining Building allowance, and awards any claim Mining XP the
|
|
484
|
+
* stake recorded. Work beyond the allowance is discarded rather than carried,
|
|
485
|
+
* so the planner refuses while the allowance is empty, and it refuses a stake
|
|
486
|
+
* that has recorded no work and is not operational. The Plan states the
|
|
487
|
+
* recorded XP and the allowance; the exact grant remains chain-authoritative.
|
|
488
|
+
*
|
|
489
|
+
* Requires Disabled rent, the stake's current System generation and the
|
|
490
|
+
* Profile's Starbase Player there from the current Starbase.
|
|
491
|
+
* Bringing a large structure up to date can take more than the default
|
|
492
|
+
* 200,000 compute units, so simulate first and raise `computeUnitLimit` when
|
|
493
|
+
* assembling if needed.
|
|
494
|
+
*
|
|
495
|
+
* @example
|
|
496
|
+
* ```ts
|
|
497
|
+
* declare const ctx: SageContext;
|
|
498
|
+
* declare const stake: ClaimStakeSnapshot;
|
|
499
|
+
* declare const authorization: PlanAuthorization;
|
|
500
|
+
* const plan = await planSettleClaimStakeBuildingXp(ctx, stake, {
|
|
501
|
+
* authorization,
|
|
502
|
+
* });
|
|
503
|
+
* console.log(plan.describe());
|
|
504
|
+
* ```
|
|
505
|
+
*/
|
|
506
|
+
export declare function planSettleClaimStakeBuildingXp(ctx: SageContext, stake: ClaimStakeSnapshot, input: PlanSettleClaimStakeBuildingXpOptions): Promise<Plan>;
|
|
456
507
|
/** Plans the start of one Fleet transfer to an owned active Claim Stake.
|
|
457
508
|
*
|
|
458
509
|
* The planner validates the shared Profile/Game, idle Fleet with normalized
|
|
@@ -580,4 +631,42 @@ export declare function planRecoverClaimStakeFleetTransfer(ctx: SageContext, fle
|
|
|
580
631
|
* ```
|
|
581
632
|
*/
|
|
582
633
|
export declare function planExitClaimStakeFleetTransfer(ctx: SageContext, fleet: FleetSnapshot, stake: ClaimStakeSnapshot, input: PlanExitClaimStakeFleetTransferOptions): Promise<Plan>;
|
|
634
|
+
/** Plans bringing one Claim Stake's production up to date.
|
|
635
|
+
*
|
|
636
|
+
* Production is permissionless: any wallet may tick any Claim Stake, so the
|
|
637
|
+
* Plan's only signer is the `funder`, which pays any growth of the stake's
|
|
638
|
+
* account. Rent the stake frees goes to its owner Profile. The game pays the
|
|
639
|
+
* stake's rent up to now, then produces from its last tick to now: each
|
|
640
|
+
* Building's processors turn their inputs into outputs at the stake's net
|
|
641
|
+
* rates, a processor that runs short of an input pauses, and output stops at
|
|
642
|
+
* the stake's storage, with Fuel limited to its separate fuel storage. The
|
|
643
|
+
* tick also records paid operational Building work and claim Mining work for
|
|
644
|
+
* a later {@link planSettleClaimStakeBuildingXp}.
|
|
645
|
+
*
|
|
646
|
+
* The planner refuses what the game would refuse: a stake in design, a
|
|
647
|
+
* Deactivated stake past its eviction grace, a stake its Planet does not
|
|
648
|
+
* register or has evicted, a Starbase Player from an earlier Starbase, and a
|
|
649
|
+
* stake whose rent balance does not cover the time up to now, which the game
|
|
650
|
+
* would deactivate instead. A Deactivated stake whose topped-up balance covers
|
|
651
|
+
* the time up to now is reactivated, then produces. It also refuses a stake
|
|
652
|
+
* still under construction or already up to date, which would produce
|
|
653
|
+
* nothing. The description projects the elapsed time, the approximate amounts
|
|
654
|
+
* at the stored net rates, storage, and the rent paid-through time; exact
|
|
655
|
+
* amounts, processor pauses and whether the Planet allows harvesting remain
|
|
656
|
+
* chain-authoritative.
|
|
657
|
+
*
|
|
658
|
+
* Requires Disabled rent and the current System generation. Bringing a large
|
|
659
|
+
* stake up to date can take more than the default 200,000 compute units, so
|
|
660
|
+
* simulate first and raise `computeUnitLimit` when assembling if needed.
|
|
661
|
+
*
|
|
662
|
+
* @example
|
|
663
|
+
* ```ts
|
|
664
|
+
* declare const ctx: SageContext;
|
|
665
|
+
* declare const stake: ClaimStakeSnapshot;
|
|
666
|
+
* declare const funder: Address;
|
|
667
|
+
* const plan = await planSettleClaimStakeProduction(ctx, stake, { funder });
|
|
668
|
+
* console.log(plan.describe());
|
|
669
|
+
* ```
|
|
670
|
+
*/
|
|
671
|
+
export declare function planSettleClaimStakeProduction(ctx: SageContext, stake: ClaimStakeSnapshot, input: PlanSettleClaimStakeProductionOptions): Promise<Plan>;
|
|
583
672
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/claim-stakes/actions/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,OAAO,EAAoB,MAAM,aAAa,CAAC;AAExE,OAAO,KAAK,EAEV,WAAW,EAEZ,MAAM,2BAA2B,CAAC;AAGnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AA6CtD,OAAO,EAKL,KAAK,wBAAwB,EAC7B,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAE7B,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/claim-stakes/actions/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,OAAO,EAAoB,MAAM,aAAa,CAAC;AAExE,OAAO,KAAK,EAEV,WAAW,EAEZ,MAAM,2BAA2B,CAAC;AAGnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AA6CtD,OAAO,EAKL,KAAK,wBAAwB,EAC7B,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAE7B,MAAM,4BAA4B,CAAC;AAwBpC,OAAO,EAaL,KAAK,iBAAiB,EACvB,MAAM,kDAAkD,CAAC;AAC1D,OAAO,KAAK,EAAE,IAAI,EAAoB,MAAM,yBAAyB,CAAC;AAEtE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAWxE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAMtD,YAAY,EAAE,iBAAiB,EAAE,CAAC;AAwBlC,UAAU,aAAa;IACrB,QAAQ,CAAC,eAAe,EAAE,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC;IACzD,QAAQ,CAAC,sBAAsB,EAAE,SAAS,CAAC,SAAS,eAAe,EAAE,CAAC,EAAE,CAAC;IACzE,QAAQ,CAAC,0BAA0B,EAAE,SA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O,CAAC,IAAI,CAAC,CAwGf;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,8BAA8B,CAClD,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,kBAAkB,EACzB,KAAK,EAAE,qCAAqC,GAC3C,OAAO,CAAC,IAAI,CAAC,CAqHf;AAmJD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,wBAAsB,gCAAgC,CACpD,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE,kBAAkB,EACzB,KAAK,EAAE,uCAAuC,GAC7C,OAAO,CAAC,IAAI,CAAC,CAqSf;AA8ID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;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,CAyJf;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAsB,+BAA+B,CACnD,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE,kBAAkB,EACzB,KAAK,EAAE,sCAAsC,GAC5C,OAAO,CAAC,IAAI,CAAC,CAgNf;AAqBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAsB,8BAA8B,CAClD,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,kBAAkB,EACzB,KAAK,EAAE,qCAAqC,GAC3C,OAAO,CAAC,IAAI,CAAC,CA4Nf"}
|
|
@@ -16,6 +16,7 @@ import { deriveProfileFactionAddress, profileFactionIdentityAccountDefinition, }
|
|
|
16
16
|
import { deriveStarbasePlayerAddress, starbasePlayerAccountDefinition, } from '../../internal/c4/starbase.js';
|
|
17
17
|
import { celestialBodyAccountDefinition, deriveCelestialBodyAddress, deriveStarSystemAddress, starSystemAccountDefinition, } from '../../internal/c4/world.js';
|
|
18
18
|
import { resolveXpRuntime } from '../../internal/planning/xp-runtime.js';
|
|
19
|
+
import { describeBuildingXpSettlement } from '../../internal/planning/building-xp.js';
|
|
19
20
|
import { readClaimStakeStorageAction } from '../../internal/planning/claim-stake-storage-actions.js';
|
|
20
21
|
import { RENT_ADDRESS } from '../../internal/planning/rent.js';
|
|
21
22
|
import { planStorageFunding } from '../../internal/planning/storage-actions.js';
|
|
@@ -27,10 +28,11 @@ import { requireProfileStarbasePlayer } from '../../internal/planning/starbase-p
|
|
|
27
28
|
import { requireGameAddress } from '../../internal/game-context.js';
|
|
28
29
|
import { structurePlacementFee } from '../../internal/planning/placement-fee.js';
|
|
29
30
|
import { cargoStorageUnits, cargoStorageUnitsFloor, } from '../../internal/cargo.js';
|
|
30
|
-
import { adaptCancelClaimStakeBuildingChangesInstruction, adaptClaimStakeBuildingChangesInstruction, adaptDeconstructClaimStakeInstruction, adaptExitClaimStakeFleetTransferInstruction, adaptFinalizeClaimStakeBuildingChangesInstruction, adaptPlaceClaimStakeInstruction, adaptRecoverClaimStakeFleetTransferInstruction, adaptStartClaimStakeFleetTransferInstruction, adaptTopUpClaimStakeRentInstruction, readPlanAuthorization, } from '../../internal/planning/authorization-adapter.js';
|
|
31
|
+
import { adaptCancelClaimStakeBuildingChangesInstruction, adaptClaimStakeBuildingChangesInstruction, adaptDeconstructClaimStakeInstruction, adaptClaimStakeResourceProductionInstruction, adaptExitClaimStakeFleetTransferInstruction, adaptFinalizeClaimStakeBuildingChangesInstruction, adaptPlaceClaimStakeInstruction, adaptRecoverClaimStakeFleetTransferInstruction, adaptSettleClaimStakeBuildingXpInstruction, adaptStartClaimStakeFleetTransferInstruction, adaptTopUpClaimStakeRentInstruction, readPlanAuthorization, } from '../../internal/planning/authorization-adapter.js';
|
|
31
32
|
import { buildPlannerPlan } from '../../planning/plan-construction.js';
|
|
32
33
|
import { readFreshGameCargoDefinitions } from '../../registry/cargo.js';
|
|
33
|
-
import { listClaimStakeBuildingDefinitions, resolveCargo, } from '../../registry/index.js';
|
|
34
|
+
import { listClaimStakeBuildingDefinitions, resolveCargo, resolveClaimStakeDefinition, } from '../../registry/index.js';
|
|
35
|
+
import { CLOCK_ADDRESS, readClock, } from '../../internal/planning/faction-enrollment.js';
|
|
34
36
|
import { accountAbsentPrecondition, accountStatePrecondition, } from '../../internal/planning/account-state.js';
|
|
35
37
|
async function resolveClaimStakeXp(ctx, game, character) {
|
|
36
38
|
const xp = await resolveXpRuntime(ctx, {
|
|
@@ -189,6 +191,11 @@ function validateDeconstructOptions(value) {
|
|
|
189
191
|
exactKeys(options, 'options', ['authorization']);
|
|
190
192
|
return { authorization: readPlanAuthorization(options.authorization) };
|
|
191
193
|
}
|
|
194
|
+
function validateSettleBuildingXpOptions(value) {
|
|
195
|
+
const options = record(value, 'options');
|
|
196
|
+
exactKeys(options, 'options', ['authorization']);
|
|
197
|
+
return { authorization: readPlanAuthorization(options.authorization) };
|
|
198
|
+
}
|
|
192
199
|
function validateTopUpRentOptions(value) {
|
|
193
200
|
const options = record(value, 'options');
|
|
194
201
|
exactKeys(options, 'options', ['amount', 'authorization']);
|
|
@@ -261,6 +268,11 @@ function validateExitFleetTransferOptions(value) {
|
|
|
261
268
|
funder: address(options.funder, 'funder'),
|
|
262
269
|
};
|
|
263
270
|
}
|
|
271
|
+
function validateSettleProductionOptions(value) {
|
|
272
|
+
const options = record(value, 'options');
|
|
273
|
+
exactKeys(options, 'options', ['funder']);
|
|
274
|
+
return { funder: address(options.funder, 'funder') };
|
|
275
|
+
}
|
|
264
276
|
function requireAccount(account, accountAddress, message) {
|
|
265
277
|
return account ?? fail(message, accountAddress);
|
|
266
278
|
}
|
|
@@ -1581,6 +1593,109 @@ export async function planTopUpClaimStakeRent(ctx, stake, input) {
|
|
|
1581
1593
|
summary: description,
|
|
1582
1594
|
});
|
|
1583
1595
|
}
|
|
1596
|
+
/** Plans settling the Building XP one owned Claim Stake has earned.
|
|
1597
|
+
*
|
|
1598
|
+
* The game first brings the stake's rent and production up to date, which
|
|
1599
|
+
* records any further paid operational time, then pays its recorded
|
|
1600
|
+
* operational work to the owner's Character as Building XP, up to the
|
|
1601
|
+
* Character's remaining Building allowance, and awards any claim Mining XP the
|
|
1602
|
+
* stake recorded. Work beyond the allowance is discarded rather than carried,
|
|
1603
|
+
* so the planner refuses while the allowance is empty, and it refuses a stake
|
|
1604
|
+
* that has recorded no work and is not operational. The Plan states the
|
|
1605
|
+
* recorded XP and the allowance; the exact grant remains chain-authoritative.
|
|
1606
|
+
*
|
|
1607
|
+
* Requires Disabled rent, the stake's current System generation and the
|
|
1608
|
+
* Profile's Starbase Player there from the current Starbase.
|
|
1609
|
+
* Bringing a large structure up to date can take more than the default
|
|
1610
|
+
* 200,000 compute units, so simulate first and raise `computeUnitLimit` when
|
|
1611
|
+
* assembling if needed.
|
|
1612
|
+
*
|
|
1613
|
+
* @example
|
|
1614
|
+
* ```ts
|
|
1615
|
+
* declare const ctx: SageContext;
|
|
1616
|
+
* declare const stake: ClaimStakeSnapshot;
|
|
1617
|
+
* declare const authorization: PlanAuthorization;
|
|
1618
|
+
* const plan = await planSettleClaimStakeBuildingXp(ctx, stake, {
|
|
1619
|
+
* authorization,
|
|
1620
|
+
* });
|
|
1621
|
+
* console.log(plan.describe());
|
|
1622
|
+
* ```
|
|
1623
|
+
*/
|
|
1624
|
+
export async function planSettleClaimStakeBuildingXp(ctx, stake, input) {
|
|
1625
|
+
const options = validateSettleBuildingXpOptions(input);
|
|
1626
|
+
const game = requireGameAddress(ctx);
|
|
1627
|
+
const { profile } = options.authorization;
|
|
1628
|
+
const character = await requireOwnedStake(ctx.programs, stake, game, profile);
|
|
1629
|
+
const currencyCache = await claimStakeCurrencyCache(ctx.programs, game);
|
|
1630
|
+
const action = 'the Building XP settlement';
|
|
1631
|
+
const [{ bodyAccount, currentBody, currentStake, extraAccounts: [characterCandidate, cacheCandidate], stakeAccount, }, rent, xp,] = await Promise.all([
|
|
1632
|
+
readOwnedStake(ctx, stake, action, [character, currencyCache]),
|
|
1633
|
+
requireDisabledStakeRent(ctx, game, stake.address, action),
|
|
1634
|
+
resolveClaimStakeXp(ctx, game, character),
|
|
1635
|
+
]);
|
|
1636
|
+
if (!sameOwnedStake(currentStake, stake, game, profile)) {
|
|
1637
|
+
fail(`Claim Stake ${stake.address} changed or does not match its loaded ownership, Body, definitions, buildings, or System generation. Refresh it and retry ${action}.`, stake.address);
|
|
1638
|
+
}
|
|
1639
|
+
// A Character's XP runtime names both accounts or refuses the Character.
|
|
1640
|
+
const xpBudget = xp.accounts.xpBudget;
|
|
1641
|
+
const xpBudgetConfig = xp.accounts.xpBudgetConfig;
|
|
1642
|
+
const { system } = await requireStakePlanet(ctx.programs, currentBody, stake, game, action);
|
|
1643
|
+
// The settlement writes the Character's XP, which other actions change
|
|
1644
|
+
// too, so the Plan checks its identity without pinning its state.
|
|
1645
|
+
requireProfileCharacter(ctx.programs, characterCandidate, character, profile, game, action);
|
|
1646
|
+
const [cacheGuard, { currentPlayer, currentSystem, player, playerAccount, systemAccount },] = await Promise.all([
|
|
1647
|
+
requireCurrencyCache(ctx.programs, cacheCandidate, currencyCache, game, action, 'planSettleClaimStakeBuildingXp'),
|
|
1648
|
+
readStakeStarbase(ctx, stake, game, system, character, profile, action),
|
|
1649
|
+
]);
|
|
1650
|
+
if (currentPlayer.sequenceId !== currentSystem.sequenceId)
|
|
1651
|
+
fail(`Starbase Player ${player} was registered at an earlier Starbase in Star System ${system}, which the game treats as destroyed. Register at the current Starbase and retry ${action}.`, player);
|
|
1652
|
+
const settlement = await describeBuildingXpSettlement(ctx, {
|
|
1653
|
+
structure: `Claim Stake ${stake.address}`,
|
|
1654
|
+
game,
|
|
1655
|
+
character,
|
|
1656
|
+
xpBudget,
|
|
1657
|
+
xpBudgetConfig,
|
|
1658
|
+
recorded: currentStake.operationalXp,
|
|
1659
|
+
operational: currentStake.state.kind === 'active' &&
|
|
1660
|
+
currentStake.constructionRemainingSeconds === 0n,
|
|
1661
|
+
});
|
|
1662
|
+
const description = `Settle Claim Stake ${stake.address}'s Building XP after bringing its rent and production up to date. ${settlement.description} Any claim Mining XP the stake recorded is awarded too.`;
|
|
1663
|
+
return buildPlannerPlan(ctx.programs, {
|
|
1664
|
+
kind: 'claim-stakes.settle-building-xp',
|
|
1665
|
+
preconditions: [
|
|
1666
|
+
...(await Promise.all([
|
|
1667
|
+
accountStatePrecondition(stakeAccount, `Claim Stake ${stake.address} retains its ownership, buildings, rent, production, lifecycle state, recorded Building work, Body, and System generation.`),
|
|
1668
|
+
planetPrecondition(bodyAccount, system),
|
|
1669
|
+
systemPrecondition(systemAccount, currentSystem.name),
|
|
1670
|
+
playerPrecondition(playerAccount, player),
|
|
1671
|
+
])),
|
|
1672
|
+
cacheGuard,
|
|
1673
|
+
xp.guard,
|
|
1674
|
+
settlement.guard,
|
|
1675
|
+
...rent.guards,
|
|
1676
|
+
],
|
|
1677
|
+
steps: [
|
|
1678
|
+
{
|
|
1679
|
+
describes: description,
|
|
1680
|
+
instruction: adaptSettleClaimStakeBuildingXpInstruction(ctx.programs, {
|
|
1681
|
+
authorization: options.authorization,
|
|
1682
|
+
celestialBody: stake.body.address,
|
|
1683
|
+
character,
|
|
1684
|
+
claimStakeInstance: stake.address,
|
|
1685
|
+
currencyCache,
|
|
1686
|
+
game,
|
|
1687
|
+
...rent.accounts,
|
|
1688
|
+
systemAndStarbasePlayerStarbasePlayer: player,
|
|
1689
|
+
systemAndStarbasePlayerSystem: system,
|
|
1690
|
+
xpBudget,
|
|
1691
|
+
xpBudgetConfig,
|
|
1692
|
+
}),
|
|
1693
|
+
signers: [options.authorization.authority],
|
|
1694
|
+
},
|
|
1695
|
+
],
|
|
1696
|
+
summary: description,
|
|
1697
|
+
});
|
|
1698
|
+
}
|
|
1584
1699
|
function cargoAmount(values, cargoId) {
|
|
1585
1700
|
return values.find((item) => item.cargoId === cargoId)?.amount ?? 0n;
|
|
1586
1701
|
}
|
|
@@ -2196,4 +2311,177 @@ export async function planExitClaimStakeFleetTransfer(ctx, fleet, stake, input)
|
|
|
2196
2311
|
summary: description,
|
|
2197
2312
|
});
|
|
2198
2313
|
}
|
|
2314
|
+
/** The latest Unix second a JavaScript Date can represent. */
|
|
2315
|
+
const DATE_LIMIT_SECONDS = 8640000000000n;
|
|
2316
|
+
/** A Unix time as an ISO-8601 instant, or as Unix seconds beyond the range a
|
|
2317
|
+
* Date can represent, which a long rent balance can reach. */
|
|
2318
|
+
function instant(unixSeconds) {
|
|
2319
|
+
return unixSeconds > DATE_LIMIT_SECONDS || unixSeconds < -DATE_LIMIT_SECONDS
|
|
2320
|
+
? `Unix time ${String(unixSeconds)}`
|
|
2321
|
+
: new Date(Number(unixSeconds) * 1000).toISOString();
|
|
2322
|
+
}
|
|
2323
|
+
/** The legacy rent a Claim Stake pays per second, as a raw rate with 56
|
|
2324
|
+
* fractional bits: the Planet's base rate for the stake's tier at the
|
|
2325
|
+
* Starbase's current level, times the definition's rent multiplier. */
|
|
2326
|
+
function claimStakeRentRate(baseRaw, multiplierRaw) {
|
|
2327
|
+
// The base rate has 32 fractional bits and the multiplier 56.
|
|
2328
|
+
return (baseRaw * multiplierRaw) >> 32n;
|
|
2329
|
+
}
|
|
2330
|
+
/** Plans bringing one Claim Stake's production up to date.
|
|
2331
|
+
*
|
|
2332
|
+
* Production is permissionless: any wallet may tick any Claim Stake, so the
|
|
2333
|
+
* Plan's only signer is the `funder`, which pays any growth of the stake's
|
|
2334
|
+
* account. Rent the stake frees goes to its owner Profile. The game pays the
|
|
2335
|
+
* stake's rent up to now, then produces from its last tick to now: each
|
|
2336
|
+
* Building's processors turn their inputs into outputs at the stake's net
|
|
2337
|
+
* rates, a processor that runs short of an input pauses, and output stops at
|
|
2338
|
+
* the stake's storage, with Fuel limited to its separate fuel storage. The
|
|
2339
|
+
* tick also records paid operational Building work and claim Mining work for
|
|
2340
|
+
* a later {@link planSettleClaimStakeBuildingXp}.
|
|
2341
|
+
*
|
|
2342
|
+
* The planner refuses what the game would refuse: a stake in design, a
|
|
2343
|
+
* Deactivated stake past its eviction grace, a stake its Planet does not
|
|
2344
|
+
* register or has evicted, a Starbase Player from an earlier Starbase, and a
|
|
2345
|
+
* stake whose rent balance does not cover the time up to now, which the game
|
|
2346
|
+
* would deactivate instead. A Deactivated stake whose topped-up balance covers
|
|
2347
|
+
* the time up to now is reactivated, then produces. It also refuses a stake
|
|
2348
|
+
* still under construction or already up to date, which would produce
|
|
2349
|
+
* nothing. The description projects the elapsed time, the approximate amounts
|
|
2350
|
+
* at the stored net rates, storage, and the rent paid-through time; exact
|
|
2351
|
+
* amounts, processor pauses and whether the Planet allows harvesting remain
|
|
2352
|
+
* chain-authoritative.
|
|
2353
|
+
*
|
|
2354
|
+
* Requires Disabled rent and the current System generation. Bringing a large
|
|
2355
|
+
* stake up to date can take more than the default 200,000 compute units, so
|
|
2356
|
+
* simulate first and raise `computeUnitLimit` when assembling if needed.
|
|
2357
|
+
*
|
|
2358
|
+
* @example
|
|
2359
|
+
* ```ts
|
|
2360
|
+
* declare const ctx: SageContext;
|
|
2361
|
+
* declare const stake: ClaimStakeSnapshot;
|
|
2362
|
+
* declare const funder: Address;
|
|
2363
|
+
* const plan = await planSettleClaimStakeProduction(ctx, stake, { funder });
|
|
2364
|
+
* console.log(plan.describe());
|
|
2365
|
+
* ```
|
|
2366
|
+
*/
|
|
2367
|
+
export async function planSettleClaimStakeProduction(ctx, stake, input) {
|
|
2368
|
+
const options = validateSettleProductionOptions(input);
|
|
2369
|
+
const game = requireGameAddress(ctx);
|
|
2370
|
+
const profile = stake.ownerProfile.address;
|
|
2371
|
+
if (stake.state.kind === 'design') {
|
|
2372
|
+
fail(`Claim Stake ${stake.address} is in design, and the game produces only for a built stake. Finalize its building changes, refresh it, and retry the production tick.`, stake.address);
|
|
2373
|
+
}
|
|
2374
|
+
const character = await requireOwnedStake(ctx.programs, stake, game, profile);
|
|
2375
|
+
const currencyCache = await claimStakeCurrencyCache(ctx.programs, game);
|
|
2376
|
+
const action = 'the Claim Stake production tick';
|
|
2377
|
+
const [{ bodyAccount, currentBody, currentStake, extraAccounts: [clockCandidate], stakeAccount, }, rent, definition, xp,] = await Promise.all([
|
|
2378
|
+
readOwnedStake(ctx, stake, action, [CLOCK_ADDRESS]),
|
|
2379
|
+
requireDisabledStakeRent(ctx, game, stake.address, action),
|
|
2380
|
+
resolveClaimStakeDefinition(ctx, stake.claimStakeDefinitionId),
|
|
2381
|
+
resolveClaimStakeXp(ctx, game),
|
|
2382
|
+
]);
|
|
2383
|
+
if (!sameOwnedStake(currentStake, stake, game, profile) ||
|
|
2384
|
+
!sameStakeState(currentStake.state, stake.state)) {
|
|
2385
|
+
fail(`Claim Stake ${stake.address} changed or does not match its loaded ownership, Body, definitions, buildings, lifecycle state, or System generation. Refresh it and retry ${action}.`, stake.address);
|
|
2386
|
+
}
|
|
2387
|
+
const now = readClock(requireAccount(clockCandidate, CLOCK_ADDRESS, 'The Clock sysvar is missing. Refresh chain time and retry the production tick.'));
|
|
2388
|
+
const planet = await requireStakePlanet(ctx.programs, currentBody, stake, game, action);
|
|
2389
|
+
const { system } = planet;
|
|
2390
|
+
const { currentPlayer, currentSystem, extraAccounts: [cacheCandidate], player, playerAccount, starbase, systemAccount, } = await readStakeStarbase(ctx, stake, game, system, character, profile, action, [currencyCache]);
|
|
2391
|
+
requireStakeRegistered(planet.details.claimedPlots, stake, starbase.level, action);
|
|
2392
|
+
if (currentPlayer.sequenceId !== currentSystem.sequenceId)
|
|
2393
|
+
fail(`Starbase Player ${player} was registered at an earlier Starbase in Star System ${system}, which the game treats as destroyed. The owner must register at the current Starbase before ${action}.`, player);
|
|
2394
|
+
const cacheGuard = await requireCurrencyCache(ctx.programs, cacheCandidate, currencyCache, game, action, 'planSettleClaimStakeProduction');
|
|
2395
|
+
let reactivation = '';
|
|
2396
|
+
if (currentStake.state.kind === 'deactivated') {
|
|
2397
|
+
const graceEnds = currentStake.state.deactivatedAtUnixSeconds +
|
|
2398
|
+
definition.evictionGracePeriodSeconds;
|
|
2399
|
+
if (now > graceEnds)
|
|
2400
|
+
fail(`Claim Stake ${stake.address} was deactivated for unpaid rent and its eviction grace ended at ${instant(graceEnds)}, so the game no longer produces for it. It can only be evicted or respawned.`, stake.address);
|
|
2401
|
+
reactivation = ` The stake is Deactivated within its eviction grace, which ends at ${instant(graceEnds)}; the game reactivates it once its rent covers the time up to now, then produces.`;
|
|
2402
|
+
}
|
|
2403
|
+
const rate = claimStakeRentRate(planet.details.baseClaimStakeRentRate[LEVEL_INDEX[starbase.level]][TIER_INDEX[definition.tier]].raw, definition.rentMultiplier.raw);
|
|
2404
|
+
const paidThrough = rate === 0n
|
|
2405
|
+
? undefined
|
|
2406
|
+
: currentStake.lastRentAtUnixSeconds +
|
|
2407
|
+
(currentStake.rentBalanceRaw << 56n) / rate;
|
|
2408
|
+
if (paidThrough !== undefined && paidThrough < now)
|
|
2409
|
+
fail(`Claim Stake ${stake.address}'s rent balance pays only through about ${instant(paidThrough)}, before chain time ${instant(now)}, so the game would deactivate the stake instead of producing. Top up its rent, refresh, and retry.`, stake.address);
|
|
2410
|
+
const constructionEnds = currentStake.constructionProgressAtUnixSeconds +
|
|
2411
|
+
currentStake.constructionRemainingSeconds;
|
|
2412
|
+
if (currentStake.constructionRemainingSeconds > 0n && constructionEnds > now)
|
|
2413
|
+
fail(`Claim Stake ${stake.address} is under construction until about ${instant(constructionEnds)} and produces nothing until then. Wait for construction to finish and retry ${action}.`, stake.address);
|
|
2414
|
+
const { production } = currentStake;
|
|
2415
|
+
const elapsed = now - production.lastTickAtUnixSeconds;
|
|
2416
|
+
if (elapsed <= 0n)
|
|
2417
|
+
fail(`Claim Stake ${stake.address}'s production is already up to date at chain time ${instant(now)}. Wait and retry ${action}.`, stake.address);
|
|
2418
|
+
const flows = await Promise.all(production.netResources.map(async ({ cargoId, ratePerSecond }) => {
|
|
2419
|
+
const { name } = await resolveCargo(ctx, cargoId);
|
|
2420
|
+
const amount = Math.round(Math.abs(ratePerSecond) * Number(elapsed));
|
|
2421
|
+
const stored = cargoAmount(production.cargoPod.amounts, cargoId);
|
|
2422
|
+
// Seconds of consumption the stored input covers; Infinity for outputs.
|
|
2423
|
+
const covers = ratePerSecond < 0
|
|
2424
|
+
? Math.floor(Number(stored) / -ratePerSecond)
|
|
2425
|
+
: Number.POSITIVE_INFINITY;
|
|
2426
|
+
return { amount, covers, name, produced: ratePerSecond > 0, stored };
|
|
2427
|
+
}));
|
|
2428
|
+
const short = flows
|
|
2429
|
+
.filter((flow) => flow.covers < Number(elapsed))
|
|
2430
|
+
.map(({ covers, name, stored }) => stored === 0n
|
|
2431
|
+
? `the stake holds no ${name}`
|
|
2432
|
+
: covers === 0
|
|
2433
|
+
? `stored ${name} lasts less than one second`
|
|
2434
|
+
: `stored ${name} covers only about ${String(covers)} of those seconds`);
|
|
2435
|
+
const shortage = short.length === 0
|
|
2436
|
+
? ''
|
|
2437
|
+
: ` Warning: ${short.join('; ')}. Processors that need an exhausted input pause, which can stop the stake's output entirely, so expect far less than these amounts.`;
|
|
2438
|
+
const list = (produced) => flows
|
|
2439
|
+
.filter((flow) => flow.produced === produced && flow.amount > 0)
|
|
2440
|
+
.map(({ amount, name }) => `${String(amount)} ${name}`)
|
|
2441
|
+
.join(', ');
|
|
2442
|
+
const made = list(true);
|
|
2443
|
+
const used = list(false);
|
|
2444
|
+
const rates = made === '' && used === ''
|
|
2445
|
+
? 'Its stored net rates produce and consume nothing.'
|
|
2446
|
+
: `At its stored net rates that is about ${[
|
|
2447
|
+
...(made === '' ? [] : [`${made} produced`]),
|
|
2448
|
+
...(used === '' ? [] : [`${used} consumed`]),
|
|
2449
|
+
].join(' and ')}, before storage limits and processor pauses.${shortage}`;
|
|
2450
|
+
const rentPaid = paidThrough === undefined
|
|
2451
|
+
? 'The stake pays no rent at the Starbase’s current level.'
|
|
2452
|
+
: `Its rent balance pays through about ${instant(paidThrough)}.`;
|
|
2453
|
+
const description = `Bring Claim Stake ${stake.address}'s production up to date: ${String(elapsed)} seconds since its last tick at ${instant(production.lastTickAtUnixSeconds)}. ${rates} Storage holds ${String(production.cargoPod.storageCost)} of ${String(production.resourceCapacityRaw)} capacity units. ${rentPaid}${reactivation} Funder ${options.funder} signs and pays any growth of the stake's account; rent the stake frees goes to Profile ${profile}. Exact amounts, processor pauses and whether the Planet allows harvesting remain chain-authoritative.`;
|
|
2454
|
+
return buildPlannerPlan(ctx.programs, {
|
|
2455
|
+
kind: 'claim-stakes.settle-production',
|
|
2456
|
+
preconditions: [
|
|
2457
|
+
xp.guard,
|
|
2458
|
+
...(await Promise.all([
|
|
2459
|
+
accountStatePrecondition(stakeAccount, `Claim Stake ${stake.address} retains its owner, buildings, rent, production, lifecycle state, Body, and System generation.`),
|
|
2460
|
+
planetPrecondition(bodyAccount, system),
|
|
2461
|
+
systemPrecondition(systemAccount, currentSystem.name),
|
|
2462
|
+
playerPrecondition(playerAccount, player),
|
|
2463
|
+
])),
|
|
2464
|
+
cacheGuard,
|
|
2465
|
+
...rent.guards,
|
|
2466
|
+
],
|
|
2467
|
+
steps: [
|
|
2468
|
+
{
|
|
2469
|
+
describes: description,
|
|
2470
|
+
instruction: adaptClaimStakeResourceProductionInstruction(ctx.programs, {
|
|
2471
|
+
celestialBody: stake.body.address,
|
|
2472
|
+
claimStakeInstance: stake.address,
|
|
2473
|
+
currencyCache,
|
|
2474
|
+
funder: options.funder,
|
|
2475
|
+
game,
|
|
2476
|
+
profile,
|
|
2477
|
+
...rent.accounts,
|
|
2478
|
+
systemAndStarbasePlayerStarbasePlayer: player,
|
|
2479
|
+
systemAndStarbasePlayerSystem: system,
|
|
2480
|
+
}),
|
|
2481
|
+
signers: [options.funder],
|
|
2482
|
+
},
|
|
2483
|
+
],
|
|
2484
|
+
summary: description,
|
|
2485
|
+
});
|
|
2486
|
+
}
|
|
2199
2487
|
//# sourceMappingURL=index.js.map
|