@rootzero/contracts 1.13.0 → 1.15.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 (86) hide show
  1. package/CHANGELOG.md +87 -3
  2. package/Codec.sol +21 -0
  3. package/Commands.sol +14 -0
  4. package/Core.sol +8 -6
  5. package/Endpoints.sol +2 -7
  6. package/Events.sol +1 -2
  7. package/README.md +70 -37
  8. package/Utils.sol +2 -4
  9. package/annotations/Action.sol +17 -0
  10. package/annotations/Label.sol +23 -0
  11. package/annotations/Schema.sol +53 -0
  12. package/codec/Blocks.sol +1643 -0
  13. package/codec/Buffers.sol +165 -0
  14. package/codec/Decoders.sol +570 -0
  15. package/codec/Descriptors.sol +124 -0
  16. package/{blocks → codec}/Keys.sol +10 -18
  17. package/codec/Readers.sol +114 -0
  18. package/{blocks → codec}/Schema.sol +43 -80
  19. package/codec/Specs.sol +240 -0
  20. package/codec/Writers.sol +485 -0
  21. package/commands/Allocate.sol +21 -20
  22. package/commands/Base.sol +83 -45
  23. package/commands/Burn.sol +23 -14
  24. package/commands/Credit.sol +21 -20
  25. package/commands/Debit.sol +25 -28
  26. package/commands/Deposit.sol +41 -36
  27. package/commands/Payout.sol +26 -16
  28. package/commands/Provision.sol +37 -38
  29. package/commands/Recover.sol +20 -19
  30. package/commands/Relay.sol +24 -22
  31. package/commands/Withdraw.sol +20 -19
  32. package/commands/admin/AllowAssets.sol +19 -16
  33. package/commands/admin/Allowance.sol +18 -13
  34. package/commands/admin/Annotate.sol +36 -0
  35. package/commands/admin/Appoint.sol +19 -16
  36. package/commands/admin/Authorize.sol +23 -14
  37. package/commands/admin/Base.sol +9 -2
  38. package/commands/admin/DenyAssets.sol +19 -16
  39. package/commands/admin/Dismiss.sol +19 -16
  40. package/commands/admin/Execute.sol +21 -19
  41. package/commands/admin/Unauthorize.sol +23 -14
  42. package/core/Access.sol +91 -49
  43. package/core/Calls.sol +30 -33
  44. package/core/Endpoint.sol +46 -143
  45. package/core/Host.sol +63 -21
  46. package/core/Pipeline.sol +16 -15
  47. package/core/Types.sol +1 -1
  48. package/docs/Schema.md +48 -31
  49. package/events/Annotation.sol +24 -0
  50. package/events/Endpoint.sol +2 -2
  51. package/events/Guardian.sol +2 -2
  52. package/events/Introduction.sol +3 -2
  53. package/execution/Budget.sol +40 -0
  54. package/execution/Execution.sol +1104 -0
  55. package/guards/Base.sol +11 -12
  56. package/guards/Revoke.sol +11 -9
  57. package/package.json +1 -1
  58. package/ports/AllowAssets.sol +12 -15
  59. package/ports/Allowance.sol +11 -9
  60. package/ports/Base.sol +35 -16
  61. package/ports/Credit.sol +11 -9
  62. package/ports/Debit.sol +11 -9
  63. package/ports/DenyAssets.sol +10 -13
  64. package/ports/Dispatch.sol +13 -15
  65. package/ports/Pipe.sol +14 -12
  66. package/ports/Redeem.sol +12 -9
  67. package/ports/Settle.sol +16 -10
  68. package/queries/Assets.sol +15 -15
  69. package/queries/Balances.sol +17 -17
  70. package/queries/Base.sol +26 -12
  71. package/utils/Accounts.sol +0 -23
  72. package/utils/Actions.sol +1 -0
  73. package/utils/Cursors.sol +367 -0
  74. package/utils/Lanes.sol +14 -0
  75. package/utils/Layout.sol +0 -2
  76. package/utils/Selectors.sol +2 -2
  77. package/utils/Utils.sol +46 -0
  78. package/Cursors.sol +0 -16
  79. package/blocks/Cursors.sol +0 -1529
  80. package/blocks/Writers.sol +0 -1036
  81. package/commands/admin/Label.sol +0 -32
  82. package/commands/admin/Schemas.sol +0 -32
  83. package/core/Payable.sol +0 -53
  84. package/events/Labeled.sol +0 -21
  85. package/events/Schema.sol +0 -23
  86. package/utils/Value.sol +0 -43
