@rootzero/contracts 1.12.0 → 1.14.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 (76) hide show
  1. package/CHANGELOG.md +76 -8
  2. package/Codec.sol +21 -0
  3. package/Commands.sol +14 -0
  4. package/Core.sol +4 -4
  5. package/Endpoints.sol +5 -7
  6. package/README.md +62 -35
  7. package/Utils.sol +2 -4
  8. package/codec/Blocks.sol +1606 -0
  9. package/codec/Buffers.sol +165 -0
  10. package/codec/Decoders.sol +558 -0
  11. package/codec/Descriptors.sol +124 -0
  12. package/{blocks → codec}/Keys.sol +4 -28
  13. package/codec/Readers.sol +114 -0
  14. package/{blocks → codec}/Schema.sol +38 -80
  15. package/codec/Specs.sol +218 -0
  16. package/codec/Writers.sol +487 -0
  17. package/commands/Allocate.sol +50 -0
  18. package/commands/Base.sol +71 -37
  19. package/commands/Burn.sol +19 -13
  20. package/commands/Credit.sol +25 -31
  21. package/commands/Debit.sol +28 -38
  22. package/commands/Deposit.sol +39 -39
  23. package/commands/Payout.sol +22 -15
  24. package/commands/Provision.sol +40 -40
  25. package/commands/Recover.sol +21 -20
  26. package/commands/Relay.sol +25 -23
  27. package/commands/Withdraw.sol +18 -20
  28. package/commands/admin/AllowAssets.sol +20 -16
  29. package/commands/admin/Allowance.sol +19 -13
  30. package/commands/admin/Appoint.sol +18 -15
  31. package/commands/admin/Authorize.sol +24 -14
  32. package/commands/admin/Base.sol +1 -1
  33. package/commands/admin/DenyAssets.sol +20 -16
  34. package/commands/admin/Dismiss.sol +18 -15
  35. package/commands/admin/Execute.sol +20 -18
  36. package/commands/admin/Label.sol +18 -13
  37. package/commands/admin/Schemas.sol +19 -14
  38. package/commands/admin/Unauthorize.sol +24 -14
  39. package/core/Calls.sol +7 -14
  40. package/core/Endpoint.sol +43 -126
  41. package/core/Host.sol +10 -2
  42. package/core/Pipeline.sol +29 -25
  43. package/core/Settlement.sol +39 -0
  44. package/core/Types.sol +1 -1
  45. package/docs/Schema.md +38 -32
  46. package/events/Endpoint.sol +2 -2
  47. package/events/Introduction.sol +4 -3
  48. package/events/Schema.sol +5 -5
  49. package/execution/Budget.sol +40 -0
  50. package/execution/Execution.sol +1083 -0
  51. package/guards/Base.sol +8 -9
  52. package/guards/Revoke.sol +11 -9
  53. package/package.json +1 -1
  54. package/ports/AllowAssets.sol +12 -15
  55. package/ports/Allowance.sol +11 -9
  56. package/ports/Base.sol +18 -11
  57. package/ports/Credit.sol +11 -9
  58. package/ports/Debit.sol +11 -9
  59. package/ports/DenyAssets.sol +10 -13
  60. package/ports/Dispatch.sol +13 -15
  61. package/ports/Pipe.sol +14 -12
  62. package/ports/Redeem.sol +12 -9
  63. package/ports/Settle.sol +13 -13
  64. package/queries/Assets.sol +15 -15
  65. package/queries/Balances.sol +17 -17
  66. package/queries/Base.sol +11 -12
  67. package/utils/Actions.sol +1 -0
  68. package/utils/Cursors.sol +308 -0
  69. package/utils/Lanes.sol +14 -0
  70. package/utils/Selectors.sol +2 -2
  71. package/utils/Utils.sol +46 -0
  72. package/Cursors.sol +0 -16
  73. package/blocks/Cursors.sol +0 -1400
  74. package/blocks/Writers.sol +0 -1028
  75. package/core/Payable.sol +0 -53
  76. package/utils/Value.sol +0 -43
