@rootzero/contracts 0.9.0 → 0.9.1

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 (44) hide show
  1. package/Commands.sol +15 -16
  2. package/Events.sol +2 -1
  3. package/blocks/Cursors.sol +25 -64
  4. package/blocks/Keys.sol +0 -2
  5. package/blocks/Schema.sol +0 -1
  6. package/commands/Burn.sol +2 -2
  7. package/commands/Credit.sol +2 -1
  8. package/commands/Debit.sol +2 -2
  9. package/commands/Deposit.sol +8 -7
  10. package/commands/Pipe.sol +2 -2
  11. package/commands/Provision.sol +8 -7
  12. package/commands/Transfer.sol +2 -2
  13. package/commands/Withdraw.sol +2 -2
  14. package/commands/{admin → control}/AllowAssets.sol +7 -6
  15. package/commands/{admin → control}/Allowance.sol +11 -11
  16. package/commands/{admin → control}/Authorize.sol +6 -5
  17. package/commands/{admin → control}/DenyAssets.sol +7 -6
  18. package/commands/{admin → control}/Destroy.sol +6 -5
  19. package/commands/{admin → control}/Execute.sol +6 -5
  20. package/commands/{admin → control}/Init.sol +6 -5
  21. package/commands/{admin → control}/Unauthorize.sol +6 -5
  22. package/core/Access.sol +2 -2
  23. package/core/Host.sol +5 -6
  24. package/core/Types.sol +1 -1
  25. package/events/Control.sol +31 -0
  26. package/events/Query.sol +4 -4
  27. package/events/Remote.sol +24 -0
  28. package/package.json +1 -1
  29. package/remote/AllowAssets.sol +39 -0
  30. package/remote/Allowance.sol +36 -0
  31. package/remote/AssetPull.sol +44 -0
  32. package/remote/Base.sol +40 -0
  33. package/remote/DenyAssets.sol +39 -0
  34. package/remote/Settle.sol +33 -0
  35. package/utils/Ids.sol +30 -30
  36. package/utils/Layout.sol +3 -3
  37. package/commands/admin/Relocate.sol +0 -43
  38. package/events/Peer.sol +0 -24
  39. package/peer/AllowAssets.sol +0 -39
  40. package/peer/Allowance.sol +0 -36
  41. package/peer/AssetPull.sol +0 -44
  42. package/peer/Base.sol +0 -40
  43. package/peer/DenyAssets.sol +0 -39
  44. package/peer/Settle.sol +0 -33
package/Commands.sol CHANGED
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-only
2
2
  pragma solidity ^0.8.33;
3
3
 
4
- // Aggregator: re-exports command, admin, and peer abstractions.
4
+ // Aggregator: re-exports command, control, and remote abstractions.
5
5
  // Import this file to inherit from the full rootzero command surface without managing individual paths.
6
6
 
7
7
  import { CommandBase, CommandContext, CommandPayable, encodeCommandCall } from "./commands/Base.sol";
@@ -14,21 +14,20 @@ import { PipePayable, PipePayableHook } from "./commands/Pipe.sol";
14
14
  import { Provision, ProvisionHook, ProvisionPayable, ProvisionPayableHook } from "./commands/Provision.sol";
15
15
  import { Transfer, TransferHook } from "./commands/Transfer.sol";
16
16
  import { Withdraw, WithdrawHook } from "./commands/Withdraw.sol";
17
- import { AllowAssets, AllowAssetsHook } from "./commands/admin/AllowAssets.sol";
18
- import { Destroy, DestroyHook } from "./commands/admin/Destroy.sol";
19
- import { ExecutePayable } from "./commands/admin/Execute.sol";
20
- import { Authorize } from "./commands/admin/Authorize.sol";
21
- import { DenyAssets, DenyAssetsHook } from "./commands/admin/DenyAssets.sol";
22
- import { Init, InitHook } from "./commands/admin/Init.sol";
23
- import { RelocatePayable } from "./commands/admin/Relocate.sol";
24
- import { Allowance, AllowanceHook } from "./commands/admin/Allowance.sol";
25
- import { Unauthorize } from "./commands/admin/Unauthorize.sol";
26
- import { PeerBase, encodePeerCall } from "./peer/Base.sol";
27
- import { PeerAllowance } from "./peer/Allowance.sol";
28
- import { PeerAssetPull, PeerAssetPullHook } from "./peer/AssetPull.sol";
29
- import { PeerAllowAssets } from "./peer/AllowAssets.sol";
30
- import { PeerDenyAssets } from "./peer/DenyAssets.sol";
31
- import { PeerSettle } from "./peer/Settle.sol";
17
+ import { AllowAssets, AllowAssetsHook } from "./commands/control/AllowAssets.sol";
18
+ import { Destroy, DestroyHook } from "./commands/control/Destroy.sol";
19
+ import { ExecutePayable } from "./commands/control/Execute.sol";
20
+ import { Authorize } from "./commands/control/Authorize.sol";
21
+ import { DenyAssets, DenyAssetsHook } from "./commands/control/DenyAssets.sol";
22
+ import { Init, InitHook } from "./commands/control/Init.sol";
23
+ import { Allowance, AllowanceHook } from "./commands/control/Allowance.sol";
24
+ import { Unauthorize } from "./commands/control/Unauthorize.sol";
25
+ import { RemoteBase, encodeRemoteCall } from "./remote/Base.sol";
26
+ import { RemoteAllowance } from "./remote/Allowance.sol";
27
+ import { RemoteAssetPull, AssetPullHook } from "./remote/AssetPull.sol";
28
+ import { RemoteAllowAssets } from "./remote/AllowAssets.sol";
29
+ import { RemoteDenyAssets } from "./remote/DenyAssets.sol";
30
+ import { RemoteSettle } from "./remote/Settle.sol";
32
31
 
