@rootzero/contracts 0.9.9 → 1.0.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.
Files changed (48) hide show
  1. package/Endpoints.sol +2 -0
  2. package/Events.sol +1 -0
  3. package/README.md +19 -18
  4. package/blocks/Cursors.sol +54 -26
  5. package/blocks/Keys.sol +6 -0
  6. package/blocks/Schema.sol +4 -2
  7. package/blocks/Writers.sol +4 -4
  8. package/commands/Burn.sol +4 -1
  9. package/commands/Credit.sol +4 -1
  10. package/commands/Debit.sol +4 -1
  11. package/commands/Deposit.sol +8 -2
  12. package/commands/Payout.sol +7 -3
  13. package/commands/Provision.sol +8 -2
  14. package/commands/Relay.sol +58 -0
  15. package/commands/Withdraw.sol +4 -1
  16. package/commands/admin/AllowAssets.sol +6 -1
  17. package/commands/admin/Allowance.sol +4 -1
  18. package/commands/admin/Appoint.sol +4 -1
  19. package/commands/admin/Authorize.sol +4 -1
  20. package/commands/admin/DenyAssets.sol +6 -1
  21. package/commands/admin/Destroy.sol +4 -2
  22. package/commands/admin/Dismiss.sol +4 -1
  23. package/commands/admin/Execute.sol +5 -2
  24. package/commands/admin/Init.sol +4 -2
  25. package/commands/admin/Unauthorize.sol +4 -1
  26. package/core/Host.sol +10 -1
  27. package/core/Pipeline.sol +2 -1
  28. package/core/Runtime.sol +3 -3
  29. package/events/Admin.sol +5 -5
  30. package/events/Chain.sol +20 -0
  31. package/events/Command.sol +5 -5
  32. package/guards/Revoke.sol +1 -1
  33. package/package.json +1 -1
  34. package/peer/AllowAssets.sol +3 -1
  35. package/peer/Allowance.sol +3 -1
  36. package/peer/BalancePull.sol +3 -1
  37. package/peer/DenyAssets.sol +3 -1
  38. package/peer/Dispatch.sol +51 -0
  39. package/peer/Pipe.sol +5 -3
  40. package/peer/Settle.sol +3 -1
  41. package/queries/Assets.sol +1 -1
  42. package/queries/Balances.sol +1 -1
  43. package/queries/Positions.sol +1 -1
  44. package/utils/Accounts.sol +1 -34
  45. package/utils/Assets.sol +21 -21
  46. package/utils/Ids.sol +12 -2
  47. package/utils/Layout.sol +21 -17
  48. package/utils/Utils.sol +2 -2
package/utils/Layout.sol CHANGED
@@ -6,19 +6,24 @@ pragma solidity ^0.8.33;
6
6
  /// layout of 256-bit IDs used throughout the rootzero protocol.
7
7
  ///
8
8
  /// IDs are structured as:
9
- /// `[uint16 width][uint16 chainId-prefix][uint32 prefix][... payload ...]`
10
- /// where the top bytes carry nested type tags drawn from the constants below.
9
+ /// `[uint32 type][uint32 chainid][192-bit payload]`
10
+ /// where `type` is `[uint8 vm][uint8 width][uint8 category][uint8 subtype]`.
11
11
  library Layout {
12
12
  // -------------------------------------------------------------------------
13
- // Data-width tags (uint16, top 2 bytes of the ID type field)
13
+ // VM and data-width tags (top 2 bytes of the ID type field)
14
14
  // -------------------------------------------------------------------------
15
15
 
16
- /// @dev 32-byte opaque value; no EVM address embedded.
17
- uint16 constant Opaque32 = 0x2000;
16
+ /// @dev EVM-compatible value; payloads are built around 20-byte addresses.
17
+ uint8 constant Evm = 0x01;
18
+ /// @dev 32-byte ID; no paired metadata word is required.
19
+ uint8 constant Width32 = 0x20;
20
+ /// @dev 64-byte ID; a paired metadata word completes the identity.
21
+ uint8 constant Width64 = 0x40;
22
+
18
23
  /// @dev 32-byte EVM-compatible value; lower 20 bytes hold an address.
19
- uint16 constant Evm32 = 0x2001;
24
+ uint16 constant Evm32 = (uint16(Evm) << 8) | uint16(Width32);
20
25
  /// @dev 64-byte EVM-compatible value; used when a paired metadata word completes the identity.
21
- uint16 constant Evm64 = 0x4001;
26
+ uint16 constant Evm64 = (uint16(Evm) << 8) | uint16(Width64);
22
27
 
23
28
  // -------------------------------------------------------------------------
24
29
  // Category tags (uint8, third byte of the ID type field)
@@ -41,30 +46,29 @@ library Layout {
41
46
  uint8 constant Guardian = 0x02;
42
47
  /// @dev User account — chain-agnostic, backed by an EVM address.
43
48
  uint8 constant User = 0x03;
44
- /// @dev Keccak account — opaque 28-byte keccak commitment.
45
- uint8 constant Keccak = 0x04;
46
-
47
49
  // -------------------------------------------------------------------------
48
50
  // Node subtype tags (uint8, fourth byte of the ID type field)
49
51
  // -------------------------------------------------------------------------
50
52
 
53
+ /// @dev Node is a chain/domain identifier.
54
+ uint8 constant Chain = 0x01;
51
55
  /// @dev Node is a host contract.
52
- uint8 constant Host = 0x01;
56
+ uint8 constant Host = 0x02;
53
57
  /// @dev Node is a command contract.
54
- uint8 constant Command = 0x02;
58
+ uint8 constant Command = 0x03;
55
59
  /// @dev Node is a peer contract.
56
- uint8 constant Peer = 0x03;
60
+ uint8 constant Peer = 0x04;
57
61
  /// @dev Node is a query contract.
58
- uint8 constant Query = 0x04;
62
+ uint8 constant Query = 0x05;
59
63
  /// @dev Node is a guardian-only direct action.
60
- uint8 constant Guard = 0x05;
64
+ uint8 constant Guard = 0x06;
61
65
 
62
66
  // -------------------------------------------------------------------------
63
67
  // Asset subtype tags (uint8, fourth byte of the ID type field)
64
68
  // -------------------------------------------------------------------------
65
69
 
66
- /// @dev Native chain value asset (ETH / native token).
67
- uint8 constant Value = 0x01;
70
+ /// @dev Native chain coin/token asset.
71
+ uint8 constant Native = 0x01;
68
72
  /// @dev ERC-20 fungible token; lower 20 bytes of the ID hold the contract address.
69
73
  uint8 constant Erc20 = 0x02;
70
74
  /// @dev ERC-721 non-fungible token; lower 20 bytes of the ID hold the collection address.
package/utils/Utils.sol CHANGED
@@ -4,9 +4,9 @@ pragma solidity ^0.8.33;
4
4
  // Basis-points denominator: 10_000 BPS == 100.00%.
5
5
  uint16 constant MAX_BPS = 10_000;
6
6
 
7
- // Thrown by max* helpers when a value exceeds the target integer width.
7
+ /// @dev Thrown by max* helpers when a value exceeds the target integer width.
8
8
  error ValueOverflow();
9
- // Thrown by `divisible` when `n` is not evenly divisible by `divisor`.
9
+ /// @dev Thrown by `divisible` when `n` is not evenly divisible by `divisor`.
10
10
  error NotDivisible();
11
11
 
12
12
  /// @notice Assert that `value` fits in uint8 and return it unchanged.