package/utils/Utils.sol CHANGED
@@ -83,6 +83,52 @@ function max160(uint value) pure returns (uint) {
83
83
  return value;
84
84
  }
85
85
 
86
+ // Packed fields
87
+
88
+ /// @notice Clear the 8-bit field beginning at `shift`.
89
+ function clear8(uint value, uint shift) pure returns (uint) {
90
+ return value & ~(uint(type(uint8).max) << shift);
91
+ }
92
+
93
+ /// @notice Clear the 16-bit field beginning at `shift`.
94
+ function clear16(uint value, uint shift) pure returns (uint) {
95
+ return value & ~(uint(type(uint16).max) << shift);
96
+ }
97
+
98
+ /// @notice Clear the 32-bit field beginning at `shift`.
99
+ function clear32(uint value, uint shift) pure returns (uint) {
100
+ return value & ~(uint(type(uint32).max) << shift);
101
+ }
102
+
103
+ /// @notice Clear the 64-bit field beginning at `shift`.
104
+ function clear64(uint value, uint shift) pure returns (uint) {
105
+ return value & ~(uint(type(uint64).max) << shift);
106
+ }
107
+
108
+ /// @notice Replace the 8-bit field beginning at `shift` with `field`.
109
+ /// @dev Reverts when `field` does not fit in 8 bits.
110
+ function replace8(uint value, uint shift, uint field) pure returns (uint) {
111
+ return clear8(value, shift) | (max8(field) << shift);
112
+ }
113
+
114
+ /// @notice Replace the 16-bit field beginning at `shift` with `field`.
115
+ /// @dev Reverts when `field` does not fit in 16 bits.
116
+ function replace16(uint value, uint shift, uint field) pure returns (uint) {
117
+ return clear16(value, shift) | (max16(field) << shift);
118
+ }
119
+
120
+ /// @notice Replace the 32-bit field beginning at `shift` with `field`.
121
+ /// @dev Reverts when `field` does not fit in 32 bits.
122
+ function replace32(uint value, uint shift, uint field) pure returns (uint) {
123
+ return clear32(value, shift) | (max32(field) << shift);
124
+ }
125
+
126
+ /// @notice Replace the 64-bit field beginning at `shift` with `field`.
127
+ /// @dev Reverts when `field` does not fit in 64 bits.
128
+ function replace64(uint value, uint shift, uint field) pure returns (uint) {
129
+ return clear64(value, shift) | (max64(field) << shift);
130
+ }
131
+
86
132
  /// @notice Assert that `n` is evenly divisible by `divisor`.
87
133
  /// No-op when `divisor` is zero.
88
134
  function divisible(uint n, uint divisor) pure {
package/Cursors.sol DELETED
@@ -1,16 +0,0 @@
1
- // SPDX-License-Identifier: GPL-3.0-only
2
- pragma solidity ^0.8.33;
3
-
4
- // Aggregator: re-exports all block stream primitives (Cursors, Readers, Writers, Schema, Keys, Sizes).
5
- // Import this file to get access to the full block encoding/decoding surface in one import.
6
-
7
- import { AssetAmount, AccountAsset, AccountAmount, HostAmount, HostAccountAsset, HostAccountAmount, Tx } from "./core/Types.sol";
8
- import { Forms, Sizes } from "./blocks/Schema.sol";
9
- import { Keys } from "./blocks/Keys.sol";
10
- import { Schemas } from "./blocks/Schema.sol";
11
- import { Cursors, Cur, Readers, Reader } from "./blocks/Cursors.sol";
12
- import { Writer, Writers, Hints } from "./blocks/Writers.sol";
13
-
14
-
15
-
16
-