@aephia/atlas-kit 0.6.0-next.40 → 0.6.0-next.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/cargo/actions/deposit.d.ts +1 -1
  2. package/dist/cargo/actions/deposit.d.ts.map +1 -1
  3. package/dist/cargo/actions/deposit.js +2 -3
  4. package/dist/cargo/actions/deposit.js.map +1 -1
  5. package/dist/cargo/actions/withdrawal.d.ts.map +1 -1
  6. package/dist/cargo/actions/withdrawal.js +1 -2
  7. package/dist/cargo/actions/withdrawal.js.map +1 -1
  8. package/dist/fleets/actions/index.d.ts +6 -10
  9. package/dist/fleets/actions/index.d.ts.map +1 -1
  10. package/dist/fleets/actions/index.js +18 -39
  11. package/dist/fleets/actions/index.js.map +1 -1
  12. package/dist/fleets/actions/ship-import.d.ts.map +1 -1
  13. package/dist/fleets/actions/ship-import.js +1 -2
  14. package/dist/fleets/actions/ship-import.js.map +1 -1
  15. package/dist/internal/c4/cargo-bytes-config.d.ts +1 -1
  16. package/dist/internal/c4/cargo-bytes-config.d.ts.map +1 -1
  17. package/dist/internal/c4/cargo-bytes-config.js +1 -1
  18. package/dist/internal/c4/cargo-bytes-config.js.map +1 -1
  19. package/dist/internal/planning/arrival-guards.d.ts +2 -2
  20. package/dist/internal/planning/arrival-guards.d.ts.map +1 -1
  21. package/dist/internal/planning/arrival-guards.js +57 -101
  22. package/dist/internal/planning/arrival-guards.js.map +1 -1
  23. package/dist/internal/planning/authorization-adapter.d.ts +0 -6
  24. package/dist/internal/planning/authorization-adapter.d.ts.map +1 -1
  25. package/dist/internal/planning/authorization-adapter.js +0 -16
  26. package/dist/internal/planning/authorization-adapter.js.map +1 -1
  27. package/dist/internal/planning/faction-trade-guards.d.ts +7 -7
  28. package/dist/internal/planning/faction-trade-guards.d.ts.map +1 -1
  29. package/dist/internal/planning/faction-trade-guards.js +3 -6
  30. package/dist/internal/planning/faction-trade-guards.js.map +1 -1
  31. package/dist/internal/planning/faction-trade-state.d.ts +2 -2
  32. package/dist/internal/planning/faction-trade-state.d.ts.map +1 -1
  33. package/dist/internal/planning/faction-trade-state.js +3 -3
  34. package/dist/internal/planning/faction-trade-state.js.map +1 -1
  35. package/dist/internal/planning/fleet-arrival.d.ts +11 -22
  36. package/dist/internal/planning/fleet-arrival.d.ts.map +1 -1
  37. package/dist/internal/planning/fleet-arrival.js +44 -79
  38. package/dist/internal/planning/fleet-arrival.js.map +1 -1
  39. package/dist/internal/planning/runtime-guards.d.ts.map +1 -1
  40. package/dist/internal/planning/runtime-guards.js +4 -6
  41. package/dist/internal/planning/runtime-guards.js.map +1 -1
  42. package/dist/internal/planning/xp-runtime.d.ts +2 -2
  43. package/dist/internal/planning/xp-runtime.d.ts.map +1 -1
  44. package/dist/internal/planning/xp-runtime.js +1 -3
  45. package/dist/internal/planning/xp-runtime.js.map +1 -1
  46. package/dist/mining/actions/index.d.ts +6 -9
  47. package/dist/mining/actions/index.d.ts.map +1 -1
  48. package/dist/mining/actions/index.js +7 -10
  49. package/dist/mining/actions/index.js.map +1 -1
  50. package/dist/planning/execution.d.ts.map +1 -1
  51. package/dist/planning/execution.js +7 -11
  52. package/dist/planning/execution.js.map +1 -1
  53. package/dist/planning/index.d.ts +13 -408
  54. package/dist/planning/index.d.ts.map +1 -1
  55. package/dist/planning/index.js +110 -332
  56. package/dist/planning/index.js.map +1 -1
  57. package/dist/registry/cargo.d.ts +3 -6
  58. package/dist/registry/cargo.d.ts.map +1 -1
  59. package/dist/registry/cargo.js +8 -13
  60. package/dist/registry/cargo.js.map +1 -1
  61. package/package.json +1 -1
  62. package/dist/internal/c4/legacy-cargo-config.d.ts +0 -6
  63. package/dist/internal/c4/legacy-cargo-config.d.ts.map +0 -1
  64. package/dist/internal/c4/legacy-cargo-config.js +0 -26
  65. package/dist/internal/c4/legacy-cargo-config.js.map +0 -1