33
32
 
34
33
 
package/Events.sol CHANGED
@@ -5,6 +5,7 @@ pragma solidity ^0.8.33;
5
5
  // Import this file to get access to every event emitter in one import.
6
6
 
7
7
  import { AccessEvent } from "./events/Access.sol";
8
+ import { ControlEvent } from "./events/Control.sol";
8
9
  import { AssetEvent } from "./events/Asset.sol";
9
10
  import { BalanceEvent } from "./events/Balance.sol";
10
11
  import { CollateralEvent } from "./events/Collateral.sol";
@@ -16,7 +17,7 @@ import { EventEmitter } from "./events/Emitter.sol";
16
17
  import { GovernedEvent } from "./events/Governed.sol";
17
18
  import { HostAnnouncedEvent } from "./events/Host.sol";
18
19
  import { ListingEvent } from "./events/Listing.sol";
19
- import { PeerEvent } from "./events/Peer.sol";
20
+ import { RemoteEvent } from "./events/Remote.sol";
20
21
  import { QueryEvent } from "./events/Query.sol";
21
22
  import { RootZeroEvent } from "./events/RootZero.sol";
22
23
  import { SwapEvent } from "./events/Swap.sol";
@@ -47,9 +47,6 @@ library Cursors {
47
47
  error UnexpectedValue();
48
48
  /// @dev Input and output block counts are not proportional to their declared group sizes.
49
49
  error BadRatio();
50
- /// @dev A fixed-width low-level unpacker received an invalid final-word keep length.
51
- error InvalidKeep();
52
-
53
50
  // -------------------------------------------------------------------------
54
51
  // Cursor construction and navigation
55
52
  // -------------------------------------------------------------------------
@@ -218,17 +215,6 @@ library Cursors {
218
215
  cur.i = next;
219
216
  }
220
217
 
221
- /// @notice Load a payload word and mask away any omitted tail bytes on the right.
222
- /// @param abs Absolute calldata offset of the word start.
223
- /// @param tail Number of trailing bytes omitted from the logical payload (0..31).
224
- /// @return value Decoded word with omitted tail bytes zeroed.
225
- function mask(uint abs, uint tail) internal pure returns (bytes32 value) {
226
- assembly ("memory-safe") {
227
- value := calldataload(abs)
228
- }
229
- if (tail != 0) value &= bytes32(type(uint256).max << (tail * 8));
230
- }
231
-
232
218
  /// @notice Enter a Bundle block at the current position and return the next offset.
233
219
  /// Advances `cur.i` past the bundle header so the bundled members can be parsed
234
220
  /// directly from the same cursor. The returned `next` is the byte offset
@@ -561,12 +547,9 @@ library Cursors {
561
547
  /// @param cur Cursor; advanced past the block.
562
548
  /// @param key Expected dynamic block key.
563
549
  /// @return value Decoded bytes32.
564
- /// @param keep Number of bytes to keep from the final payload word (1..32).
565
- function unpack32(Cur memory cur, bytes4 key, uint keep) internal pure returns (bytes32 value) {
566
- if (keep == 0 || keep > 32) revert InvalidKeep();
567
- uint len = keep;
568
- uint abs = consume(cur, key, len, len);
569
- value = mask(abs, 32 - keep);
550
+ function unpack32(Cur memory cur, bytes4 key) internal pure returns (bytes32 value) {
551
+ uint abs = consume(cur, key, 32, 32);
552
+ value = bytes32(msg.data[abs:abs + 32]);
570
553
  }
571
554
 
572
555
  /// @notice Consume a dynamic block with two bytes32 payload words.
@@ -574,13 +557,10 @@ library Cursors {
574
557
  /// @param key Expected dynamic block key.
575
558
  /// @return a First decoded bytes32.
576
559
  /// @return b Second decoded bytes32.
577
- /// @param keep Number of bytes to keep from the final payload word (1..32).
578
- function unpack64(Cur memory cur, bytes4 key, uint keep) internal pure returns (bytes32 a, bytes32 b) {
579
- if (keep == 0 || keep > 32) revert InvalidKeep();
580
- uint len = 32 + keep;
581
- uint abs = consume(cur, key, len, len);
560
+ function unpack64(Cur memory cur, bytes4 key) internal pure returns (bytes32 a, bytes32 b) {
561
+ uint abs = consume(cur, key, 64, 64);
582
562
  a = bytes32(msg.data[abs:abs + 32]);
583
- b = mask(abs + 32, 32 - keep);
563
+ b = bytes32(msg.data[abs + 32:abs + 64]);
584
564
  }
585
565
 
586
566
  /// @notice Consume a dynamic block with three bytes32 payload words.
@@ -589,14 +569,11 @@ library Cursors {
589
569
  /// @return a First decoded bytes32.
590
570
  /// @return b Second decoded bytes32.
591
571
  /// @return c Third decoded bytes32.
592
- /// @param keep Number of bytes to keep from the final payload word (1..32).
593
- function unpack96(Cur memory cur, bytes4 key, uint keep) internal pure returns (bytes32 a, bytes32 b, bytes32 c) {
594
- if (keep == 0 || keep > 32) revert InvalidKeep();
595
- uint len = 64 + keep;
596
- uint abs = consume(cur, key, len, len);
572
+ function unpack96(Cur memory cur, bytes4 key) internal pure returns (bytes32 a, bytes32 b, bytes32 c) {
573
+ uint abs = consume(cur, key, 96, 96);
597
574
  a = bytes32(msg.data[abs:abs + 32]);
598
575
  b = bytes32(msg.data[abs + 32:abs + 64]);
599
- c = mask(abs + 64, 32 - keep);
576
+ c = bytes32(msg.data[abs + 64:abs + 96]);
600
577
  }
601
578
 
602
579
  /// @notice Consume a dynamic block with a 128-byte payload (four 32-byte words).
@@ -606,19 +583,15 @@ library Cursors {
606
583
  /// @return b Second decoded bytes32.
607
584
  /// @return c Third decoded bytes32.
608
585
  /// @return d Fourth decoded bytes32.
609
- /// @param keep Number of bytes to keep from the final payload word (1..32).
610
586
  function unpack128(
611
587
  Cur memory cur,
612
- bytes4 key,
613
- uint keep
588
+ bytes4 key
614
589
  ) internal pure returns (bytes32 a, bytes32 b, bytes32 c, bytes32 d) {
615
- if (keep == 0 || keep > 32) revert InvalidKeep();
616
- uint len = 96 + keep;
617
- uint abs = consume(cur, key, len, len);
590
+ uint abs = consume(cur, key, 128, 128);
618
591
  a = bytes32(msg.data[abs:abs + 32]);
619
592
  b = bytes32(msg.data[abs + 32:abs + 64]);
620
593
  c = bytes32(msg.data[abs + 64:abs + 96]);
621
- d = mask(abs + 96, 32 - keep);
594
+ d = bytes32(msg.data[abs + 96:abs + 128]);
622
595
  }
623
596
 
624
597
  /// @notice Consume a dynamic block with a 160-byte payload (five 32-byte words).
@@ -629,20 +602,16 @@ library Cursors {
629
602
  /// @return c Third decoded bytes32.
630
603
  /// @return d Fourth decoded bytes32.
631
604
  /// @return e Fifth decoded bytes32.
632
- /// @param keep Number of bytes to keep from the final payload word (1..32).
633
605
  function unpack160(
634
606
  Cur memory cur,
635
- bytes4 key,
636
- uint keep
607
+ bytes4 key
637
608
  ) internal pure returns (bytes32 a, bytes32 b, bytes32 c, bytes32 d, bytes32 e) {
638
- if (keep == 0 || keep > 32) revert InvalidKeep();
639
- uint len = 128 + keep;
640
- uint abs = consume(cur, key, len, len);
609
+ uint abs = consume(cur, key, 160, 160);
641
610
  a = bytes32(msg.data[abs:abs + 32]);
642
611
  b = bytes32(msg.data[abs + 32:abs + 64]);
643
612
  c = bytes32(msg.data[abs + 64:abs + 96]);
644
613
  d = bytes32(msg.data[abs + 96:abs + 128]);
645
- e = mask(abs + 128, 32 - keep);
614
+ e = bytes32(msg.data[abs + 128:abs + 160]);
646
615
  }
647
616
 
648
617
  /// @notice Consume a dynamic block with a single uint payload.
@@ -650,7 +619,7 @@ library Cursors {
650
619
  /// @param key Expected dynamic block key.
651
620
  /// @return value Decoded uint value.
652
621
  function unpackUint(Cur memory cur, bytes4 key) internal pure returns (uint value) {
653
- value = uint(unpack32(cur, key, 32));
622
+ value = uint(unpack32(cur, key));
654
623
  }
655
624
 
656
625
  /// @notice Consume a dynamic block with two uint payload words.
@@ -659,7 +628,7 @@ library Cursors {
659
628
  /// @return a First decoded uint.
660
629
  /// @return b Second decoded uint.
661
630
  function unpack2Uint(Cur memory cur, bytes4 key) internal pure returns (uint a, uint b) {
662
- (bytes32 x, bytes32 y) = unpack64(cur, key, 32);
631
+ (bytes32 x, bytes32 y) = unpack64(cur, key);
663
632
  return (uint(x), uint(y));
664
633
  }
665
634
 
@@ -670,7 +639,7 @@ library Cursors {
670
639
  /// @return b Second decoded uint.
671
640
  /// @return c Third decoded uint.
672
641
  function unpack3Uint(Cur memory cur, bytes4 key) internal pure returns (uint a, uint b, uint c) {
673
- (bytes32 x, bytes32 y, bytes32 z) = unpack96(cur, key, 32);
642
+ (bytes32 x, bytes32 y, bytes32 z) = unpack96(cur, key);
674
643
  return (uint(x), uint(y), uint(z));
675
644
  }
676
645
 
@@ -839,35 +808,35 @@ library Cursors {
839
808
  /// @param cur Cursor; advanced past the block.
840
809
  /// @return account Account identifier.
841
810
  function unpackAccount(Cur memory cur) internal pure returns (bytes32 account) {
842
- account = unpack32(cur, Keys.Account, 32);
811
+ account = unpack32(cur, Keys.Account);
843
812
  }
844
813
 
845
814
  /// @notice Consume a NODE block and return the node ID.
846
815
  /// @param cur Cursor; advanced past the block.
847
816
  /// @return node Node identifier.
848
817
  function unpackNode(Cur memory cur) internal pure returns (uint node) {
849
- node = uint(unpack32(cur, Keys.Node, 32));
818
+ node = uint(unpack32(cur, Keys.Node));
850
819
  }
851
820
 
852
821
  /// @notice Consume a RATE block and return the value.
853
822
  /// @param cur Cursor; advanced past the block.
854
823
  /// @return value Encoded ratio or rate.
855
824
  function unpackRate(Cur memory cur) internal pure returns (uint value) {
856
- value = uint(unpack32(cur, Keys.Rate, 32));
825
+ value = uint(unpack32(cur, Keys.Rate));
857
826
  }
858
827
 
859
828
  /// @notice Consume a QUANTITY block and return the amount.
860
829
  /// @param cur Cursor; advanced past the block.
861
830
  /// @return amount Scalar quantity value.
862
831
  function unpackQuantity(Cur memory cur) internal pure returns (uint amount) {
863
- amount = uint(unpack32(cur, Keys.Quantity, 32));
832
+ amount = uint(unpack32(cur, Keys.Quantity));
864
833
  }
865
834
 
866
835
  /// @notice Consume a FEE block and return the amount.
867
836
  /// @param cur Cursor; advanced past the block.
868
837
  /// @return amount Fee amount.
869
838
  function unpackFee(Cur memory cur) internal pure returns (uint amount) {
870
- amount = uint(unpack32(cur, Keys.Fee, 32));
839
+ amount = uint(unpack32(cur, Keys.Fee));
871
840
  }
872
841
 
873
842
  /// @notice Consume an ASSET block and return the asset descriptor fields.
@@ -875,7 +844,7 @@ library Cursors {
875
844
  /// @return asset Asset identifier.
876
845
  /// @return meta Asset metadata slot.
877
846
  function unpackAsset(Cur memory cur) internal pure returns (bytes32 asset, bytes32 meta) {
878
- (asset, meta) = unpack64(cur, Keys.Asset, 32);
847
+ (asset, meta) = unpack64(cur, Keys.Asset);
879
848
  }
880
849
 
881
850
  /// @notice Consume an ACCOUNT_ASSET form block and return its fields as separate values.
@@ -897,20 +866,12 @@ library Cursors {
897
866
  (value.account, value.asset, value.meta) = unpackAccountAsset(cur);
898
867
  }
899
868
 
900
- /// @notice Consume a RELOCATION block and return the host and amount.
901
- /// @param cur Cursor; advanced past the block.
902
- /// @return host Host node ID receiving the funding.
903
- /// @return amount Funding amount.
904
- function unpackRelocation(Cur memory cur) internal pure returns (uint host, uint amount) {
905
- (host, amount) = unpack2Uint(cur, Keys.Relocation);
906
- }
907
-
908
869
  /// @notice Consume a BOUNTY block and return the reward amount and relayer.
909
870
  /// @param cur Cursor; advanced past the block.
910
871
  /// @return amount Relayer reward amount.
911
872
  /// @return relayer Relayer account identifier.
912
873
  function unpackBounty(Cur memory cur) internal pure returns (uint amount, bytes32 relayer) {
913
- (bytes32 x, bytes32 y) = unpack64(cur, Keys.Bounty, 32);
874
+ (bytes32 x, bytes32 y) = unpack64(cur, Keys.Bounty);
914
875
  amount = uint(x);
915
876
  relayer = y;
916
877
  }
package/blocks/Keys.sol CHANGED
@@ -68,8 +68,6 @@ library Keys {
68
68
  bytes4 constant Asset = bytes4(keccak256("asset(bytes32 asset, bytes32 meta)"));
69
69
  /// @dev Node identifier - (uint id)
70
70
  bytes4 constant Node = bytes4(keccak256("node(uint id)"));
71
- /// @dev Native value relocation entry - (uint host, uint amount)
72
- bytes4 constant Relocation = bytes4(keccak256("relocation(uint host, uint amount)"));
73
71
  /// @dev Relayer bounty - (uint amount, bytes32 relayer)
74
72
  bytes4 constant Bounty = bytes4(keccak256("bounty(uint amount, bytes32 relayer)"));
75
73
 
package/blocks/Schema.sol CHANGED
@@ -114,7 +114,6 @@ library Schemas {
114
114
  string constant Allocation = "allocation(uint host, bytes32 asset, bytes32 meta, uint amount)";
115
115
  string constant Allowance = "allowance(uint host, bytes32 asset, bytes32 meta, uint amount)";
116
116
  string constant Transaction = "transaction(bytes32 from, bytes32 to, bytes32 asset, bytes32 meta, uint amount)";
117
- string constant Relocation = "relocation(uint host, uint amount)";
118
117
  string constant Call = "call(uint target, uint value, bytes data)";
119
118
  string constant Step = "step(uint target, uint value, bytes request)";
120
119
  string constant Bounty = "bounty(uint amount, bytes32 relayer)";
package/commands/Burn.sol CHANGED
@@ -5,8 +5,6 @@ import { CommandBase, CommandContext, Keys } from "./Base.sol";
5
5
  import { Cursors, Cur } from "../Cursors.sol";
6
6
  using Cursors for Cur;
7
7
 
8
- string constant NAME = "burn";
9
-
10
8
  abstract contract BurnHook {
11
9
  /// @notice Override to burn or consume the provided balance amount.
12
10
  /// Called once per BALANCE block in state.
@@ -22,6 +20,8 @@ abstract contract BurnHook {
22
20
  /// @notice Command that irreversibly destroys each BALANCE state block via a virtual hook.
23
21
  /// Produces no output state.
24
22
  abstract contract Burn is CommandBase, BurnHook {
23
+ string private constant NAME = "burn";
24
+
25
25
  uint internal immutable burnId = commandId(NAME);
26
26
 
27
27
  constructor() {
@@ -3,7 +3,6 @@ pragma solidity ^0.8.33;
3
3
 
4
4
  import { CommandBase, CommandContext, Keys } from "./Base.sol";
5
5
  import { Cursors, Cur, Schemas } from "../Cursors.sol";
6
- string constant NAME = "creditAccount";
7
6
 
8
7
  using Cursors for Cur;
9
8
 
@@ -22,6 +21,8 @@ abstract contract CreditAccountHook {
22
21
  /// Use for internally recording credits that have already been settled externally.
23
22
  /// An optional ACCOUNT block in the request overrides the default `c.account` destination.
24
23
  abstract contract CreditAccount is CommandBase, CreditAccountHook {
24
+ string private constant NAME = "creditAccount";
25
+
25
26
  uint internal immutable creditAccountId = commandId(NAME);
26
27
 
27
28
  constructor() {
@@ -4,8 +4,6 @@ pragma solidity ^0.8.33;
4
4
  import { CommandContext, CommandBase, Keys } from "./Base.sol";
5
5
  import { Cursors, Cur, Schemas, Writer, Writers } from "../Cursors.sol";
6
6
 
7
- string constant NAME = "debitAccount";
8
-
9
7
  using Cursors for Cur;
10
8
  using Writers for Writer;
11
9
 
@@ -24,6 +22,8 @@ abstract contract DebitAccountHook {
24
22
  /// Use for internally recording debits. The virtual `debitAccount` hook is called once per
25
23
  /// AMOUNT block; the default batch implementation handles the full request loop.
26
24
  abstract contract DebitAccount is CommandBase, DebitAccountHook {
25
+ string private constant NAME = "debitAccount";
26
+
27
27
  uint internal immutable debitAccountId = commandId(NAME);
28
28
 
29
29
  constructor() {
@@ -5,9 +5,6 @@ import { CommandContext, CommandBase, CommandPayable, Keys } from "./Base.sol";
5
5
  import { Cursors, Cur, Schemas, Writer, Writers } from "../Cursors.sol";
6
6
  import { Budget, Values } from "../utils/Value.sol";
7
7
 
8
- string constant DEPOSIT = "deposit";
9
- string constant DEPOSIT_PAYABLE = "depositPayable";
10
-
11
8
  using Cursors for Cur;
12
9
  using Writers for Writer;
13
10
 
@@ -39,10 +36,12 @@ abstract contract DepositPayableHook {
39
36
  /// Use `deposit` for assets arriving from outside the protocol (e.g. ERC-20 transfers, ETH).
40
37
  /// For internal balance deductions, use `debitAccount` instead.
41
38
  abstract contract Deposit is CommandBase, DepositHook {
42
- uint internal immutable depositId = commandId(DEPOSIT);
39
+ string private constant NAME = "deposit";
40
+
41
+ uint internal immutable depositId = commandId(NAME);
43
42
 
44
43
  constructor() {
45
- emit Command(host, depositId, DEPOSIT, Schemas.Amount, Keys.Empty, Keys.Balance, false);
44
+ emit Command(host, depositId, NAME, Schemas.Amount, Keys.Empty, Keys.Balance, false);
46
45
  }
47
46
 
48
47
  function deposit(
@@ -65,10 +64,12 @@ abstract contract Deposit is CommandBase, DepositHook {
65
64
  /// @notice Command that receives externally sourced assets and records them as BALANCE state.
66
65
  /// Use `depositPayable` when the hook needs tracked access to `msg.value` via a mutable budget.
67
66
  abstract contract DepositPayable is CommandPayable, DepositPayableHook {
68
- uint internal immutable depositPayableId = commandId(DEPOSIT_PAYABLE);
67
+ string private constant NAME = "depositPayable";
68
+
69
+ uint internal immutable depositPayableId = commandId(NAME);
69
70
 
70
71
  constructor() {
71
- emit Command(host, depositPayableId, DEPOSIT_PAYABLE, Schemas.Amount, Keys.Empty, Keys.Balance, true);
72
+ emit Command(host, depositPayableId, NAME, Schemas.Amount, Keys.Empty, Keys.Balance, true);
72
73
  }
73
74
 
74
75
  function depositPayable(
package/commands/Pipe.sol CHANGED
@@ -8,8 +8,6 @@ import {Budget, Values} from "../utils/Value.sol";
8
8
 
9
9
  using Cursors for Cur;
10
10
 
11
- string constant NAME = "pipePayable";
12
-
13
11
  abstract contract PipePayableHook {
14
12
  function dispatchStep(
15
13
  uint target,
@@ -26,6 +24,8 @@ abstract contract PipePayableHook {
26
24
  /// State threads through the steps: each step's output becomes the next step's state.
27
25
  /// Admin accounts are not permitted to use `pipePayable`.
28
26
  abstract contract PipePayable is CommandPayable, PipePayableHook {
27
+ string private constant NAME = "pipePayable";
28
+
29
29
  uint internal immutable pipePayableId = commandId(NAME);
30
30
 
31
31
  constructor() {
@@ -7,9 +7,6 @@ import {Budget, Values} from "../utils/Value.sol";
7
7
  using Cursors for Cur;
8
8
  using Writers for Writer;
9
9
 
10
- string constant PROVISION = "provision";
11
- string constant PP = "provisionPayable";
12
-
13
10
  /// @notice Shared provision hook used by `Provision`.
14
11
  abstract contract ProvisionHook {
15
12
  /// @notice Override to send or provision a custody value.
@@ -35,10 +32,12 @@ abstract contract ProvisionPayableHook {
35
32
  /// @notice Command that provisions assets to remote hosts from ALLOCATION request blocks.
36
33
  /// Each request block supplies the target host plus an asset amount; the output is a CUSTODY state stream.
37
34
  abstract contract Provision is CommandBase, ProvisionHook {
38
- uint internal immutable provisionId = commandId(PROVISION);
35
+ string private constant NAME = "provision";
36
+
37
+ uint internal immutable provisionId = commandId(NAME);
39
38
 
40
39
  constructor() {
41
- emit Command(host, provisionId, PROVISION, Schemas.Allocation, Keys.Empty, Keys.Custody, false);
40
+ emit Command(host, provisionId, NAME, Schemas.Allocation, Keys.Empty, Keys.Custody, false);
42
41
  }
43
42
 
44
43
  function provision(CommandContext calldata c) external onlyCommand(c.account) returns (bytes memory) {
@@ -60,10 +59,12 @@ abstract contract Provision is CommandBase, ProvisionHook {
60
59
  /// Each request block supplies the target host plus an asset amount; the output is a CUSTODY state stream.
61
60
  /// The hook receives a mutable native-value budget drawn from `msg.value`.
62
61
  abstract contract ProvisionPayable is CommandPayable, ProvisionPayableHook {
63
- uint internal immutable provisionPayableId = commandId(PP);
62
+ string private constant NAME = "provisionPayable";
63
+
64
+ uint internal immutable provisionPayableId = commandId(NAME);
64
65
 
65
66
  constructor() {
66
- emit Command(host, provisionPayableId, PP, Schemas.Allocation, Keys.Empty, Keys.Custody, true);
67
+ emit Command(host, provisionPayableId, NAME, Schemas.Allocation, Keys.Empty, Keys.Custody, true);
67
68
  }
68
69
 
69
70
  function provisionPayable(
@@ -6,8 +6,6 @@ import { Cursors, Cur, Schemas, Tx } from "../Cursors.sol";
6
6
  import { Accounts } from "../utils/Accounts.sol";
7
7
  using Cursors for Cur;
8
8
 
9
- string constant NAME = "transfer";
10
-
11
9
  abstract contract TransferHook {
12
10
  /// @notice Override to execute a single transfer record from the request pipeline.
13
11
  /// Called once per PAYOUT block in the request.
@@ -20,6 +18,8 @@ abstract contract TransferHook {
20
18
  /// PAYOUT request blocks. Produces no state output.
21
19
  /// The virtual `transfer(value)` hook is called once per entry.
22
20
  abstract contract Transfer is CommandBase, TransferHook {
21
+ string private constant NAME = "transfer";
22
+
23
23
  uint internal immutable transferId = commandId(NAME);
24
24
 
25
25
  constructor() {
@@ -5,8 +5,6 @@ import { CommandContext, CommandBase, Keys } from "./Base.sol";
5
5
  import { Cursors, Cur, Schemas } from "../Cursors.sol";
6
6
  using Cursors for Cur;
7
7
 
8
- string constant NAME = "withdraw";
9
-
10
8
  abstract contract WithdrawHook {
11
9
  /// @notice Override to send funds to `account`.
12
10
  /// Called once per BALANCE block in state.
@@ -22,6 +20,8 @@ abstract contract WithdrawHook {
22
20
  /// Use `withdraw` for assets being sent outside the protocol (e.g. ERC-20 transfers, ETH sends).
23
21
  /// For internal balance credits, use `creditAccount` instead.
24
22
  abstract contract Withdraw is CommandBase, WithdrawHook {
23
+ string private constant NAME = "withdraw";
24
+
25
25
  uint internal immutable withdrawId = commandId(NAME);
26
26
 
27
27
  constructor() {
@@ -3,24 +3,25 @@ pragma solidity ^0.8.33;
3
3
 
4
4
  import { CommandBase, CommandContext, Keys } from "../Base.sol";
5
5
  import { Cursors, Cur, Schemas } from "../../Cursors.sol";
6
+ import { ControlEvent } from "../../events/Control.sol";
6
7
  using Cursors for Cur;
7
8
 
8
- string constant NAME = "allowAssets";
9
-
10
9
  abstract contract AllowAssetsHook {
11
10
  /// @dev Override to allow a single asset/meta pair.
12
11
  /// Called once per ASSET block in the request.
13
- function allowAsset(bytes32 asset, bytes32 meta) internal virtual returns (bool);
12
+ function allowAsset(bytes32 asset, bytes32 meta) internal virtual;
14
13
  }
15
14
 
16
15
  /// @title AllowAssets
17
- /// @notice Admin command that permits a list of (asset, meta) pairs via a virtual hook.
16
+ /// @notice Control command that permits a list of (asset, meta) pairs via a virtual hook.
18
17
  /// Each ASSET block in the request calls `allowAsset`. Only callable by the admin account.
19
- abstract contract AllowAssets is CommandBase, AllowAssetsHook {
18
+ abstract contract AllowAssets is CommandBase, ControlEvent, AllowAssetsHook {
19
+ string private constant NAME = "allowAssets";
20
+
20
21
  uint internal immutable allowAssetsId = commandId(NAME);
21
22
 
22
23
  constructor() {
23
- emit Command(host, allowAssetsId, NAME, Schemas.Asset, Keys.Empty, Keys.Empty, false);
24
+ emit Control(host, allowAssetsId, NAME, Schemas.Asset, Keys.Empty, Keys.Empty, false);
24
25
  }
25
26
 
26
27
  function allowAssets(
@@ -1,40 +1,40 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-only
2
2
  pragma solidity ^0.8.33;
3
3
 
4
- import { CommandBase, CommandContext, Keys } from "../Base.sol";
5
- import { Cursors, Cur, Schemas } from "../../Cursors.sol";
4
+ import {CommandBase, CommandContext, Keys} from "../Base.sol";
5
+ import {Cursors, Cur, Schemas} from "../../Cursors.sol";
6
+ import {ControlEvent} from "../../events/Control.sol";
6
7
  using Cursors for Cur;
7
8
 
8
- string constant NAME = "allowance";
9
-
10
9
  abstract contract AllowanceHook {
11
10
  /// @notice Apply or revoke one host-scoped allowance.
12
11
  /// Called once per ALLOWANCE block in the request. Implementations decide
13
12
  /// how the allowance is represented, e.g. ERC-20 approval, an internal cap,
14
13
  /// or another host-specific authorization record.
15
- /// @param peer Host node receiving the allowed cap.
14
+ /// @param remote Host node receiving the allowed cap.
16
15
  /// @param asset Asset identifier.
17
16
  /// @param meta Asset metadata slot.
18
17
  /// @param amount Allowed cap amount.
19
- function allowance(uint peer, bytes32 asset, bytes32 meta, uint amount) internal virtual;
18
+ function allowance(uint remote, bytes32 asset, bytes32 meta, uint amount) internal virtual;
20
19
  }
21
20
 
22
21
  /// @title Allowance
23
- /// @notice Admin command that applies cross-host allowance entries via a virtual hook.
22
+ /// @notice Control command that applies cross-host allowance entries via a virtual hook.
24
23
  /// Each ALLOWANCE block grants or updates a host-scoped asset cap. Only callable by the admin account.
25
- abstract contract Allowance is CommandBase, AllowanceHook {
24
+ abstract contract Allowance is CommandBase, ControlEvent, AllowanceHook {
25
+ string private constant NAME = "allowance";
26
26
  uint internal immutable allowanceId = commandId(NAME);
27
27
 
28
28
  constructor() {
29
- emit Command(host, allowanceId, NAME, Schemas.Allowance, Keys.Empty, Keys.Empty, false);
29
+ emit Control(host, allowanceId, NAME, Schemas.Allowance, Keys.Empty, Keys.Empty, false);
30
30
  }
31
31
 
32
32
  function allowance(CommandContext calldata c) external onlyAdmin(c.account) returns (bytes memory) {
33
33
  (Cur memory request, , ) = cursor(c.request, 1);
34
34
 
35
35
  while (request.i < request.bound) {
36
- (uint peer, bytes32 asset, bytes32 meta, uint amount) = request.unpackAllowance();
37
- allowance(peer, asset, meta, amount);
36
+ (uint remote, bytes32 asset, bytes32 meta, uint amount) = request.unpackAllowance();
37
+ allowance(remote, asset, meta, amount);
38
38
  }
39
39
 
40
40
  request.complete();
@@ -3,19 +3,20 @@ pragma solidity ^0.8.33;
3
3
 
4
4
  import { CommandBase, CommandContext, Keys } from "../Base.sol";
5
5
  import { Cursors, Cur, Schemas } from "../../Cursors.sol";
6
+ import { ControlEvent } from "../../events/Control.sol";
6
7
  using Cursors for Cur;
7
8
 
8
- string constant NAME = "authorize";
9
-
10
9
  /// @title Authorize
11
- /// @notice Admin command that grants authorization to a list of node IDs.
10
+ /// @notice Control command that grants authorization to a list of node IDs.
12
11
  /// Each NODE block in the request is authorized on the host.
13
12
  /// Only callable by the admin account.
14
- abstract contract Authorize is CommandBase {
13
+ abstract contract Authorize is CommandBase, ControlEvent {
14
+ string private constant NAME = "authorize";
15
+
15
16
  uint internal immutable authorizeId = commandId(NAME);
16
17
 
17
18
  constructor() {
18
- emit Command(host, authorizeId, NAME, Schemas.Node, Keys.Empty, Keys.Empty, false);
19
+ emit Control(host, authorizeId, NAME, Schemas.Node, Keys.Empty, Keys.Empty, false);
19
20
  }
20
21
 
21
22
  function authorize(
@@ -3,24 +3,25 @@ pragma solidity ^0.8.33;
3
3
 
4
4
  import { CommandBase, CommandContext, Keys } from "../Base.sol";
5
5
  import { Cursors, Cur, Schemas } from "../../Cursors.sol";
6
+ import { ControlEvent } from "../../events/Control.sol";
6
7
  using Cursors for Cur;
7
8
 
8
- string constant NAME = "denyAssets";
9
-
10
9
  abstract contract DenyAssetsHook {
11
10
  /// @dev Override to deny a single asset/meta pair.
12
11
  /// Called once per ASSET block in the request.
13
- function denyAsset(bytes32 asset, bytes32 meta) internal virtual returns (bool);
12
+ function denyAsset(bytes32 asset, bytes32 meta) internal virtual;
14
13
  }
15
14
 
16
15
  /// @title DenyAssets
17
- /// @notice Admin command that blocks a list of (asset, meta) pairs via a virtual hook.
16
+ /// @notice Control command that blocks a list of (asset, meta) pairs via a virtual hook.
18
17
  /// Each ASSET block in the request calls `denyAsset`. Only callable by the admin account.
19
- abstract contract DenyAssets is CommandBase, DenyAssetsHook {
18
+ abstract contract DenyAssets is CommandBase, ControlEvent, DenyAssetsHook {
19
+ string private constant NAME = "denyAssets";
20
+
20
21
  uint internal immutable denyAssetsId = commandId(NAME);
21
22
 
22
23
  constructor() {
23
- emit Command(host, denyAssetsId, NAME, Schemas.Asset, Keys.Empty, Keys.Empty, false);
24
+ emit Control(host, denyAssetsId, NAME, Schemas.Asset, Keys.Empty, Keys.Empty, false);
24
25
  }
25
26
 
26
27
  function denyAssets(