@aephia/atlas-kit 0.6.0-next.40 → 0.6.0-next.41
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/fleets/actions/index.d.ts +6 -10
- package/dist/fleets/actions/index.d.ts.map +1 -1
- package/dist/fleets/actions/index.js +18 -39
- package/dist/fleets/actions/index.js.map +1 -1
- package/dist/internal/c4/cargo-bytes-config.d.ts +1 -1
- package/dist/internal/c4/cargo-bytes-config.d.ts.map +1 -1
- package/dist/internal/c4/cargo-bytes-config.js +1 -1
- package/dist/internal/c4/cargo-bytes-config.js.map +1 -1
- package/dist/internal/planning/arrival-guards.d.ts +2 -2
- package/dist/internal/planning/arrival-guards.d.ts.map +1 -1
- package/dist/internal/planning/arrival-guards.js +57 -101
- package/dist/internal/planning/arrival-guards.js.map +1 -1
- package/dist/internal/planning/authorization-adapter.d.ts +0 -6
- package/dist/internal/planning/authorization-adapter.d.ts.map +1 -1
- package/dist/internal/planning/authorization-adapter.js +0 -16
- package/dist/internal/planning/authorization-adapter.js.map +1 -1
- package/dist/internal/planning/faction-trade-guards.d.ts +7 -7
- package/dist/internal/planning/faction-trade-guards.d.ts.map +1 -1
- package/dist/internal/planning/faction-trade-guards.js +3 -6
- package/dist/internal/planning/faction-trade-guards.js.map +1 -1
- package/dist/internal/planning/faction-trade-state.d.ts +2 -2
- package/dist/internal/planning/faction-trade-state.d.ts.map +1 -1
- package/dist/internal/planning/faction-trade-state.js +3 -3
- package/dist/internal/planning/faction-trade-state.js.map +1 -1
- package/dist/internal/planning/fleet-arrival.d.ts +11 -22
- package/dist/internal/planning/fleet-arrival.d.ts.map +1 -1
- package/dist/internal/planning/fleet-arrival.js +44 -79
- package/dist/internal/planning/fleet-arrival.js.map +1 -1
- package/dist/internal/planning/runtime-guards.d.ts.map +1 -1
- package/dist/internal/planning/runtime-guards.js +4 -6
- package/dist/internal/planning/runtime-guards.js.map +1 -1
- package/dist/internal/planning/xp-runtime.d.ts +2 -2
- package/dist/internal/planning/xp-runtime.d.ts.map +1 -1
- package/dist/internal/planning/xp-runtime.js +1 -3
- package/dist/internal/planning/xp-runtime.js.map +1 -1
- package/dist/mining/actions/index.d.ts +6 -9
- package/dist/mining/actions/index.d.ts.map +1 -1
- package/dist/mining/actions/index.js +7 -10
- package/dist/mining/actions/index.js.map +1 -1
- package/dist/planning/execution.d.ts.map +1 -1
- package/dist/planning/execution.js +7 -11
- package/dist/planning/execution.js.map +1 -1
- package/dist/planning/index.d.ts +13 -408
- package/dist/planning/index.d.ts.map +1 -1
- package/dist/planning/index.js +110 -332
- package/dist/planning/index.js.map +1 -1
- package/dist/registry/cargo.d.ts +3 -6
- package/dist/registry/cargo.d.ts.map +1 -1
- package/dist/registry/cargo.js +8 -13
- package/dist/registry/cargo.js.map +1 -1
- package/package.json +1 -1
- package/dist/internal/c4/legacy-cargo-config.d.ts +0 -6
- package/dist/internal/c4/legacy-cargo-config.d.ts.map +0 -1
- package/dist/internal/c4/legacy-cargo-config.js +0 -26
- package/dist/internal/c4/legacy-cargo-config.js.map +0 -1
package/dist/planning/index.js
CHANGED
|
@@ -163,13 +163,13 @@ function normalizeSemanticFact(value, field) {
|
|
|
163
163
|
}
|
|
164
164
|
return invalid(`${field}.kind`, semantic.kind, 'one of exclusive, requires, invalidates, or transition');
|
|
165
165
|
}
|
|
166
|
-
function normalizePrecondition(value, field
|
|
166
|
+
function normalizePrecondition(value, field) {
|
|
167
167
|
const precondition = readRecord(value, field);
|
|
168
|
-
if (
|
|
168
|
+
if (precondition.kind === 'fleet-arrival')
|
|
169
169
|
return normalizeArrivalGuard(precondition, field);
|
|
170
|
-
if (
|
|
170
|
+
if (isRuntimeGuard(precondition))
|
|
171
171
|
return normalizeRuntimeGuard(precondition, field);
|
|
172
|
-
if (
|
|
172
|
+
if (precondition.kind === 'ship-import-funding') {
|
|
173
173
|
assertKeys(precondition, field, [
|
|
174
174
|
'kind',
|
|
175
175
|
'address',
|
|
@@ -200,7 +200,7 @@ function normalizePrecondition(value, field, version = 17) {
|
|
|
200
200
|
describes: readString(precondition.describes, `${field}.describes`),
|
|
201
201
|
});
|
|
202
202
|
}
|
|
203
|
-
if (
|
|
203
|
+
if (precondition.kind === 'fleet-mining') {
|
|
204
204
|
assertKeys(precondition, field, [
|
|
205
205
|
'kind',
|
|
206
206
|
'address',
|
|
@@ -218,18 +218,15 @@ function normalizePrecondition(value, field, version = 17) {
|
|
|
218
218
|
describes: readString(precondition.describes, `${field}.describes`),
|
|
219
219
|
});
|
|
220
220
|
}
|
|
221
|
-
if (
|
|
222
|
-
isFactionTradeGuard(precondition) &&
|
|
223
|
-
(version >= 14 || !precondition.kind.endsWith('-versioned'))) {
|
|
221
|
+
if (isFactionTradeGuard(precondition)) {
|
|
224
222
|
const kind = precondition.kind;
|
|
225
|
-
const versioned = kind.endsWith('-versioned');
|
|
226
223
|
assertKeys(precondition, field, [
|
|
227
224
|
'kind',
|
|
228
225
|
'address',
|
|
229
226
|
'game',
|
|
230
227
|
'factionId',
|
|
231
228
|
'describes',
|
|
232
|
-
|
|
229
|
+
'schemaVersion',
|
|
233
230
|
...(isTradeBuyGuard(precondition)
|
|
234
231
|
? ['cargoId', 'floorRaw']
|
|
235
232
|
: isTradeSellGuard(precondition)
|
|
@@ -254,7 +251,7 @@ function normalizePrecondition(value, field, version = 17) {
|
|
|
254
251
|
address: readAddress(precondition.address, `${field}.address`),
|
|
255
252
|
game: readAddress(precondition.game, `${field}.game`),
|
|
256
253
|
factionId: unsigned('factionId'),
|
|
257
|
-
|
|
254
|
+
schemaVersion: unsigned('schemaVersion', 255),
|
|
258
255
|
describes: readString(precondition.describes, `${field}.describes`),
|
|
259
256
|
};
|
|
260
257
|
if (isTradeBuyGuard(precondition))
|
|
@@ -273,7 +270,7 @@ function normalizePrecondition(value, field, version = 17) {
|
|
|
273
270
|
});
|
|
274
271
|
return Object.freeze({ kind, ...common });
|
|
275
272
|
}
|
|
276
|
-
if (
|
|
273
|
+
if (precondition.kind === 'fleet-add-ship') {
|
|
277
274
|
assertKeys(precondition, field, [
|
|
278
275
|
'kind',
|
|
279
276
|
'address',
|
|
@@ -321,7 +318,7 @@ function normalizePrecondition(value, field, version = 17) {
|
|
|
321
318
|
describes: readString(precondition.describes, `${field}.describes`),
|
|
322
319
|
});
|
|
323
320
|
}
|
|
324
|
-
if (
|
|
321
|
+
if (precondition.kind === 'fleet-create') {
|
|
325
322
|
assertKeys(precondition, field, [
|
|
326
323
|
'kind',
|
|
327
324
|
'address',
|
|
@@ -363,7 +360,7 @@ function normalizePrecondition(value, field, version = 17) {
|
|
|
363
360
|
describes: readString(precondition.describes, `${field}.describes`),
|
|
364
361
|
});
|
|
365
362
|
}
|
|
366
|
-
if (
|
|
363
|
+
if (precondition.kind === 'system-account-or-absent') {
|
|
367
364
|
assertKeys(precondition, field, ['kind', 'address', 'describes']);
|
|
368
365
|
return Object.freeze({
|
|
369
366
|
kind: 'system-account-or-absent',
|
|
@@ -371,7 +368,7 @@ function normalizePrecondition(value, field, version = 17) {
|
|
|
371
368
|
describes: readString(precondition.describes, `${field}.describes`),
|
|
372
369
|
});
|
|
373
370
|
}
|
|
374
|
-
if (
|
|
371
|
+
if (precondition.kind === 'token-mint') {
|
|
375
372
|
assertKeys(precondition, field, [
|
|
376
373
|
'kind',
|
|
377
374
|
'address',
|
|
@@ -391,7 +388,7 @@ function normalizePrecondition(value, field, version = 17) {
|
|
|
391
388
|
describes: readString(precondition.describes, `${field}.describes`),
|
|
392
389
|
});
|
|
393
390
|
}
|
|
394
|
-
if (
|
|
391
|
+
if (precondition.kind === 'game-ship-config') {
|
|
395
392
|
assertKeys(precondition, field, [
|
|
396
393
|
'kind',
|
|
397
394
|
'address',
|
|
@@ -410,7 +407,7 @@ function normalizePrecondition(value, field, version = 17) {
|
|
|
410
407
|
describes: readString(precondition.describes, `${field}.describes`),
|
|
411
408
|
});
|
|
412
409
|
}
|
|
413
|
-
if (
|
|
410
|
+
if (precondition.kind === 'game-account') {
|
|
414
411
|
assertKeys(precondition, field, ['kind', 'address', 'describes']);
|
|
415
412
|
return Object.freeze({
|
|
416
413
|
kind: 'game-account',
|
|
@@ -418,9 +415,7 @@ function normalizePrecondition(value, field, version = 17) {
|
|
|
418
415
|
describes: readString(precondition.describes, `${field}.describes`),
|
|
419
416
|
});
|
|
420
417
|
}
|
|
421
|
-
if (
|
|
422
|
-
(version >= 4 &&
|
|
423
|
-
['token-account', 'game-cargo-config', 'cargo-cache'].includes(String(precondition.kind)))) {
|
|
418
|
+
if (['game-cargo-bytes-config', 'token-account', 'cargo-cache'].includes(String(precondition.kind))) {
|
|
424
419
|
const base = {
|
|
425
420
|
address: readAddress(precondition.address, `${field}.address`),
|
|
426
421
|
describes: readString(precondition.describes, `${field}.describes`),
|
|
@@ -447,8 +442,7 @@ function normalizePrecondition(value, field, version = 17) {
|
|
|
447
442
|
minimumBalance: amount,
|
|
448
443
|
});
|
|
449
444
|
}
|
|
450
|
-
if (precondition.kind === 'game-cargo-config'
|
|
451
|
-
precondition.kind === 'game-cargo-bytes-config') {
|
|
445
|
+
if (precondition.kind === 'game-cargo-bytes-config') {
|
|
452
446
|
assertKeys(precondition, field, [
|
|
453
447
|
'kind',
|
|
454
448
|
'address',
|
|
@@ -489,7 +483,7 @@ function normalizePrecondition(value, field, version = 17) {
|
|
|
489
483
|
bump,
|
|
490
484
|
});
|
|
491
485
|
}
|
|
492
|
-
if (precondition.kind === 'token-account-or-absent'
|
|
486
|
+
if (precondition.kind === 'token-account-or-absent') {
|
|
493
487
|
assertKeys(precondition, field, [
|
|
494
488
|
'kind',
|
|
495
489
|
'address',
|
|
@@ -505,7 +499,7 @@ function normalizePrecondition(value, field, version = 17) {
|
|
|
505
499
|
describes: readString(precondition.describes, `${field}.describes`),
|
|
506
500
|
});
|
|
507
501
|
}
|
|
508
|
-
if (precondition.kind === 'account-absent'
|
|
502
|
+
if (precondition.kind === 'account-absent') {
|
|
509
503
|
assertKeys(precondition, field, ['kind', 'address', 'describes']);
|
|
510
504
|
return Object.freeze({
|
|
511
505
|
kind: 'account-absent',
|
|
@@ -514,45 +508,7 @@ function normalizePrecondition(value, field, version = 17) {
|
|
|
514
508
|
});
|
|
515
509
|
}
|
|
516
510
|
if (precondition.kind !== 'account-state') {
|
|
517
|
-
invalid(`${field}.kind`, precondition.kind,
|
|
518
|
-
? 'the value account-state'
|
|
519
|
-
: `one of ${[
|
|
520
|
-
...(version >= 17 ? ['fleet-arrival'] : []),
|
|
521
|
-
...(version >= 16
|
|
522
|
-
? ['democracy-history', 'xp-runtime', 'governance-fees']
|
|
523
|
-
: []),
|
|
524
|
-
...(version >= 15 ? ['ship-import-funding'] : []),
|
|
525
|
-
...(version >= 14
|
|
526
|
-
? [
|
|
527
|
-
'faction-treasury-buy-versioned',
|
|
528
|
-
'faction-treasury-sell-versioned',
|
|
529
|
-
'faction-epoch-meter-versioned',
|
|
530
|
-
]
|
|
531
|
-
: []),
|
|
532
|
-
...(version >= 13 ? ['fleet-mining'] : []),
|
|
533
|
-
...(version >= 12
|
|
534
|
-
? [
|
|
535
|
-
'faction-treasury-buy',
|
|
536
|
-
'faction-treasury-sell',
|
|
537
|
-
'faction-epoch-meter',
|
|
538
|
-
]
|
|
539
|
-
: []),
|
|
540
|
-
...(version >= 11 ? ['fleet-add-ship'] : []),
|
|
541
|
-
...(version >= 10 ? ['fleet-create'] : []),
|
|
542
|
-
'account-state',
|
|
543
|
-
'account-absent',
|
|
544
|
-
...(version >= 8 ? ['system-account-or-absent'] : []),
|
|
545
|
-
...(version >= 3 ? ['token-account-or-absent'] : []),
|
|
546
|
-
...(version >= 4 ? ['token-account'] : []),
|
|
547
|
-
...(version >= 7 ? ['token-mint'] : []),
|
|
548
|
-
...(version >= 4 ? ['game-cargo-config'] : []),
|
|
549
|
-
...(version >= 9 ? ['game-cargo-bytes-config'] : []),
|
|
550
|
-
...(version >= 4 ? ['cargo-cache'] : []),
|
|
551
|
-
...(version >= 5 ? ['game-account'] : []),
|
|
552
|
-
...(version >= 6 ? ['game-ship-config'] : []),
|
|
553
|
-
]
|
|
554
|
-
.join(', ')
|
|
555
|
-
.replace(/, ([^,]+)$/u, version === 2 ? ' or $1' : ', or $1')}`);
|
|
511
|
+
invalid(`${field}.kind`, precondition.kind, 'a supported current Plan guard; recreate the Plan using the current capability planner');
|
|
556
512
|
}
|
|
557
513
|
assertKeys(precondition, field, ['kind', 'address', 'dataHash', 'describes']);
|
|
558
514
|
return Object.freeze({
|
|
@@ -588,201 +544,48 @@ function instructionToJSON(instruction) {
|
|
|
588
544
|
return deepFreeze(value);
|
|
589
545
|
}
|
|
590
546
|
function planToJSON(plan) {
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
const common = {
|
|
547
|
+
return deepFreeze({
|
|
548
|
+
v: 18,
|
|
594
549
|
kind: plan.kind,
|
|
595
550
|
summary: plan.summary,
|
|
596
551
|
affected: [...plan.affected],
|
|
597
552
|
requiredSigners: [...plan.requiredSigners],
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
:
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
: hasShipImportFunding
|
|
622
|
-
? 15
|
|
623
|
-
: plan.preconditions.some((guard) => 'schemaVersion' in guard)
|
|
624
|
-
? 14
|
|
625
|
-
: hasMiningGuard
|
|
626
|
-
? 13
|
|
627
|
-
: 12,
|
|
628
|
-
...common,
|
|
629
|
-
steps,
|
|
630
|
-
preconditions: plan.preconditions.map((guard) => {
|
|
631
|
-
if (guard.kind === 'fleet-arrival')
|
|
632
|
-
return arrivalGuardToJSON(guard);
|
|
633
|
-
if (isRuntimeGuard(guard))
|
|
634
|
-
return runtimeGuardToJSON(guard);
|
|
635
|
-
if (isTradeBuyGuard(guard))
|
|
636
|
-
return { ...guard, floorRaw: String(guard.floorRaw) };
|
|
637
|
-
if (isTradeSellGuard(guard))
|
|
638
|
-
return {
|
|
639
|
-
...guard,
|
|
640
|
-
atlasOutCapPerEpochRaw: String(guard.atlasOutCapPerEpochRaw),
|
|
641
|
-
epochLengthSeconds: String(guard.epochLengthSeconds),
|
|
642
|
-
};
|
|
643
|
-
if (guard.kind === 'fleet-add-ship')
|
|
644
|
-
return {
|
|
645
|
-
...guard,
|
|
646
|
-
amount: String(guard.amount),
|
|
647
|
-
maximumProfileDebit: String(guard.maximumProfileDebit),
|
|
648
|
-
};
|
|
649
|
-
if (guard.kind === 'fleet-create' ||
|
|
650
|
-
guard.kind === 'ship-import-funding')
|
|
651
|
-
return {
|
|
652
|
-
...guard,
|
|
653
|
-
maximumProfileDebit: String(guard.maximumProfileDebit),
|
|
654
|
-
};
|
|
655
|
-
if (guard.kind === 'token-account')
|
|
656
|
-
return { ...guard, minimumBalance: String(guard.minimumBalance) };
|
|
657
|
-
return { ...guard };
|
|
658
|
-
}),
|
|
659
|
-
});
|
|
660
|
-
}
|
|
661
|
-
if (plan.preconditions.some(({ kind }) => kind === 'fleet-add-ship')) {
|
|
662
|
-
return deepFreeze({
|
|
663
|
-
v: 11,
|
|
664
|
-
...common,
|
|
665
|
-
steps,
|
|
666
|
-
preconditions: plan.preconditions.map((guard) => guard.kind === 'fleet-add-ship'
|
|
667
|
-
? {
|
|
553
|
+
steps: plan.steps.map((step) => ({
|
|
554
|
+
instruction: instructionToJSON(step.instruction),
|
|
555
|
+
describes: step.describes,
|
|
556
|
+
...((step.semantics?.length ?? 0) > 0
|
|
557
|
+
? { semantics: step.semantics.map((semantic) => ({ ...semantic })) }
|
|
558
|
+
: {}),
|
|
559
|
+
signers: [...step.signers],
|
|
560
|
+
})),
|
|
561
|
+
preconditions: plan.preconditions.map((guard) => {
|
|
562
|
+
if (guard.kind === 'fleet-arrival')
|
|
563
|
+
return arrivalGuardToJSON(guard);
|
|
564
|
+
if (isRuntimeGuard(guard))
|
|
565
|
+
return runtimeGuardToJSON(guard);
|
|
566
|
+
if (isTradeBuyGuard(guard))
|
|
567
|
+
return { ...guard, floorRaw: String(guard.floorRaw) };
|
|
568
|
+
if (isTradeSellGuard(guard))
|
|
569
|
+
return {
|
|
570
|
+
...guard,
|
|
571
|
+
atlasOutCapPerEpochRaw: String(guard.atlasOutCapPerEpochRaw),
|
|
572
|
+
epochLengthSeconds: String(guard.epochLengthSeconds),
|
|
573
|
+
};
|
|
574
|
+
if (guard.kind === 'fleet-add-ship')
|
|
575
|
+
return {
|
|
668
576
|
...guard,
|
|
669
577
|
amount: String(guard.amount),
|
|
670
578
|
maximumProfileDebit: String(guard.maximumProfileDebit),
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
})
|
|
681
|
-
}
|
|
682
|
-
if (plan.preconditions.some(({ kind }) => kind === 'fleet-create')) {
|
|
683
|
-
return deepFreeze({
|
|
684
|
-
v: 10,
|
|
685
|
-
...common,
|
|
686
|
-
steps,
|
|
687
|
-
preconditions: plan.preconditions.map((guard) => guard.kind === 'fleet-create'
|
|
688
|
-
? { ...guard, maximumProfileDebit: String(guard.maximumProfileDebit) }
|
|
689
|
-
: guard.kind === 'token-account'
|
|
690
|
-
? { ...guard, minimumBalance: String(guard.minimumBalance) }
|
|
691
|
-
: { ...guard }),
|
|
692
|
-
});
|
|
693
|
-
}
|
|
694
|
-
if (plan.preconditions.some(({ kind }) => kind === 'game-cargo-bytes-config')) {
|
|
695
|
-
return deepFreeze({
|
|
696
|
-
v: 9,
|
|
697
|
-
...common,
|
|
698
|
-
steps,
|
|
699
|
-
preconditions: plan.preconditions.map((guard) => guard.kind === 'token-account'
|
|
700
|
-
? { ...guard, minimumBalance: String(guard.minimumBalance) }
|
|
701
|
-
: { ...guard }),
|
|
702
|
-
});
|
|
703
|
-
}
|
|
704
|
-
if (plan.preconditions.some(({ kind }) => kind === 'system-account-or-absent')) {
|
|
705
|
-
return deepFreeze({
|
|
706
|
-
v: 8,
|
|
707
|
-
...common,
|
|
708
|
-
steps,
|
|
709
|
-
preconditions: plan.preconditions.map((guard) => guard.kind === 'token-account'
|
|
710
|
-
? { ...guard, minimumBalance: String(guard.minimumBalance) }
|
|
711
|
-
: { ...guard }),
|
|
712
|
-
});
|
|
713
|
-
}
|
|
714
|
-
if (plan.preconditions.some(({ kind }) => kind === 'token-mint')) {
|
|
715
|
-
return deepFreeze({
|
|
716
|
-
v: 7,
|
|
717
|
-
...common,
|
|
718
|
-
steps,
|
|
719
|
-
preconditions: plan.preconditions.map((guard) => guard.kind === 'token-account'
|
|
720
|
-
? { ...guard, minimumBalance: String(guard.minimumBalance) }
|
|
721
|
-
: { ...guard }),
|
|
722
|
-
});
|
|
723
|
-
}
|
|
724
|
-
if (plan.preconditions.some(({ kind }) => kind === 'game-ship-config')) {
|
|
725
|
-
return deepFreeze({
|
|
726
|
-
v: 6,
|
|
727
|
-
...common,
|
|
728
|
-
steps,
|
|
729
|
-
preconditions: plan.preconditions.map((guard) => guard.kind === 'token-account'
|
|
730
|
-
? { ...guard, minimumBalance: String(guard.minimumBalance) }
|
|
731
|
-
: { ...guard }),
|
|
732
|
-
});
|
|
733
|
-
}
|
|
734
|
-
if (plan.preconditions.some(({ kind }) => kind === 'game-account')) {
|
|
735
|
-
return deepFreeze({
|
|
736
|
-
v: 5,
|
|
737
|
-
...common,
|
|
738
|
-
steps,
|
|
739
|
-
preconditions: plan.preconditions.map((guard) => guard.kind === 'token-account'
|
|
740
|
-
? { ...guard, minimumBalance: String(guard.minimumBalance) }
|
|
741
|
-
: { ...guard }),
|
|
742
|
-
});
|
|
743
|
-
}
|
|
744
|
-
if (plan.preconditions.some(({ kind }) => kind === 'token-account' ||
|
|
745
|
-
kind === 'game-cargo-config' ||
|
|
746
|
-
kind === 'cargo-cache')) {
|
|
747
|
-
return deepFreeze({
|
|
748
|
-
v: 4,
|
|
749
|
-
...common,
|
|
750
|
-
steps,
|
|
751
|
-
preconditions: plan.preconditions.map((guard) => guard.kind === 'token-account'
|
|
752
|
-
? { ...guard, minimumBalance: String(guard.minimumBalance) }
|
|
753
|
-
: { ...guard }),
|
|
754
|
-
});
|
|
755
|
-
}
|
|
756
|
-
if (plan.preconditions.some(({ kind }) => kind === 'token-account-or-absent')) {
|
|
757
|
-
return deepFreeze({
|
|
758
|
-
v: 3,
|
|
759
|
-
...common,
|
|
760
|
-
steps,
|
|
761
|
-
preconditions: plan.preconditions.map((guard) => ({
|
|
762
|
-
...guard,
|
|
763
|
-
})),
|
|
764
|
-
});
|
|
765
|
-
}
|
|
766
|
-
if (hasSemantics || hasAbsentPrecondition) {
|
|
767
|
-
return deepFreeze({
|
|
768
|
-
v: 2,
|
|
769
|
-
...common,
|
|
770
|
-
steps,
|
|
771
|
-
preconditions: plan.preconditions.map((guard) => ({
|
|
772
|
-
...guard,
|
|
773
|
-
})),
|
|
774
|
-
});
|
|
775
|
-
}
|
|
776
|
-
return deepFreeze({
|
|
777
|
-
v: 1,
|
|
778
|
-
...common,
|
|
779
|
-
steps,
|
|
780
|
-
preconditions: plan.preconditions.map((precondition) => ({
|
|
781
|
-
kind: 'account-state',
|
|
782
|
-
address: precondition.address,
|
|
783
|
-
dataHash: precondition.dataHash,
|
|
784
|
-
describes: precondition.describes,
|
|
785
|
-
})),
|
|
579
|
+
};
|
|
580
|
+
if (guard.kind === 'fleet-create' || guard.kind === 'ship-import-funding')
|
|
581
|
+
return {
|
|
582
|
+
...guard,
|
|
583
|
+
maximumProfileDebit: String(guard.maximumProfileDebit),
|
|
584
|
+
};
|
|
585
|
+
if (guard.kind === 'token-account')
|
|
586
|
+
return { ...guard, minimumBalance: String(guard.minimumBalance) };
|
|
587
|
+
return { ...guard };
|
|
588
|
+
}),
|
|
786
589
|
});
|
|
787
590
|
}
|
|
788
591
|
/** Creates an inert branded Plan while deriving every aggregate field.
|
|
@@ -851,7 +654,7 @@ function sameAddresses(actual, encoded) {
|
|
|
851
654
|
*
|
|
852
655
|
* @example
|
|
853
656
|
* ```ts
|
|
854
|
-
* declare const wire:
|
|
657
|
+
* declare const wire: PlanJson;
|
|
855
658
|
* const plan = planFromJSON(wire);
|
|
856
659
|
* console.log(plan.describe());
|
|
857
660
|
* ```
|
|
@@ -867,87 +670,66 @@ export function planFromJSON(json) {
|
|
|
867
670
|
'affected',
|
|
868
671
|
'requiredSigners',
|
|
869
672
|
]);
|
|
870
|
-
if (value.v !==
|
|
871
|
-
value.v
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
const guard = readRecord(entry, 'precondition');
|
|
893
|
-
if (version >= 17 && guard.kind === 'fleet-arrival')
|
|
894
|
-
return normalizeArrivalGuard(guard, 'precondition', true);
|
|
895
|
-
if (version >= 16 && isRuntimeGuard(guard))
|
|
896
|
-
return normalizeRuntimeGuard(guard, 'precondition', true);
|
|
897
|
-
if (version >= 12 &&
|
|
898
|
-
(isTradeBuyGuard(guard) || isTradeSellGuard(guard))) {
|
|
899
|
-
const keys = isTradeBuyGuard(guard)
|
|
900
|
-
? ['floorRaw']
|
|
901
|
-
: ['atlasOutCapPerEpochRaw', 'epochLengthSeconds'];
|
|
902
|
-
const decoded = { ...guard };
|
|
903
|
-
for (const key of keys) {
|
|
904
|
-
const raw = guard[key];
|
|
905
|
-
const pattern = key === 'epochLengthSeconds'
|
|
906
|
-
? /^(0|[1-9][0-9]*|-[1-9][0-9]*)$/
|
|
907
|
-
: /^(0|[1-9][0-9]*)$/;
|
|
908
|
-
if (typeof raw !== 'string' || !pattern.test(raw))
|
|
909
|
-
invalid(key, raw, 'a canonical decimal string');
|
|
910
|
-
decoded[key] = BigInt(raw);
|
|
911
|
-
}
|
|
912
|
-
return decoded;
|
|
673
|
+
if (value.v !== 18) {
|
|
674
|
+
throw new InvalidActionInputError('planJson.v', value.v, 'the current Plan wire version 18', 'Recreate the Plan using the current capability planner; do not change its saved version or migrate its guards.');
|
|
675
|
+
}
|
|
676
|
+
value.preconditions = readArray(value.preconditions, 'planJson.preconditions').map((entry) => {
|
|
677
|
+
const guard = readRecord(entry, 'precondition');
|
|
678
|
+
if (guard.kind === 'fleet-arrival')
|
|
679
|
+
return normalizeArrivalGuard(guard, 'precondition', true);
|
|
680
|
+
if (isRuntimeGuard(guard))
|
|
681
|
+
return normalizeRuntimeGuard(guard, 'precondition', true);
|
|
682
|
+
if (isTradeBuyGuard(guard) || isTradeSellGuard(guard)) {
|
|
683
|
+
const keys = isTradeBuyGuard(guard)
|
|
684
|
+
? ['floorRaw']
|
|
685
|
+
: ['atlasOutCapPerEpochRaw', 'epochLengthSeconds'];
|
|
686
|
+
const decoded = { ...guard };
|
|
687
|
+
for (const key of keys) {
|
|
688
|
+
const raw = guard[key];
|
|
689
|
+
const pattern = key === 'epochLengthSeconds'
|
|
690
|
+
? /^(0|[1-9][0-9]*|-[1-9][0-9]*)$/
|
|
691
|
+
: /^(0|[1-9][0-9]*)$/;
|
|
692
|
+
if (typeof raw !== 'string' || !pattern.test(raw))
|
|
693
|
+
invalid(key, raw, 'a canonical decimal string');
|
|
694
|
+
decoded[key] = BigInt(raw);
|
|
913
695
|
}
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
}
|
|
942
|
-
}
|
|
696
|
+
return decoded;
|
|
697
|
+
}
|
|
698
|
+
if (guard.kind === 'fleet-add-ship') {
|
|
699
|
+
for (const field of ['amount', 'maximumProfileDebit'])
|
|
700
|
+
if (typeof guard[field] !== 'string' ||
|
|
701
|
+
!/^(0|[1-9][0-9]*)$/.test(guard[field]))
|
|
702
|
+
invalid(field, guard[field], 'a canonical unsigned decimal string');
|
|
703
|
+
return {
|
|
704
|
+
...guard,
|
|
705
|
+
amount: BigInt(guard.amount),
|
|
706
|
+
maximumProfileDebit: BigInt(guard.maximumProfileDebit),
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
if (guard.kind === 'fleet-create' || guard.kind === 'ship-import-funding') {
|
|
710
|
+
if (typeof guard.maximumProfileDebit !== 'string' ||
|
|
711
|
+
!/^(0|[1-9][0-9]*)$/.test(guard.maximumProfileDebit))
|
|
712
|
+
invalid('maximumProfileDebit', guard.maximumProfileDebit, 'a canonical unsigned decimal string');
|
|
713
|
+
return {
|
|
714
|
+
...guard,
|
|
715
|
+
maximumProfileDebit: BigInt(guard.maximumProfileDebit),
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
if (guard.kind !== 'token-account')
|
|
719
|
+
return guard;
|
|
720
|
+
if (typeof guard.minimumBalance !== 'string' ||
|
|
721
|
+
!/^(0|[1-9][0-9]*)$/.test(guard.minimumBalance))
|
|
722
|
+
invalid('minimumBalance', guard.minimumBalance, 'a canonical unsigned decimal string');
|
|
723
|
+
return { ...guard, minimumBalance: BigInt(guard.minimumBalance) };
|
|
724
|
+
});
|
|
943
725
|
const steps = readArray(value.steps, 'planJson.steps').map((candidate, index) => {
|
|
944
726
|
const field = `planJson.steps[${String(index)}]`;
|
|
945
727
|
const step = readRecord(candidate, field);
|
|
946
|
-
assertKeys(step, field, ['instruction', 'describes', 'signers'],
|
|
728
|
+
assertKeys(step, field, ['instruction', 'describes', 'signers'], ['semantics']);
|
|
947
729
|
return {
|
|
948
730
|
instruction: readWireInstruction(step.instruction, `${field}.instruction`),
|
|
949
731
|
describes: readString(step.describes, `${field}.describes`),
|
|
950
|
-
...(
|
|
732
|
+
...(step.semantics !== undefined
|
|
951
733
|
? {
|
|
952
734
|
semantics: readArray(step.semantics, `${field}.semantics`).map((semantic, semanticIndex) => normalizeSemanticFact(semantic, `${field}.semantics[${String(semanticIndex)}]`)),
|
|
953
735
|
}
|
|
@@ -955,7 +737,7 @@ export function planFromJSON(json) {
|
|
|
955
737
|
signers: readArray(step.signers, `${field}.signers`).map((signer, signerIndex) => readAddress(signer, `${field}.signers[${String(signerIndex)}]`)),
|
|
956
738
|
};
|
|
957
739
|
});
|
|
958
|
-
const preconditions = readArray(value.preconditions, 'planJson.preconditions').map((candidate, index) => normalizePrecondition(candidate, `planJson.preconditions[${String(index)}]
|
|
740
|
+
const preconditions = readArray(value.preconditions, 'planJson.preconditions').map((candidate, index) => normalizePrecondition(candidate, `planJson.preconditions[${String(index)}]`));
|
|
959
741
|
const affected = readArray(value.affected, 'planJson.affected').map((candidate, index) => readAddress(candidate, `planJson.affected[${String(index)}]`));
|
|
960
742
|
const requiredSigners = readArray(value.requiredSigners, 'planJson.requiredSigners').map((candidate, index) => readAddress(candidate, `planJson.requiredSigners[${String(index)}]`));
|
|
961
743
|
const plan = createPlan({
|
|
@@ -1014,11 +796,7 @@ function validateFactionGuardComposition(guards) {
|
|
|
1014
796
|
`${String(guard.atlasOutCapPerEpochRaw)}:${String(guard.epochLengthSeconds)}`,
|
|
1015
797
|
]);
|
|
1016
798
|
}
|
|
1017
|
-
|
|
1018
|
-
constraints.push([
|
|
1019
|
-
`${guard.address}:schema`,
|
|
1020
|
-
String(guard.schemaVersion),
|
|
1021
|
-
]);
|
|
799
|
+
constraints.push([`${guard.address}:schema`, String(guard.schemaVersion)]);
|
|
1022
800
|
for (const [key, value] of constraints) {
|
|
1023
801
|
const previous = retained.get(key);
|
|
1024
802
|
if (previous !== undefined && previous !== value)
|