@@ -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, version = 17) {
166
+ function normalizePrecondition(value, field) {
167
167
  const precondition = readRecord(value, field);
168
- if (version >= 17 && precondition.kind === 'fleet-arrival')
168
+ if (precondition.kind === 'fleet-arrival')
169
169
  return normalizeArrivalGuard(precondition, field);
170
- if (version >= 16 && isRuntimeGuard(precondition))
170
+ if (isRuntimeGuard(precondition))
171
171
  return normalizeRuntimeGuard(precondition, field);
172
- if (version >= 15 && precondition.kind === 'ship-import-funding') {
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 (version >= 13 && precondition.kind === 'fleet-mining') {
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 (version >= 12 &&
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
- ...(versioned ? ['schemaVersion'] : []),
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
- ...(versioned ? { schemaVersion: unsigned('schemaVersion', 255) } : {}),
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 (version >= 11 && precondition.kind === 'fleet-add-ship') {
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 (version >= 10 && precondition.kind === 'fleet-create') {
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 (version >= 8 && precondition.kind === 'system-account-or-absent') {
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 (version >= 7 && precondition.kind === 'token-mint') {
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 (version >= 6 && precondition.kind === 'game-ship-config') {
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 (version >= 5 && precondition.kind === 'game-account') {
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 ((version >= 9 && precondition.kind === 'game-cargo-bytes-config') ||
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' && version >= 3) {
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' && version !== 1) {
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, version === 1
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
- const hasSemantics = plan.steps.some((step) => (step.semantics?.length ?? 0) > 0);
592
- const hasAbsentPrecondition = plan.preconditions.some(({ kind }) => kind === 'account-absent');
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
- const steps = plan.steps.map((step) => ({
600
- instruction: instructionToJSON(step.instruction),
601
- describes: step.describes,
602
- ...((step.semantics?.length ?? 0) > 0
603
- ? { semantics: step.semantics.map((semantic) => ({ ...semantic })) }
604
- : {}),
605
- signers: [...step.signers],
606
- }));
607
- const hasArrivalGuard = plan.preconditions.some(({ kind }) => kind === 'fleet-arrival');
608
- const hasRuntimeGuard = plan.preconditions.some(isRuntimeGuard);
609
- const hasShipImportFunding = plan.preconditions.some(({ kind }) => kind === 'ship-import-funding');
610
- const hasMiningGuard = plan.preconditions.some(({ kind }) => kind === 'fleet-mining');
611
- if (hasArrivalGuard ||
612
- hasRuntimeGuard ||
613
- hasShipImportFunding ||
614
- hasMiningGuard ||
615
- plan.preconditions.some(isFactionTradeGuard)) {
616
- return deepFreeze({
617
- v: hasArrivalGuard
618
- ? 17
619
- : hasRuntimeGuard
620
- ? 16
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
- : guard.kind === 'fleet-create'
673
- ? {
674
- ...guard,
675
- maximumProfileDebit: String(guard.maximumProfileDebit),
676
- }
677
- : guard.kind === 'token-account'
678
- ? { ...guard, minimumBalance: String(guard.minimumBalance) }
679
- : { ...guard }),
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: PlanJsonV1 | PlanJsonV2 | PlanJsonV3 | PlanJsonV4 | PlanJsonV5 | PlanJsonV6 | PlanJsonV7 | PlanJsonV8 | PlanJsonV9 | PlanJsonV10 | PlanJsonV11 | PlanJsonV12 | PlanJsonV13 | PlanJsonV14 | PlanJsonV15 | PlanJsonV16 | PlanJsonV17;
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 !== 1 &&
871
- value.v !== 2 &&
872
- value.v !== 3 &&
873
- value.v !== 4 &&
874
- value.v !== 5 &&
875
- value.v !== 6 &&
876
- value.v !== 7 &&
877
- value.v !== 8 &&
878
- value.v !== 9 &&
879
- value.v !== 10 &&
880
- value.v !== 11 &&
881
- value.v !== 12 &&
882
- value.v !== 13 &&
883
- value.v !== 14 &&
884
- value.v !== 15 &&
885
- value.v !== 16 &&
886
- value.v !== 17) {
887
- invalid('planJson.v', value.v, 'the Plan wire version 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, or 17');
888
- }
889
- const version = value.v;
890
- if (version >= 4 && Array.isArray(value.preconditions)) {
891
- value.preconditions = value.preconditions.map((entry) => {
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
- if (version >= 11 && guard.kind === 'fleet-add-ship') {
915
- for (const field of ['amount', 'maximumProfileDebit'])
916
- if (typeof guard[field] !== 'string' ||
917
- !/^(0|[1-9][0-9]*)$/.test(guard[field]))
918
- invalid(field, guard[field], 'a canonical unsigned decimal string');
919
- return {
920
- ...guard,
921
- amount: BigInt(guard.amount),
922
- maximumProfileDebit: BigInt(guard.maximumProfileDebit),
923
- };
924
- }
925
- if ((version >= 10 && guard.kind === 'fleet-create') ||
926
- (version >= 15 && guard.kind === 'ship-import-funding')) {
927
- if (typeof guard.maximumProfileDebit !== 'string' ||
928
- !/^(0|[1-9][0-9]*)$/.test(guard.maximumProfileDebit))
929
- invalid('maximumProfileDebit', guard.maximumProfileDebit, 'a canonical unsigned decimal string');
930
- return {
931
- ...guard,
932
- maximumProfileDebit: BigInt(guard.maximumProfileDebit),
933
- };
934
- }
935
- if (guard.kind !== 'token-account')
936
- return guard;
937
- if (typeof guard.minimumBalance !== 'string' ||
938
- !/^(0|[1-9][0-9]*)$/.test(guard.minimumBalance))
939
- invalid('minimumBalance', guard.minimumBalance, 'a canonical unsigned decimal string');
940
- return { ...guard, minimumBalance: BigInt(guard.minimumBalance) };
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'], version !== 1 ? ['semantics'] : []);
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
- ...(version !== 1 && step.semantics !== undefined
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)}]`, version));
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
- if ('schemaVersion' in guard)
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)