@aephia/atlas-kit 0.8.0-next.9 → 0.8.0
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/README.md +1 -1
- package/dist/claim-stakes/actions/index.d.ts +153 -0
- package/dist/claim-stakes/actions/index.d.ts.map +1 -1
- package/dist/claim-stakes/actions/index.js +560 -72
- 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/client/contracts.d.ts +1 -1
- package/dist/client/contracts.d.ts.map +1 -1
- package/dist/client/deployments.d.ts +1 -1
- package/dist/client/deployments.js +1 -1
- package/dist/client/errors.d.ts +1 -1
- package/dist/client/errors.d.ts.map +1 -1
- package/dist/client/errors.js.map +1 -1
- package/dist/combat/actions/index.d.ts +137 -0
- package/dist/combat/actions/index.d.ts.map +1 -1
- package/dist/combat/actions/index.js +596 -1
- package/dist/combat/actions/index.js.map +1 -1
- package/dist/crafting/actions/habs.d.ts +366 -0
- package/dist/crafting/actions/habs.d.ts.map +1 -0
- package/dist/crafting/actions/habs.js +1030 -0
- package/dist/crafting/actions/habs.js.map +1 -0
- package/dist/crafting/actions/index.d.ts +14 -3
- package/dist/crafting/actions/index.d.ts.map +1 -1
- package/dist/crafting/actions/index.js +61 -25
- package/dist/crafting/actions/index.js.map +1 -1
- package/dist/crafting/index.d.ts +4 -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/fleets/actions/index.d.ts +10 -8
- package/dist/fleets/actions/index.d.ts.map +1 -1
- package/dist/fleets/actions/index.js +15 -13
- package/dist/fleets/actions/index.js.map +1 -1
- package/dist/identity/actions/daily-check-in.d.ts +57 -0
- package/dist/identity/actions/daily-check-in.d.ts.map +1 -0
- package/dist/identity/actions/daily-check-in.js +200 -0
- package/dist/identity/actions/daily-check-in.js.map +1 -0
- package/dist/identity/actions/index.d.ts +1 -0
- package/dist/identity/actions/index.d.ts.map +1 -1
- package/dist/identity/actions/index.js +1 -0
- package/dist/identity/actions/index.js.map +1 -1
- package/dist/identity/index.d.ts +169 -17
- package/dist/identity/index.d.ts.map +1 -1
- package/dist/identity/index.js +142 -9
- package/dist/identity/index.js.map +1 -1
- package/dist/internal/c4/career-xp.d.ts +113 -26
- package/dist/internal/c4/career-xp.d.ts.map +1 -1
- package/dist/internal/c4/career-xp.js +101 -38
- package/dist/internal/c4/career-xp.js.map +1 -1
- package/dist/internal/c4/character-registration.d.ts.map +1 -1
- package/dist/internal/c4/character-registration.js +3 -0
- package/dist/internal/c4/character-registration.js.map +1 -1
- package/dist/internal/c4/character.d.ts +68 -0
- package/dist/internal/c4/character.d.ts.map +1 -1
- package/dist/internal/c4/character.js +46 -2
- package/dist/internal/c4/character.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/combat-storage.d.ts +4 -0
- package/dist/internal/c4/combat-storage.d.ts.map +1 -1
- package/dist/internal/c4/combat-storage.js +6 -1
- package/dist/internal/c4/combat-storage.js.map +1 -1
- package/dist/internal/c4/crafting-hab-storage.d.ts +42 -0
- package/dist/internal/c4/crafting-hab-storage.d.ts.map +1 -0
- package/dist/internal/c4/crafting-hab-storage.js +174 -0
- package/dist/internal/c4/crafting-hab-storage.js.map +1 -0
- package/dist/internal/c4/crafting-storage.d.ts +8 -0
- package/dist/internal/c4/crafting-storage.d.ts.map +1 -1
- package/dist/internal/c4/crafting-storage.js +18 -1
- package/dist/internal/c4/crafting-storage.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 +27 -0
- package/dist/internal/c4/discriminators.d.ts.map +1 -1
- package/dist/internal/c4/discriminators.js +55 -1
- package/dist/internal/c4/discriminators.js.map +1 -1
- package/dist/internal/c4/fleet-storage.d.ts +2 -1
- package/dist/internal/c4/fleet-storage.d.ts.map +1 -1
- package/dist/internal/c4/fleet-storage.js +14 -5
- package/dist/internal/c4/fleet-storage.js.map +1 -1
- package/dist/internal/c4/fleet.d.ts +33 -4
- package/dist/internal/c4/fleet.d.ts.map +1 -1
- package/dist/internal/c4/fleet.js +27 -2
- package/dist/internal/c4/fleet.js.map +1 -1
- package/dist/internal/c4/game.d.ts +33 -0
- package/dist/internal/c4/game.d.ts.map +1 -1
- package/dist/internal/c4/game.js +46 -0
- package/dist/internal/c4/game.js.map +1 -1
- package/dist/internal/c4/governance.d.ts +72 -0
- package/dist/internal/c4/governance.d.ts.map +1 -1
- package/dist/internal/c4/governance.js +108 -3
- package/dist/internal/c4/governance.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/c4/starbase-upgrade.d.ts +20 -0
- package/dist/internal/c4/starbase-upgrade.d.ts.map +1 -0
- package/dist/internal/c4/starbase-upgrade.js +44 -0
- package/dist/internal/c4/starbase-upgrade.js.map +1 -0
- package/dist/internal/c4/world.d.ts +3 -2
- package/dist/internal/c4/world.d.ts.map +1 -1
- package/dist/internal/c4/world.js +4 -18
- package/dist/internal/c4/world.js.map +1 -1
- package/dist/internal/planning/action-runtime.d.ts +3 -2
- package/dist/internal/planning/action-runtime.d.ts.map +1 -1
- package/dist/internal/planning/action-runtime.js +4 -3
- package/dist/internal/planning/action-runtime.js.map +1 -1
- package/dist/internal/planning/authorization-adapter.d.ts +363 -1
- package/dist/internal/planning/authorization-adapter.d.ts.map +1 -1
- package/dist/internal/planning/authorization-adapter.js +519 -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/claim-stake-transfer-window.d.ts +18 -0
- package/dist/internal/planning/claim-stake-transfer-window.d.ts.map +1 -0
- package/dist/internal/planning/claim-stake-transfer-window.js +57 -0
- package/dist/internal/planning/claim-stake-transfer-window.js.map +1 -0
- package/dist/internal/planning/combat-storage-actions.d.ts +3 -2
- package/dist/internal/planning/combat-storage-actions.d.ts.map +1 -1
- package/dist/internal/planning/combat-storage-actions.js +26 -4
- package/dist/internal/planning/combat-storage-actions.js.map +1 -1
- package/dist/internal/planning/crafting-hab-storage-actions.d.ts +10 -0
- package/dist/internal/planning/crafting-hab-storage-actions.d.ts.map +1 -0
- package/dist/internal/planning/crafting-hab-storage-actions.js +46 -0
- package/dist/internal/planning/crafting-hab-storage-actions.js.map +1 -0
- package/dist/internal/planning/crafting-storage-actions.d.ts +5 -3
- package/dist/internal/planning/crafting-storage-actions.d.ts.map +1 -1
- package/dist/internal/planning/crafting-storage-actions.js +66 -4
- package/dist/internal/planning/crafting-storage-actions.js.map +1 -1
- package/dist/internal/planning/currency-cache-guard.d.ts.map +1 -1
- package/dist/internal/planning/currency-cache-guard.js +5 -1
- package/dist/internal/planning/currency-cache-guard.js.map +1 -1
- package/dist/internal/planning/daily-check-in.d.ts +71 -0
- package/dist/internal/planning/daily-check-in.d.ts.map +1 -0
- package/dist/internal/planning/daily-check-in.js +201 -0
- package/dist/internal/planning/daily-check-in.js.map +1 -0
- package/dist/internal/planning/democracy-history.d.ts +15 -0
- package/dist/internal/planning/democracy-history.d.ts.map +1 -1
- package/dist/internal/planning/democracy-history.js +23 -7
- package/dist/internal/planning/democracy-history.js.map +1 -1
- package/dist/internal/planning/democracy-storage-actions.d.ts +12 -0
- package/dist/internal/planning/democracy-storage-actions.d.ts.map +1 -0
- package/dist/internal/planning/democracy-storage-actions.js +81 -0
- package/dist/internal/planning/democracy-storage-actions.js.map +1 -0
- package/dist/internal/planning/fleet-state.js +1 -1
- package/dist/internal/planning/fleet-state.js.map +1 -1
- package/dist/internal/planning/loyalty-earning.d.ts +42 -0
- package/dist/internal/planning/loyalty-earning.d.ts.map +1 -0
- package/dist/internal/planning/loyalty-earning.js +143 -0
- package/dist/internal/planning/loyalty-earning.js.map +1 -0
- package/dist/internal/planning/placement-fee.d.ts +6 -0
- package/dist/internal/planning/placement-fee.d.ts.map +1 -0
- package/dist/internal/planning/placement-fee.js +9 -0
- package/dist/internal/planning/placement-fee.js.map +1 -0
- package/dist/internal/planning/plan-guards.d.ts.map +1 -1
- package/dist/internal/planning/plan-guards.js +11 -0
- package/dist/internal/planning/plan-guards.js.map +1 -1
- package/dist/internal/planning/profile-storage-funding-guard.d.ts +1 -1
- package/dist/internal/planning/profile-storage-funding-guard.d.ts.map +1 -1
- package/dist/internal/planning/profile-storage-funding-guard.js +53 -1
- package/dist/internal/planning/profile-storage-funding-guard.js.map +1 -1
- package/dist/internal/planning/rent-catalog.d.ts.map +1 -1
- package/dist/internal/planning/rent-catalog.js +37 -1
- package/dist/internal/planning/rent-catalog.js.map +1 -1
- package/dist/internal/planning/research-unlock.d.ts.map +1 -1
- package/dist/internal/planning/research-unlock.js.map +1 -1
- package/dist/internal/planning/reward-epoch.d.ts +44 -0
- package/dist/internal/planning/reward-epoch.d.ts.map +1 -0
- package/dist/internal/planning/reward-epoch.js +220 -0
- package/dist/internal/planning/reward-epoch.js.map +1 -0
- package/dist/internal/planning/runtime-guards.d.ts.map +1 -1
- package/dist/internal/planning/runtime-guards.js +92 -13
- package/dist/internal/planning/runtime-guards.js.map +1 -1
- package/dist/internal/planning/starbase-repair-guard.d.ts +12 -0
- package/dist/internal/planning/starbase-repair-guard.d.ts.map +1 -0
- package/dist/internal/planning/starbase-repair-guard.js +54 -0
- package/dist/internal/planning/starbase-repair-guard.js.map +1 -0
- package/dist/internal/planning/starbase-system-guard.d.ts.map +1 -1
- package/dist/internal/planning/starbase-system-guard.js +48 -3
- package/dist/internal/planning/starbase-system-guard.js.map +1 -1
- package/dist/internal/planning/starbase-upgrade-storage-actions.d.ts +7 -0
- package/dist/internal/planning/starbase-upgrade-storage-actions.d.ts.map +1 -0
- package/dist/internal/planning/starbase-upgrade-storage-actions.js +71 -0
- package/dist/internal/planning/starbase-upgrade-storage-actions.js.map +1 -0
- package/dist/internal/planning/starbase-upgrade-window.d.ts +22 -0
- package/dist/internal/planning/starbase-upgrade-window.d.ts.map +1 -0
- package/dist/internal/planning/starbase-upgrade-window.js +64 -0
- package/dist/internal/planning/starbase-upgrade-window.js.map +1 -0
- package/dist/internal/planning/storage-action-readers.d.ts.map +1 -1
- package/dist/internal/planning/storage-action-readers.js +36 -3
- package/dist/internal/planning/storage-action-readers.js.map +1 -1
- package/dist/internal/planning/storage-actions.d.ts +5 -1
- package/dist/internal/planning/storage-actions.d.ts.map +1 -1
- package/dist/internal/planning/storage-actions.js +8 -1
- package/dist/internal/planning/storage-actions.js.map +1 -1
- package/dist/mining/actions/index.js +1 -1
- package/dist/mining/actions/index.js.map +1 -1
- package/dist/planning/assembly.d.ts +2 -0
- package/dist/planning/assembly.d.ts.map +1 -1
- package/dist/planning/assembly.js +5 -1
- package/dist/planning/assembly.js.map +1 -1
- package/dist/planning/execution.d.ts.map +1 -1
- package/dist/planning/execution.js +132 -5
- package/dist/planning/execution.js.map +1 -1
- package/dist/planning/index.d.ts +75 -0
- package/dist/planning/index.d.ts.map +1 -1
- package/dist/planning/index.js +1 -0
- package/dist/planning/index.js.map +1 -1
- package/dist/planning/plan-validation.d.ts.map +1 -1
- package/dist/planning/plan-validation.js +27 -0
- package/dist/planning/plan-validation.js.map +1 -1
- package/dist/planning/selected-references.d.ts +83 -1
- package/dist/planning/selected-references.d.ts.map +1 -1
- package/dist/planning/selected-references.js +192 -2
- package/dist/planning/selected-references.js.map +1 -1
- package/dist/planning/simulation.d.ts.map +1 -1
- package/dist/planning/simulation.js +11 -3
- package/dist/planning/simulation.js.map +1 -1
- package/dist/starbases/actions/democracy.d.ts +205 -0
- package/dist/starbases/actions/democracy.d.ts.map +1 -0
- package/dist/starbases/actions/democracy.js +861 -0
- package/dist/starbases/actions/democracy.js.map +1 -0
- package/dist/starbases/actions/index.d.ts +2 -0
- package/dist/starbases/actions/index.d.ts.map +1 -1
- package/dist/starbases/actions/index.js +2 -0
- package/dist/starbases/actions/index.js.map +1 -1
- package/dist/starbases/actions/upgrades.d.ts +116 -0
- package/dist/starbases/actions/upgrades.d.ts.map +1 -0
- package/dist/starbases/actions/upgrades.js +474 -0
- package/dist/starbases/actions/upgrades.js.map +1 -0
- package/dist/starbases/governance.d.ts +75 -0
- package/dist/starbases/governance.d.ts.map +1 -1
- package/dist/starbases/governance.js +82 -1
- package/dist/starbases/governance.js.map +1 -1
- package/dist/starbases/index.d.ts +1 -1
- package/dist/starbases/index.d.ts.map +1 -1
- package/dist/starbases/index.js +1 -1
- package/dist/starbases/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Address, Instruction } from '@solana/kit';
|
|
2
|
+
import type { RawAccount, SageProgramAddresses } from '../../client/contracts.js';
|
|
3
|
+
import { type StorageAction } from './storage-actions.js';
|
|
4
|
+
/** Reads the storage a Crafting Hab placement or building change funds from
|
|
5
|
+
* the Profile. A placement funds the new Hab to its rent floor, and the Star
|
|
6
|
+
* System's growth for the Hab's plot, the largest over the five Hab tiers; the
|
|
7
|
+
* Hab item it consumes can only shrink the Starbase Player, which this bound
|
|
8
|
+
* does not credit. A building change grows only the Hab's design. */
|
|
9
|
+
export declare function readCraftingHabStorageAction(programs: SageProgramAddresses, instruction: Instruction, accounts: ReadonlyMap<Address, RawAccount | undefined>): StorageAction;
|
|
10
|
+
//# sourceMappingURL=crafting-hab-storage-actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crafting-hab-storage-actions.d.ts","sourceRoot":"","sources":["../../../src/internal/planning/crafting-hab-storage-actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAExD,OAAO,KAAK,EACV,UAAU,EACV,oBAAoB,EACrB,MAAM,2BAA2B,CAAC;AAUnC,OAAO,EAAW,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEnE;;;;qEAIqE;AACrE,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,oBAAoB,EAC9B,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,WAAW,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,CAAC,GACrD,aAAa,CA2Cf"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { decodeHabBuildingChangesData, decodePlaceCraftingHabData, habBuildingChange, habPlotGrowth, placedHabBytes, } from '../c4/crafting-hab-storage.js';
|
|
2
|
+
import { starbaseLevel } from '../c4/claim-stake-storage.js';
|
|
3
|
+
import { storageInstruction } from './profile-storage-funding-guard.js';
|
|
4
|
+
import { present } from './storage-actions.js';
|
|
5
|
+
/** Reads the storage a Crafting Hab placement or building change funds from
|
|
6
|
+
* the Profile. A placement funds the new Hab to its rent floor, and the Star
|
|
7
|
+
* System's growth for the Hab's plot, the largest over the five Hab tiers; the
|
|
8
|
+
* Hab item it consumes can only shrink the Starbase Player, which this bound
|
|
9
|
+
* does not credit. A building change grows only the Hab's design. */
|
|
10
|
+
export function readCraftingHabStorageAction(programs, instruction, accounts) {
|
|
11
|
+
const metas = instruction.accounts;
|
|
12
|
+
if (storageInstruction(programs, instruction).kind ===
|
|
13
|
+
'crafting-hab-building-changes') {
|
|
14
|
+
const { keyIndex, buildingIds } = decodeHabBuildingChangesData(instruction.data);
|
|
15
|
+
const hab = present(accounts, metas[6].address);
|
|
16
|
+
return {
|
|
17
|
+
profile: metas[2].address,
|
|
18
|
+
authority: metas[1].address,
|
|
19
|
+
keyIndex,
|
|
20
|
+
settlement: 'each',
|
|
21
|
+
accounts: [
|
|
22
|
+
{ address: hab.address, ...habBuildingChange(hab, buildingIds) },
|
|
23
|
+
],
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const { keyIndex } = decodePlaceCraftingHabData(instruction.data);
|
|
27
|
+
const hab = metas[6].address;
|
|
28
|
+
const system = present(accounts, metas[7].address);
|
|
29
|
+
const { bytes, reservedBytes } = placedHabBytes();
|
|
30
|
+
return {
|
|
31
|
+
profile: metas[2].address,
|
|
32
|
+
authority: metas[1].address,
|
|
33
|
+
keyIndex,
|
|
34
|
+
settlement: 'each',
|
|
35
|
+
accounts: [
|
|
36
|
+
{ address: hab, created: true, growthBytes: bytes, reservedBytes },
|
|
37
|
+
{
|
|
38
|
+
address: system.address,
|
|
39
|
+
// The definition's tier picks the level; without reading the Game,
|
|
40
|
+
// the largest growth over every tier bounds it.
|
|
41
|
+
growthBytes: Math.max(...[0, 1, 2, 3, 4].map((tier) => habPlotGrowth(system, hab, starbaseLevel(system), tier))),
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=crafting-hab-storage-actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crafting-hab-storage-actions.js","sourceRoot":"","sources":["../../../src/internal/planning/crafting-hab-storage-actions.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,EAC1B,iBAAiB,EACjB,aAAa,EACb,cAAc,GACf,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,OAAO,EAAsB,MAAM,sBAAsB,CAAC;AA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GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,EAAE;YAClE;gBACE,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,mEAAmE;gBACnE,gDAAgD;gBAChD,WAAW,EAAE,IAAI,CAAC,GAAG,CACnB,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAC9B,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CACxD,CACF;aACF;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Address, Instruction } from '@solana/kit';
|
|
2
2
|
import type { RawAccount, SageProgramAddresses } from '../../client/contracts.js';
|
|
3
3
|
import { type StorageAction } from './storage-actions.js';
|
|
4
|
-
/** Reads a Crafting Process start's or cancellation's storage
|
|
5
|
-
* bytes and fresh accounts.
|
|
6
|
-
|
|
4
|
+
/** Reads a Crafting Process start's, collection's or cancellation's storage
|
|
5
|
+
* effect from its bytes and fresh accounts. A collection's effect depends on
|
|
6
|
+
* whether it is the final one, so it is judged at `atUnixSeconds`, or at the
|
|
7
|
+
* fresh Clock when that is omitted. */
|
|
8
|
+
export declare function readCraftingStorageAction(programs: SageProgramAddresses, instruction: Instruction, accounts: ReadonlyMap<Address, RawAccount | undefined>, atUnixSeconds?: bigint): StorageAction;
|
|
7
9
|
//# sourceMappingURL=crafting-storage-actions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crafting-storage-actions.d.ts","sourceRoot":"","sources":["../../../src/internal/planning/crafting-storage-actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAExD,OAAO,KAAK,EACV,UAAU,EACV,oBAAoB,EACrB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"crafting-storage-actions.d.ts","sourceRoot":"","sources":["../../../src/internal/planning/crafting-storage-actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAExD,OAAO,KAAK,EACV,UAAU,EACV,oBAAoB,EACrB,MAAM,2BAA2B,CAAC;AAkBnC,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAUzE;;;uCAGuC;AACvC,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,oBAAoB,EAC9B,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,WAAW,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,CAAC,EACtD,aAAa,CAAC,EAAE,MAAM,GACrB,aAAa,CAsHf"}
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
import { craftingProcessBytes, craftingProcessInputLines, decodeCancelCraftingData, decodeStartCraftingData, recipeInputConsumption, } from '../c4/crafting-storage.js';
|
|
1
|
+
import { craftingProcessBytes, craftingProcessEndTime, craftingProcessInputLines, decodeCancelCraftingData, decodeCompleteCraftingData, decodeStartCraftingData, recipeInputConsumption, recipeOutputLines, } from '../c4/crafting-storage.js';
|
|
2
|
+
import { characterAccountDefinition } from '../c4/character.js';
|
|
3
|
+
import { habReservedBytes } from '../c4/crafting-hab-storage.js';
|
|
4
|
+
import { decodeGameDefinitionSequences } from '../c4/game.js';
|
|
2
5
|
import { starbasePlayerAccountDefinition } from '../c4/starbase.js';
|
|
6
|
+
import { CLOCK_ADDRESS, readClock } from './faction-enrollment.js';
|
|
3
7
|
import { storageInstruction } from './profile-storage-funding-guard.js';
|
|
8
|
+
import { SageSdkError } from '../../client/errors.js';
|
|
4
9
|
import { NONE, present } from './storage-actions.js';
|
|
5
10
|
function playerLines(programs, player) {
|
|
6
11
|
return new Map(starbasePlayerAccountDefinition
|
|
7
12
|
.decode(player, programs)
|
|
8
13
|
.cargo.amounts.map(({ cargoId, amount }) => [cargoId, amount]));
|
|
9
14
|
}
|
|
10
|
-
/** Reads a Crafting Process start's or cancellation's storage
|
|
11
|
-
* bytes and fresh accounts.
|
|
12
|
-
|
|
15
|
+
/** Reads a Crafting Process start's, collection's or cancellation's storage
|
|
16
|
+
* effect from its bytes and fresh accounts. A collection's effect depends on
|
|
17
|
+
* whether it is the final one, so it is judged at `atUnixSeconds`, or at the
|
|
18
|
+
* fresh Clock when that is omitted. */
|
|
19
|
+
export function readCraftingStorageAction(programs, instruction, accounts, atUnixSeconds) {
|
|
13
20
|
const { kind } = storageInstruction(programs, instruction);
|
|
14
21
|
const metas = instruction.accounts;
|
|
15
22
|
const data = instruction.data;
|
|
@@ -18,6 +25,61 @@ export function readCraftingStorageAction(programs, instruction, accounts) {
|
|
|
18
25
|
authority: metas[0].address,
|
|
19
26
|
settlement: 'each',
|
|
20
27
|
};
|
|
28
|
+
if (kind === 'complete-crafting') {
|
|
29
|
+
const player = present(accounts, metas[7].address);
|
|
30
|
+
const process = present(accounts, metas[10].address);
|
|
31
|
+
const habAddress = metas[9].address;
|
|
32
|
+
const hab = habAddress === instruction.programAddress
|
|
33
|
+
? undefined
|
|
34
|
+
: present(accounts, habAddress);
|
|
35
|
+
// Collection first resynchronizes a Character whose research or XP
|
|
36
|
+
// predates the Game's definitions, which can resize it and change the
|
|
37
|
+
// Profile's storage debit. That growth is not projected, so a stale
|
|
38
|
+
// Character is refused before planning and again before signing.
|
|
39
|
+
const characterRaw = present(accounts, metas[4].address);
|
|
40
|
+
const character = characterAccountDefinition.decode(characterRaw, programs);
|
|
41
|
+
const game = decodeGameDefinitionSequences(programs, present(accounts, metas[5].address));
|
|
42
|
+
if (character.modifiers.seqId !== game.research ||
|
|
43
|
+
character.xp.seqId !== game.xp)
|
|
44
|
+
throw new SageSdkError('ACTION_PRECONDITION_FAILED', `Character ${characterRaw.address} predates the Game's definitions (research sequence ${character.modifiers.seqId} of ${game.research}, XP sequence ${character.xp.seqId} of ${game.xp}). Collecting resynchronizes it first, which can resize it and change the Profile's storage debit. Run the permissionless syncCharacter instruction or any SAGE action that validates the Character, then plan the collection again.`, { address: characterRaw.address });
|
|
45
|
+
const now = atUnixSeconds ?? readClock(present(accounts, CLOCK_ADDRESS));
|
|
46
|
+
// Every Recipe output may open a Starbase Player line. A collection the
|
|
47
|
+
// Process's end has reached is the final one: the Process closes, and its
|
|
48
|
+
// lamports fund the Starbase Player and the Hab's rent floor first.
|
|
49
|
+
const outputs = {
|
|
50
|
+
address: player.address,
|
|
51
|
+
held: playerLines(programs, player),
|
|
52
|
+
added: recipeOutputLines(present(accounts, metas[8].address)),
|
|
53
|
+
};
|
|
54
|
+
const habFloor = hab && {
|
|
55
|
+
address: hab.address,
|
|
56
|
+
reservedBytes: habReservedBytes(hab),
|
|
57
|
+
};
|
|
58
|
+
if (now >= craftingProcessEndTime(process))
|
|
59
|
+
return {
|
|
60
|
+
...signer,
|
|
61
|
+
settlement: 'net',
|
|
62
|
+
keyIndex: decodeCompleteCraftingData(data),
|
|
63
|
+
accounts: [
|
|
64
|
+
outputs,
|
|
65
|
+
...(habFloor ? [habFloor] : []),
|
|
66
|
+
{ address: process.address, closes: true },
|
|
67
|
+
],
|
|
68
|
+
};
|
|
69
|
+
// A partial collection from a Hab Process settles the Starbase Player,
|
|
70
|
+
// the Process, the Hab at its rent floor and the Character as one group;
|
|
71
|
+
// without a Hab, the Starbase Player and the Process each settle alone.
|
|
72
|
+
return {
|
|
73
|
+
...signer,
|
|
74
|
+
settlement: habFloor ? 'net' : 'each',
|
|
75
|
+
keyIndex: decodeCompleteCraftingData(data),
|
|
76
|
+
accounts: [
|
|
77
|
+
outputs,
|
|
78
|
+
{ address: process.address },
|
|
79
|
+
...(habFloor ? [habFloor, { address: characterRaw.address }] : []),
|
|
80
|
+
],
|
|
81
|
+
};
|
|
82
|
+
}
|
|
21
83
|
if (kind === 'cancel-crafting') {
|
|
22
84
|
// Returned inputs can reopen Starbase Player lines, which the program
|
|
23
85
|
// funds before the closed Process refunds its rent.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crafting-storage-actions.js","sourceRoot":"","sources":["../../../src/internal/planning/crafting-storage-actions.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,wBAAwB,EACxB,uBAAuB,EACvB,sBAAsB,
|
|
1
|
+
{"version":3,"file":"crafting-storage-actions.js","sourceRoot":"","sources":["../../../src/internal/planning/crafting-storage-actions.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,yBAAyB,EACzB,wBAAwB,EACxB,0BAA0B,EAC1B,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAsB,MAAM,sBAAsB,CAAC;AAEzE,SAAS,WAAW,CAAC,QAA8B,EAAE,MAAkB;IACrE,OAAO,IAAI,GAAG,CACZ,+BAA+B;SAC5B,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC;SACxB,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CACjE,CAAC;AACJ,CAAC;AAED;;;uCA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AAC,OAAO,CAAC,CAAC;IACpD,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAE,CAAC,OAAO,CAAC,CAAC;IACpD,OAAO;QACL,GAAG,MAAM;QACT,UAAU,EAAE,KAAK;QACjB,QAAQ;QACR,QAAQ,EAAE;YACR;gBACE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAE,CAAC,OAAO;gBAC1B,OAAO,EAAE,IAAI;gBACb,WAAW,EAAE,oBAAoB,CAAC,MAAM,CAAC;aAC1C;YACD;gBACE,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,IAAI,EAAE,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC;gBACnC,KAAK,EAAE,IAAI;gBACX,OAAO,EAAE,sBAAsB,CAAC,MAAM,EAAE,QAAQ,CAAC;aAClD;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"currency-cache-guard.d.ts","sourceRoot":"","sources":["../../../src/internal/planning/currency-cache-guard.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"currency-cache-guard.d.ts","sourceRoot":"","sources":["../../../src/internal/planning/currency-cache-guard.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAe1E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEtE;;uEAEuE;AACvE,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,oBAAoB,EAC9B,KAAK,EAAE,SAAS,QAAQ,EAAE,EAC1B,MAAM,EAAE,SAAS,gBAAgB,EAAE,GAClC,IAAI,CA2GN"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AccountRole } from '@solana/kit';
|
|
2
2
|
import { SageSdkError } from '../../client/errors.js';
|
|
3
|
-
import { ATTACK_STARBASE_DISCRIMINATOR, CANCEL_CLAIM_STAKE_BUILDING_DESIGN_DISCRIMINATOR, DECONSTRUCT_CLAIM_STAKE_INSTANCE_DISCRIMINATOR, FINALIZE_BUILDING_CHANGES_DISCRIMINATOR, START_CLAIM_STAKES_FLEET_TRANSFER_DISCRIMINATOR, START_SUBWARP_DISCRIMINATOR, WARP_LANE_DISCRIMINATOR, WARP_TO_COORDINATE_DISCRIMINATOR, } from '../c4/discriminators.js';
|
|
3
|
+
import { ATTACK_STARBASE_DISCRIMINATOR, CANCEL_CLAIM_STAKE_BUILDING_DESIGN_DISCRIMINATOR, CLAIM_STAKES_RESOURCE_PRODUCTION_DISCRIMINATOR, DECONSTRUCT_CLAIM_STAKE_INSTANCE_DISCRIMINATOR, EXIT_CLAIM_STAKES_FLEET_TRANSFER_DISCRIMINATOR, FINALIZE_BUILDING_CHANGES_DISCRIMINATOR, SETTLE_CLAIM_STAKE_BUILDING_XP_DISCRIMINATOR, SETTLE_HAB_BUILDING_XP_DISCRIMINATOR, START_CLAIM_STAKES_FLEET_TRANSFER_DISCRIMINATOR, START_SUBWARP_DISCRIMINATOR, WARP_LANE_DISCRIMINATOR, WARP_TO_COORDINATE_DISCRIMINATOR, } from '../c4/discriminators.js';
|
|
4
4
|
/** Bind the cache guard, the region-access guard of a warp lane's destination
|
|
5
5
|
* or a Starbase attack's target, and a coordinate movement's region-path
|
|
6
6
|
* guard to generated instruction metas, independently of Plan kind. */
|
|
@@ -13,7 +13,11 @@ export function validateCurrencyInstructions(programs, steps, guards) {
|
|
|
13
13
|
[CANCEL_CLAIM_STAKE_BUILDING_DESIGN_DISCRIMINATOR, 0, 9],
|
|
14
14
|
[FINALIZE_BUILDING_CHANGES_DISCRIMINATOR, 0, 10],
|
|
15
15
|
[START_CLAIM_STAKES_FLEET_TRANSFER_DISCRIMINATOR, 10, 9],
|
|
16
|
+
[EXIT_CLAIM_STAKES_FLEET_TRANSFER_DISCRIMINATOR, 8, 7],
|
|
17
|
+
[CLAIM_STAKES_RESOURCE_PRODUCTION_DISCRIMINATOR, 7, 6],
|
|
16
18
|
[DECONSTRUCT_CLAIM_STAKE_INSTANCE_DISCRIMINATOR, 5, 15],
|
|
19
|
+
[SETTLE_CLAIM_STAKE_BUILDING_XP_DISCRIMINATOR, 0, 10],
|
|
20
|
+
[SETTLE_HAB_BUILDING_XP_DISCRIMINATOR, 0, 9],
|
|
17
21
|
];
|
|
18
22
|
for (const [index, { instruction }] of steps.entries()) {
|
|
19
23
|
if (instruction.programAddress !== programs.sage)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"currency-cache-guard.js","sourceRoot":"","sources":["../../../src/internal/planning/currency-cache-guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EACL,6BAA6B,EAC7B,gDAAgD,EAChD,8CAA8C,EAC9C,uCAAuC,EACvC,+CAA+C,EAC/C,2BAA2B,EAC3B,uBAAuB,EACvB,gCAAgC,GACjC,MAAM,yBAAyB,CAAC;AAGjC;;uEAEuE;AACvE,MAAM,UAAU,4BAA4B,CAC1C,QAA8B,EAC9B,KAA0B,EAC1B,MAAmC;IAEnC,0EAA0E;IAC1E,kDAAkD;IAClD,oEAAoE;IACpE,MAAM,OAAO,GAAG;QACd,CAAC,uBAAuB,EAAE,CAAC,EAAE,CAAC,CAAC;QAC/B,CAAC,gDAAgD,EAAE,CAAC,EAAE,CAAC,CAAC;QACxD,CAAC,uCAAuC,EAAE,CAAC,EAAE,EAAE,CAAC;QAChD,CAAC,+CAA+C,EAAE,EAAE,EAAE,CAAC,CAAC;QACxD,CAAC,8CAA8C,EAAE,CAAC,EAAE,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"currency-cache-guard.js","sourceRoot":"","sources":["../../../src/internal/planning/currency-cache-guard.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
3
|
+
import type { PlanPrecondition, PlanStep } from '../../planning/index.js';
|
|
4
|
+
import { type GameDecodeScope } from '../c4/game.js';
|
|
5
|
+
/** The Character check-in state and chain-day window a check-in must still
|
|
6
|
+
* find when it executes. */
|
|
7
|
+
export type DailyCheckInGuard = Extract<PlanPrecondition, {
|
|
8
|
+
readonly kind: 'daily-check-in';
|
|
9
|
+
}>;
|
|
10
|
+
/** Seconds per check-in day. */
|
|
11
|
+
export declare const CHECK_IN_DAY_SECONDS = 86400n;
|
|
12
|
+
/** The Game's check-in rules a projection needs, in raw stored units. */
|
|
13
|
+
export interface CheckInRules {
|
|
14
|
+
readonly xpBase: bigint;
|
|
15
|
+
readonly streakBonusXp: bigint;
|
|
16
|
+
readonly streakBuyBackCostRaw: bigint;
|
|
17
|
+
readonly streakBuyBackMaxDays: number;
|
|
18
|
+
readonly minimumCheckInIntervalSeconds: number;
|
|
19
|
+
readonly epochStartUnixSeconds: bigint;
|
|
20
|
+
}
|
|
21
|
+
/** What one check-in does at chain time `now`. */
|
|
22
|
+
export interface CheckInProjection {
|
|
23
|
+
/** How the streak moves: the next day continues it, and a missed day
|
|
24
|
+
* resets it to 1 unless restored. */
|
|
25
|
+
readonly kind: 'continue' | 'reset' | 'restore';
|
|
26
|
+
readonly day: bigint;
|
|
27
|
+
readonly lastDay: bigint;
|
|
28
|
+
readonly streakBefore: number;
|
|
29
|
+
readonly streakAfter: number;
|
|
30
|
+
readonly xp: bigint;
|
|
31
|
+
/** Check-in days from the last check-in to today, when restoring. */
|
|
32
|
+
readonly restoreDays?: bigint;
|
|
33
|
+
readonly restoreCostRaw?: bigint;
|
|
34
|
+
/** The window, on the chain Clock, in which the check-in has this effect. */
|
|
35
|
+
readonly notBeforeUnixSeconds: bigint;
|
|
36
|
+
readonly endsAtUnixSeconds: bigint;
|
|
37
|
+
}
|
|
38
|
+
/** The chain Clock time as an ISO instant, or raw seconds when out of range. */
|
|
39
|
+
export declare function checkInInstant(unixSeconds: bigint): string;
|
|
40
|
+
/** Projects one check-in by the game's rules: at least the minimum interval
|
|
41
|
+
* after the last check-in and on a later check-in day (whole days since the
|
|
42
|
+
* Game's check-in epoch); the next day extends the streak, capped by the
|
|
43
|
+
* Character's research; a missed day resets it to 1 unless the caller restores
|
|
44
|
+
* it, which extends it instead for the Game's per-day ATLAS cost times the
|
|
45
|
+
* days since the last check-in, up to the Game's maximum. Daily XP is the base
|
|
46
|
+
* plus the streak bonus times the new streak. Refuses what the game refuses. */
|
|
47
|
+
export declare function projectDailyCheckIn(input: {
|
|
48
|
+
readonly character: Address;
|
|
49
|
+
readonly rules: CheckInRules;
|
|
50
|
+
readonly lastCheckInTime: bigint;
|
|
51
|
+
readonly streak: number;
|
|
52
|
+
readonly maximumStreak: number;
|
|
53
|
+
readonly atlasRaw: bigint;
|
|
54
|
+
readonly restore: boolean;
|
|
55
|
+
}, now: bigint): CheckInProjection;
|
|
56
|
+
/** Binds every daily check-in to exactly one check-in guard for its
|
|
57
|
+
* Character, Profile and Game whose planned restore matches the instruction's
|
|
58
|
+
* restore flag and exact cost, to a character-access guard for the research
|
|
59
|
+
* that caps its streak, and, when it restores a streak, to a writable
|
|
60
|
+
* Currency Cache with its guard, so a saved Plan cannot drop the checks that
|
|
61
|
+
* keep its streak and XP description true. */
|
|
62
|
+
export declare function validateDailyCheckInInstructions(programs: SageProgramAddresses, steps: readonly PlanStep[], guards: readonly PlanPrecondition[]): void;
|
|
63
|
+
/** Why a check-in cannot run as planned at chain time `now`, if it cannot:
|
|
64
|
+
* the Character is missing or foreign, its check-in state changed since
|
|
65
|
+
* planning, the chain Clock lies outside the planned check-in day, the game
|
|
66
|
+
* would refuse it now (for example a restore the Character can no longer
|
|
67
|
+
* pay, or research that predates the Game's research definitions), or the
|
|
68
|
+
* Game's current check-in rules give another streak, Daily XP, restore cost
|
|
69
|
+
* or check-in day than planned. */
|
|
70
|
+
export declare function dailyCheckInCause(programs: SageProgramAddresses, guard: DailyCheckInGuard, account: RawAccount | undefined, game: RawAccount | undefined, now: bigint, scope?: GameDecodeScope): string | undefined;
|
|
71
|
+
//# sourceMappingURL=daily-check-in.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daily-check-in.d.ts","sourceRoot":"","sources":["../../../src/internal/planning/daily-check-in.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAExD,OAAO,KAAK,EACV,UAAU,EACV,oBAAoB,EACrB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAG1E,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AAEvB;4BAC4B;AAC5B,MAAM,MAAM,iBAAiB,GAAG,OAAO,CACrC,gBAAgB,EAChB;IAAE,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAA;CAAE,CACpC,CAAC;AAEF,gCAAgC;AAChC,eAAO,MAAM,oBAAoB,SAAU,CAAC;AAE5C,yEAAyE;AACzE,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC,QAAQ,CAAC,6BAA6B,EAAE,MAAM,CAAC;IAC/C,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;CACxC;AAED,kDAAkD;AAClD,MAAM,WAAW,iBAAiB;IAChC;yCACqC;IACrC,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,GAAG,SAAS,CAAC;IAChD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC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@ -0,0 +1,201 @@
|
|
|
1
|
+
import { AccountRole } from '@solana/kit';
|
|
2
|
+
import { SageSdkError } from '../../client/errors.js';
|
|
3
|
+
import { characterAccountDefinition } from '../c4/character.js';
|
|
4
|
+
import { DAILY_CHECK_IN_DISCRIMINATOR } from '../c4/discriminators.js';
|
|
5
|
+
import { decodeGameDailyCheckInRules, } from '../c4/game.js';
|
|
6
|
+
/** Seconds per check-in day. */
|
|
7
|
+
export const CHECK_IN_DAY_SECONDS = 86400n;
|
|
8
|
+
function fail(message, address) {
|
|
9
|
+
throw new SageSdkError('ACTION_PRECONDITION_FAILED', message, { address });
|
|
10
|
+
}
|
|
11
|
+
/** The chain Clock time as an ISO instant, or raw seconds when out of range. */
|
|
12
|
+
export function checkInInstant(unixSeconds) {
|
|
13
|
+
return unixSeconds > 8640000000000n || unixSeconds < -8640000000000n
|
|
14
|
+
? `Unix time ${String(unixSeconds)}`
|
|
15
|
+
: new Date(Number(unixSeconds) * 1000).toISOString();
|
|
16
|
+
}
|
|
17
|
+
/** Projects one check-in by the game's rules: at least the minimum interval
|
|
18
|
+
* after the last check-in and on a later check-in day (whole days since the
|
|
19
|
+
* Game's check-in epoch); the next day extends the streak, capped by the
|
|
20
|
+
* Character's research; a missed day resets it to 1 unless the caller restores
|
|
21
|
+
* it, which extends it instead for the Game's per-day ATLAS cost times the
|
|
22
|
+
* days since the last check-in, up to the Game's maximum. Daily XP is the base
|
|
23
|
+
* plus the streak bonus times the new streak. Refuses what the game refuses. */
|
|
24
|
+
export function projectDailyCheckIn(input, now) {
|
|
25
|
+
const { rules, character } = input;
|
|
26
|
+
// Whole days, truncated toward zero as the game computes them.
|
|
27
|
+
const lastDay = (input.lastCheckInTime - rules.epochStartUnixSeconds) /
|
|
28
|
+
CHECK_IN_DAY_SECONDS;
|
|
29
|
+
const day = (now - rules.epochStartUnixSeconds) / CHECK_IN_DAY_SECONDS;
|
|
30
|
+
if (lastDay < 0n || day < 0n)
|
|
31
|
+
fail(`Character ${character}'s last check-in or the chain time falls before the Game's check-in epoch (${checkInInstant(rules.epochStartUnixSeconds)}), which the game rejects. Wait for the Game's check-in rules to be corrected, then replan.`, character);
|
|
32
|
+
const notBefore = input.lastCheckInTime + BigInt(rules.minimumCheckInIntervalSeconds);
|
|
33
|
+
if (now < notBefore)
|
|
34
|
+
fail(`Character ${character} checked in at ${checkInInstant(input.lastCheckInTime)}, and the Game requires ${rules.minimumCheckInIntervalSeconds} seconds between check-ins. Replan at or after ${checkInInstant(notBefore)}.`, character);
|
|
35
|
+
const dayStart = rules.epochStartUnixSeconds + day * CHECK_IN_DAY_SECONDS;
|
|
36
|
+
const endsAt = dayStart + CHECK_IN_DAY_SECONDS;
|
|
37
|
+
if (day === lastDay)
|
|
38
|
+
fail(`Character ${character} already checked in on the current check-in day. The next day starts at ${checkInInstant(endsAt)}; replan then.`, character);
|
|
39
|
+
const extended = Math.min(input.streak + 1, input.maximumStreak);
|
|
40
|
+
let kind;
|
|
41
|
+
let streakAfter;
|
|
42
|
+
let restoreDays;
|
|
43
|
+
let restoreCostRaw;
|
|
44
|
+
// The interval check keeps the chain time at or after the last check-in,
|
|
45
|
+
// so the current day is now later than the last one.
|
|
46
|
+
if (day === lastDay + 1n) {
|
|
47
|
+
if (input.restore)
|
|
48
|
+
fail(`Character ${character} checked in on the previous check-in day, so its streak continues without a restore. Plan the check-in without restoreStreak.`, character);
|
|
49
|
+
kind = 'continue';
|
|
50
|
+
streakAfter = extended;
|
|
51
|
+
}
|
|
52
|
+
else if (input.restore) {
|
|
53
|
+
restoreDays = day - lastDay;
|
|
54
|
+
if (restoreDays > BigInt(rules.streakBuyBackMaxDays))
|
|
55
|
+
fail(`Character ${character}'s last check-in was ${String(restoreDays)} check-in days ago, more than the ${rules.streakBuyBackMaxDays} days the Game lets a streak be restored. Plan the check-in without restoreStreak, which starts a new streak.`, character);
|
|
56
|
+
restoreCostRaw = rules.streakBuyBackCostRaw * restoreDays;
|
|
57
|
+
if (input.atlasRaw < restoreCostRaw)
|
|
58
|
+
fail(`Restoring Character ${character}'s streak costs ${String(restoreCostRaw)} ATLAS Floyds (100,000,000 Floyds per ATLAS); the Character holds ${String(input.atlasRaw)}. Deposit ATLAS to the Character, or plan without restoreStreak, then replan.`, character);
|
|
59
|
+
kind = 'restore';
|
|
60
|
+
streakAfter = extended;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
kind = 'reset';
|
|
64
|
+
streakAfter = 1;
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
kind,
|
|
68
|
+
day,
|
|
69
|
+
lastDay,
|
|
70
|
+
streakBefore: input.streak,
|
|
71
|
+
streakAfter,
|
|
72
|
+
xp: rules.xpBase + rules.streakBonusXp * BigInt(streakAfter),
|
|
73
|
+
...(restoreDays === undefined || restoreCostRaw === undefined
|
|
74
|
+
? {}
|
|
75
|
+
: { restoreDays, restoreCostRaw }),
|
|
76
|
+
notBeforeUnixSeconds: notBefore > dayStart ? notBefore : dayStart,
|
|
77
|
+
endsAtUnixSeconds: endsAt,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const ACCOUNTS = 7;
|
|
81
|
+
const CHARACTER = 4;
|
|
82
|
+
const CACHE = 5;
|
|
83
|
+
const GAME = 6;
|
|
84
|
+
function refuse(cause) {
|
|
85
|
+
throw new SageSdkError('ACTION_PRECONDITION_FAILED', `${cause} Refresh the Character and recreate the Plan with planDailyCheckIn.`);
|
|
86
|
+
}
|
|
87
|
+
/** Binds every daily check-in to exactly one check-in guard for its
|
|
88
|
+
* Character, Profile and Game whose planned restore matches the instruction's
|
|
89
|
+
* restore flag and exact cost, to a character-access guard for the research
|
|
90
|
+
* that caps its streak, and, when it restores a streak, to a writable
|
|
91
|
+
* Currency Cache with its guard, so a saved Plan cannot drop the checks that
|
|
92
|
+
* keep its streak and XP description true. */
|
|
93
|
+
export function validateDailyCheckInInstructions(programs, steps, guards) {
|
|
94
|
+
const checkIns = guards.filter((guard) => guard.kind === 'daily-check-in');
|
|
95
|
+
const used = new Set();
|
|
96
|
+
for (const { instruction } of steps) {
|
|
97
|
+
if (instruction.programAddress !== programs.sage ||
|
|
98
|
+
!DAILY_CHECK_IN_DISCRIMINATOR.every((byte, index) => instruction.data?.[index] === byte))
|
|
99
|
+
continue;
|
|
100
|
+
const metas = instruction.accounts;
|
|
101
|
+
const data = instruction.data;
|
|
102
|
+
// Discriminator, u16 key index, restore flag, then the optional cost.
|
|
103
|
+
const restore = data.length === 20 && data[10] === 1 && data[11] === 1;
|
|
104
|
+
if (metas?.length !== ACCOUNTS ||
|
|
105
|
+
!(restore || (data.length === 12 && data[10] === 0 && data[11] === 0)) ||
|
|
106
|
+
metas[1].role !== AccountRole.WRITABLE ||
|
|
107
|
+
metas[CHARACTER].role !== AccountRole.WRITABLE ||
|
|
108
|
+
metas[GAME].role !== AccountRole.READONLY)
|
|
109
|
+
refuse('A daily check-in has an unsupported account or data layout.');
|
|
110
|
+
const character = metas[CHARACTER].address;
|
|
111
|
+
const bound = checkIns.filter((guard) => guard.address === character &&
|
|
112
|
+
guard.profile === metas[1].address &&
|
|
113
|
+
guard.game === metas[GAME].address);
|
|
114
|
+
if (bound.length !== 1 || used.has(bound[0]))
|
|
115
|
+
refuse('A daily check-in must carry exactly one daily-check-in guard bound to its Character, Profile and Game.');
|
|
116
|
+
const guard = bound[0];
|
|
117
|
+
used.add(guard);
|
|
118
|
+
const cost = restore
|
|
119
|
+
? new DataView(data.buffer, data.byteOffset + 12, 8).getBigUint64(0, true)
|
|
120
|
+
: 0n;
|
|
121
|
+
if (guard.restoreDays > 0 !== restore || guard.restoreCostRaw !== cost)
|
|
122
|
+
refuse('A daily check-in guard must record the same streak restore and exact cost as its instruction.');
|
|
123
|
+
if (!guards.some((guard) => guard.kind === 'character-access' && guard.address === character))
|
|
124
|
+
refuse(`A daily check-in must keep the character-access guard on Character ${character}, whose research caps the streak.`);
|
|
125
|
+
const cache = metas[CACHE];
|
|
126
|
+
if (restore
|
|
127
|
+
? cache.role !== AccountRole.WRITABLE ||
|
|
128
|
+
!guards.some((guard) => guard.kind === 'currency-cache' &&
|
|
129
|
+
guard.address === cache.address &&
|
|
130
|
+
guard.game === metas[GAME].address)
|
|
131
|
+
: cache.address !== programs.sage || cache.role !== AccountRole.READONLY)
|
|
132
|
+
refuse('A streak restore needs the Game Currency Cache with its guard, and a check-in without a restore passes none.');
|
|
133
|
+
}
|
|
134
|
+
if (checkIns.some((guard) => !used.has(guard)))
|
|
135
|
+
refuse('Every daily-check-in guard needs the check-in it checks.');
|
|
136
|
+
}
|
|
137
|
+
/** Why a check-in cannot run as planned at chain time `now`, if it cannot:
|
|
138
|
+
* the Character is missing or foreign, its check-in state changed since
|
|
139
|
+
* planning, the chain Clock lies outside the planned check-in day, the game
|
|
140
|
+
* would refuse it now (for example a restore the Character can no longer
|
|
141
|
+
* pay, or research that predates the Game's research definitions), or the
|
|
142
|
+
* Game's current check-in rules give another streak, Daily XP, restore cost
|
|
143
|
+
* or check-in day than planned. */
|
|
144
|
+
export function dailyCheckInCause(programs, guard, account, game, now, scope) {
|
|
145
|
+
let character;
|
|
146
|
+
try {
|
|
147
|
+
character =
|
|
148
|
+
account === undefined
|
|
149
|
+
? undefined
|
|
150
|
+
: characterAccountDefinition.decode(account, programs);
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
character = undefined;
|
|
154
|
+
}
|
|
155
|
+
if (character === undefined ||
|
|
156
|
+
character.game !== guard.game ||
|
|
157
|
+
character.playerProfile !== guard.profile)
|
|
158
|
+
return `Character ${guard.address} is missing or no longer belongs to Profile ${guard.profile} in the configured Game. Refresh the Character and recreate the Plan with planDailyCheckIn.`;
|
|
159
|
+
if (character.checkIn.lastCheckInTime !== guard.lastCheckInTime ||
|
|
160
|
+
character.checkIn.streak !== guard.streak)
|
|
161
|
+
return `Character ${guard.address}'s check-in changed since planning (last check-in ${checkInInstant(character.checkIn.lastCheckInTime)}, streak ${character.checkIn.streak}), so it may already have checked in today. Refresh the Character and recreate the Plan with planDailyCheckIn.`;
|
|
162
|
+
if (now < guard.notBeforeUnixSeconds)
|
|
163
|
+
return `The check-in is planned for ${checkInInstant(guard.notBeforeUnixSeconds)} or later (chain time ${checkInInstant(now)}), and the game refuses it earlier. Wait, then execute the Plan.`;
|
|
164
|
+
if (now >= guard.endsAtUnixSeconds)
|
|
165
|
+
return `The planned check-in day ended at ${checkInInstant(guard.endsAtUnixSeconds)}, so the streak and Daily XP the Plan describes no longer apply. Recreate the Plan with planDailyCheckIn.`;
|
|
166
|
+
let rules;
|
|
167
|
+
try {
|
|
168
|
+
rules = decodeGameDailyCheckInRules(programs, game, scope);
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
return `Game ${guard.game}'s check-in rules could not be read. Refresh the Game and recreate the Plan with planDailyCheckIn.`;
|
|
172
|
+
}
|
|
173
|
+
if (character.modifiers.seqId !== rules.researchSequenceId)
|
|
174
|
+
return `Character ${guard.address}'s research predates the Game's research definitions (sequence ${character.modifiers.seqId} of ${rules.researchSequenceId}). The game resynchronizes it before checking in, which can change the streak cap. Run the permissionless syncCharacter instruction or any SAGE action that validates the Character, then recreate the Plan with planDailyCheckIn.`;
|
|
175
|
+
let projection;
|
|
176
|
+
try {
|
|
177
|
+
projection = projectDailyCheckIn({
|
|
178
|
+
character: guard.address,
|
|
179
|
+
rules,
|
|
180
|
+
lastCheckInTime: guard.lastCheckInTime,
|
|
181
|
+
streak: guard.streak,
|
|
182
|
+
maximumStreak: character.modifiers.values.maxDailyStreakLength,
|
|
183
|
+
atlasRaw: character.atlasRaw,
|
|
184
|
+
restore: guard.restoreDays > 0,
|
|
185
|
+
}, now);
|
|
186
|
+
}
|
|
187
|
+
catch (error) {
|
|
188
|
+
// The game would refuse it now, for the reason and remedy given.
|
|
189
|
+
return error.message;
|
|
190
|
+
}
|
|
191
|
+
const restoreCost = projection.restoreCostRaw ?? 0n;
|
|
192
|
+
if (projection.streakAfter !== guard.streakAfter ||
|
|
193
|
+
projection.xp !== guard.dailyXp ||
|
|
194
|
+
Number(projection.restoreDays ?? 0n) !== guard.restoreDays ||
|
|
195
|
+
restoreCost !== guard.restoreCostRaw ||
|
|
196
|
+
projection.notBeforeUnixSeconds !== guard.notBeforeUnixSeconds ||
|
|
197
|
+
projection.endsAtUnixSeconds !== guard.endsAtUnixSeconds)
|
|
198
|
+
return `Game ${guard.game}'s check-in rules or Character ${guard.address}'s streak cap changed since planning: the check-in now runs until ${checkInInstant(projection.endsAtUnixSeconds)} and gives streak ${projection.streakAfter} and ${String(projection.xp)} Daily XP${restoreCost > 0n ? ` for ${String(restoreCost)} ATLAS Floyds` : ''}, not the planned streak ${guard.streakAfter} and ${String(guard.dailyXp)} Daily XP${guard.restoreCostRaw > 0n ? ` for ${String(guard.restoreCostRaw)} ATLAS Floyds` : ''}. Recreate the Plan with planDailyCheckIn.`;
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=daily-check-in.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daily-check-in.js","sourceRoot":"","sources":["../../../src/internal/planning/daily-check-in.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgB,MAAM,aAAa,CAAC;AAMxD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EACL,2BAA2B,GAE5B,MAAM,eAAe,CAAC;AASvB,gCAAgC;AAChC,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAO,CAAC;AA8B5C,SAAS,IAAI,CAAC,OAAe,EAAE,OAAgB;IAC7C,MAAM,IAAI,YAAY,CAAC,4BAA4B,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;AAC7E,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,cAAc,CAAC,WAAmB;IA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AAiB,CAAC,qBAAqB,UAAU,CAAC,WAAW,QAAQ,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,YAAY,WAAW,GAAG,EAAE,CAAC,CAAC,CAAC,QAAQ,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,4BAA4B,KAAK,CAAC,WAAW,QAAQ,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,KAAK,CAAC,cAAc,GAAG,EAAE,CAAC,CAAC,CAAC,QAAQ,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,4CAA4C,CAAC;IACxiB,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -10,6 +10,21 @@ interface HistoryScope {
|
|
|
10
10
|
readonly system: Address;
|
|
11
11
|
readonly address: Address;
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* The highest value the game accepts for each Democracy history policy
|
|
15
|
+
* choice; every choice starts at 1. The no-controller and zero-power revenue
|
|
16
|
+
* routes and the successor baseline each offer three choices, and capture
|
|
17
|
+
* eligibility offers two. Atlas Kit only carries these values to detect a
|
|
18
|
+
* changed policy; it does not interpret them.
|
|
19
|
+
*/
|
|
20
|
+
export declare const DEMOCRACY_POLICY_FLAG_MAXIMUM: {
|
|
21
|
+
readonly noControllerRevenue: 3;
|
|
22
|
+
readonly zeroPowerRevenue: 3;
|
|
23
|
+
readonly successorBaseline: 3;
|
|
24
|
+
readonly captureIncomingEligibility: 2;
|
|
25
|
+
};
|
|
26
|
+
/** Whether every Democracy history policy choice is one the game accepts. */
|
|
27
|
+
export declare function validDemocracyPolicyFlags(flags: Readonly<Record<keyof typeof DEMOCRACY_POLICY_FLAG_MAXIMUM, number>>): boolean;
|
|
13
28
|
export type HistoryIntent = HistoryScope & ({
|
|
14
29
|
readonly state: 'absent';
|
|
15
30
|
} | {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"democracy-history.d.ts","source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