@rootzero/contracts 1.10.0 → 1.11.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 (58) hide show
  1. package/CHANGELOG.md +20 -1
  2. package/Core.sol +1 -0
  3. package/Endpoints.sol +1 -3
  4. package/Events.sol +2 -5
  5. package/README.md +35 -33
  6. package/Utils.sol +2 -1
  7. package/blocks/Cursors.sol +26 -75
  8. package/blocks/Keys.sol +14 -4
  9. package/blocks/Schema.sol +49 -44
  10. package/commands/Base.sol +43 -13
  11. package/commands/Burn.sol +3 -6
  12. package/commands/Credit.sol +9 -6
  13. package/commands/Debit.sol +15 -11
  14. package/commands/Deposit.sol +19 -23
  15. package/commands/Payout.sol +6 -10
  16. package/commands/Provision.sol +19 -23
  17. package/commands/Recover.sol +7 -9
  18. package/commands/Relay.sol +10 -11
  19. package/commands/Withdraw.sol +3 -6
  20. package/commands/admin/AllowAssets.sol +7 -10
  21. package/commands/admin/Allowance.sol +7 -10
  22. package/commands/admin/Appoint.sol +7 -10
  23. package/commands/admin/Authorize.sol +7 -10
  24. package/commands/admin/Base.sol +1 -2
  25. package/commands/admin/DenyAssets.sol +7 -10
  26. package/commands/admin/Dismiss.sol +7 -10
  27. package/commands/admin/Execute.sol +7 -10
  28. package/commands/admin/Label.sol +8 -11
  29. package/commands/admin/Unauthorize.sol +7 -10
  30. package/core/Endpoint.sol +153 -0
  31. package/docs/Schema.md +114 -82
  32. package/events/Endpoint.sol +19 -0
  33. package/events/Schema.sol +23 -0
  34. package/guards/Base.sol +17 -8
  35. package/guards/Revoke.sol +4 -6
  36. package/package.json +1 -1
  37. package/ports/AllowAssets.sol +6 -9
  38. package/ports/Allowance.sol +6 -9
  39. package/ports/Base.sol +21 -8
  40. package/ports/Credit.sol +6 -9
  41. package/ports/Debit.sol +6 -9
  42. package/ports/DenyAssets.sol +6 -9
  43. package/ports/Dispatch.sol +6 -9
  44. package/ports/Pipe.sol +4 -7
  45. package/ports/Redeem.sol +4 -7
  46. package/ports/Settle.sol +6 -9
  47. package/queries/Assets.sol +9 -12
  48. package/queries/Balances.sol +7 -9
  49. package/queries/Base.sol +19 -11
  50. package/utils/Selectors.sol +49 -0
  51. package/commands/admin/Destroy.sol +0 -43
  52. package/commands/admin/Init.sol +0 -43
  53. package/events/Admin.sol +0 -32
  54. package/events/Command.sol +0 -32
  55. package/events/Guard.sol +0 -18
  56. package/events/Port.sol +0 -22
  57. package/events/Query.sol +0 -20
  58. package/queries/Positions.sol +0 -54
@@ -1,54 +0,0 @@
1
- // SPDX-License-Identifier: GPL-3.0-only
2
- pragma solidity ^0.8.33;
3
-
4
- import {Cur, Cursors, Writer, Writers} from "../Cursors.sol";
5
- import {Forms} from "../blocks/Schema.sol";
6
- import {QueryBase} from "./Base.sol";
7
-
8
- using Cursors for Cur;
9
- using Writers for Writer;
10
-
11
- abstract contract GetPositionHook {
12
- /// @notice Append the position response for one requested position.
13
- /// Concrete implementations must append exactly one response block matching
14
- /// the query output schema.
15
- /// @param account Requested account identifier.
16
- /// @param asset Requested asset identifier.
17
- /// @param response Destination writer for the response stream.
18
- function appendPosition(
19
- bytes32 account,
20
- bytes32 asset,
21
- Writer memory response
22
- ) internal view virtual;
23
- }
24
-
25
- /// @title GetPosition
26
- /// @notice Rootzero query that resolves one dynamic position response for each requested position.
27
- /// The request is a run of `ACCOUNT_ASSET` form blocks.
28
- /// The response returns one output-schema block per position entry, preserving request order.
29
- abstract contract GetPosition is QueryBase, GetPositionHook {
30
- uint public immutable getPositionId = queryId(this.getPosition.selector);
31
-
32
- /// @param output Response schema advertised for each position output block.
33
- constructor(string memory output) {
34
- emit Query(host, getPositionId, "1:1", Forms.AccountAsset, output);
35
- emit Labeled(getPositionId, bytes32(0), "getPosition");
36
- }
37
-
38
- /// @notice Resolve positions for a run of requested `(account, asset)` tuples.
39
- /// @dev Allocates from a per-block capacity hint and grows when position outputs exceed it.
40
- /// @param request Block-stream request consisting of `accountAsset(account, asset)*`.
41
- /// @return Block-stream response containing one output-schema block per position block.
42
- function getPosition(bytes calldata request) external view returns (bytes memory) {
43
- (Cur memory query, uint groups) = Cursors.init(request, 1);
44
- Writer memory response = Writers.allocAny(groups);
45
-
46
- while (query.i < query.len) {
47
- (bytes32 account, bytes32 asset) = query.unpackAccountAsset();
48
- appendPosition(account, asset, response);
49
- }
50
-
51
- query.complete();
52
- return response.finish();
53
- }
54
- }