package/core/Payable.sol DELETED
@@ -1,53 +0,0 @@
1
- // SPDX-License-Identifier: GPL-3.0-only
2
- pragma solidity ^0.8.33;
3
-
4
- import {Budget, Values} from "../utils/Value.sol";
5
- import {max128} from "../utils/Utils.sol";
6
-
7
- /// @title Payable
8
- /// @notice Abstract mixin for entrypoints that accept native value (`msg.value`).
9
- /// Provides shared helpers for mutable native-value budgets.
10
- abstract contract Payable {
11
- /// @dev Thrown when a payable entrypoint completes with unspent native value.
12
- error UnusedValue(uint remaining);
13
-
14
- /// @notice Open a native-value budget from the current call's `msg.value`.
15
- /// @return Budget initialized with the full `msg.value`.
16
- function openValue() internal view returns (Budget memory) {
17
- return Budget({remaining: msg.value});
18
- }
19
-
20
- /// @notice Return the current call's native value as a checked uint128.
21
- /// @return value Current `msg.value` in wei.
22
- function msgValue() internal view returns (uint128 value) {
23
- return uint128(max128(msg.value));
24
- }
25
-
26
- /// @notice Deduct the EVM value lane from a packed resource word and return it.
27
- /// @dev EVM resources use the low 128 bits as native value/endowment.
28
- /// @param budget Mutable budget to deduct from.
29
- /// @param resources Packed resources.
30
- /// @return value Native value to forward in wei.
31
- function useValue(Budget memory budget, uint resources) internal pure returns (uint128 value) {
32
- value = uint128(resources);
33
- Values.use(budget, value);
34
- }
35
-
36
- /// @notice Close a native-value budget and settle any drained value.
37
- /// @param account Account identifier for the current invocation.
38
- /// @param budget Mutable native-value budget to close.
39
- function closeValue(bytes32 account, Budget memory budget) internal {
40
- uint value = Values.drain(budget);
41
- if (value == 0) return;
42
- settleValue(account, value);
43
- }
44
-
45
- /// @notice Handle a drained native value amount.
46
- /// @dev Override to refund or redirect unused value. The default rejects it.
47
- /// @param account Account identifier for the current invocation.
48
- /// @param value Drained native value amount to settle, in wei.
49
- function settleValue(bytes32 account, uint value) internal virtual {
50
- account;
51
- revert UnusedValue(value);
52
- }
53
- }
package/utils/Value.sol DELETED
@@ -1,43 +0,0 @@
1
- // SPDX-License-Identifier: GPL-3.0-only
2
- pragma solidity ^0.8.33;
3
-
4
- /// @notice Mutable native-value budget drawn down as sub-calls consume ETH.
5
- struct Budget {
6
- /// @dev Remaining unspent native value in wei.
7
- uint remaining;
8
- }
9
-
10
- /// @title Values
11
- /// @notice Native-value budget mutation helpers.
12
- library Values {
13
- /// @dev Thrown when a call attempts to spend more native value than remains in the budget.
14
- error InsufficientValue();
15
-
16
- /// @notice Deduct `amount` from the budget and return it.
17
- /// Reverts if `amount` exceeds `budget.remaining`.
18
- /// @param budget Mutable budget to deduct from.
19
- /// @param amount Native value to spend in wei.
20
- /// @return The same `amount`, ready to forward to a callee.
21
- function use(Budget memory budget, uint amount) internal pure returns (uint) {
22
- if (amount > budget.remaining) revert InsufficientValue();
23
- budget.remaining -= amount;
24
- return amount;
25
- }
26
-
27
- /// @notice Drain the remaining native value from `budget` and return it.
28
- /// @param budget Mutable budget to drain.
29
- /// @return value Native value removed from the budget, in wei.
30
- function drain(Budget memory budget) internal pure returns (uint value) {
31
- value = budget.remaining;
32
- budget.remaining = 0;
33
- }
34
-
35
- /// @notice Deduct `amount` from the budget and return it as a new sub-budget.
36
- /// Reverts if `amount` exceeds `budget.remaining`.
37
- /// @param budget Mutable parent budget to deduct from.
38
- /// @param amount Native value to assign to the sub-budget, in wei.
39
- /// @return A new budget with `amount` remaining.
40
- function allocate(Budget memory budget, uint amount) internal pure returns (Budget memory) {
41
- return Budget({remaining: use(budget, amount)});
42
- }
43
- }