@rootzero/contracts 0.8.0 → 0.9.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 (75) hide show
  1. package/Commands.sol +5 -10
  2. package/Core.sol +3 -4
  3. package/Cursors.sol +4 -6
  4. package/Events.sol +1 -1
  5. package/Queries.sol +1 -1
  6. package/README.md +18 -19
  7. package/Utils.sol +3 -3
  8. package/blocks/Cursors.sol +1437 -0
  9. package/blocks/Keys.sol +59 -34
  10. package/blocks/Schema.sol +109 -126
  11. package/blocks/Writers.sol +476 -301
  12. package/commands/Base.sol +32 -22
  13. package/commands/Burn.sol +3 -3
  14. package/commands/Credit.sol +6 -7
  15. package/commands/Debit.sol +3 -3
  16. package/commands/Deposit.sol +7 -7
  17. package/commands/Pipe.sol +3 -3
  18. package/commands/Provision.sol +19 -49
  19. package/commands/Transfer.sol +9 -19
  20. package/commands/Withdraw.sol +5 -6
  21. package/commands/admin/AllowAssets.sol +3 -3
  22. package/commands/admin/Allowance.sol +43 -0
  23. package/commands/admin/Authorize.sol +4 -4
  24. package/commands/admin/DenyAssets.sol +3 -3
  25. package/commands/admin/Destroy.sol +3 -3
  26. package/commands/admin/Execute.sol +38 -0
  27. package/commands/admin/Init.sol +3 -3
  28. package/commands/admin/Relocate.sol +5 -5
  29. package/commands/admin/Unauthorize.sol +4 -4
  30. package/core/Access.sol +38 -34
  31. package/core/Balances.sol +17 -18
  32. package/core/{Operation.sol → Calls.sol} +5 -8
  33. package/core/{CursorBase.sol → Context.sol} +11 -5
  34. package/core/Host.sol +10 -9
  35. package/core/Types.sol +86 -0
  36. package/docs/GETTING_STARTED.md +37 -29
  37. package/events/Asset.sol +1 -1
  38. package/events/Command.sol +10 -10
  39. package/events/Deposit.sol +3 -4
  40. package/events/Listing.sol +1 -1
  41. package/events/Peer.sol +3 -3
  42. package/events/Position.sol +21 -0
  43. package/events/Query.sol +3 -3
  44. package/events/Withdraw.sol +2 -3
  45. package/package.json +1 -1
  46. package/peer/AllowAssets.sol +1 -1
  47. package/peer/Allowance.sol +36 -0
  48. package/peer/AssetPull.sol +1 -1
  49. package/peer/Base.sol +8 -4
  50. package/peer/DenyAssets.sol +1 -1
  51. package/peer/Settle.sol +3 -4
  52. package/queries/Assets.sol +8 -8
  53. package/queries/Balances.sol +11 -11
  54. package/queries/Base.sol +2 -3
  55. package/queries/Positions.sol +25 -19
  56. package/utils/Accounts.sol +14 -13
  57. package/utils/Assets.sol +77 -57
  58. package/utils/Ids.sol +4 -4
  59. package/utils/Layout.sol +1 -1
  60. package/utils/Utils.sol +10 -0
  61. package/blocks/cursors/Core.sol +0 -1121
  62. package/blocks/cursors/Erc1155.sol +0 -149
  63. package/blocks/cursors/Erc20.sol +0 -130
  64. package/blocks/cursors/Erc721.sol +0 -66
  65. package/commands/Create.sol +0 -44
  66. package/commands/Remove.sol +0 -44
  67. package/commands/Settle.sol +0 -38
  68. package/commands/Stake.sol +0 -49
  69. package/commands/Supply.sol +0 -43
  70. package/commands/admin/Allocate.sol +0 -43
  71. package/core/HostBound.sol +0 -14
  72. package/events/Erc721.sol +0 -20
  73. package/peer/Pull.sol +0 -41
  74. package/peer/Push.sol +0 -47
  75. package/utils/State.sol +0 -22
package/peer/Pull.sol DELETED
@@ -1,41 +0,0 @@
1
- // SPDX-License-Identifier: GPL-3.0-only
2
- pragma solidity ^0.8.33;
3
-
4
- import {PeerBase} from "./Base.sol";
5
- import {Cursors, Cur} from "../Cursors.sol";
6
-
7
- string constant NAME = "peerPull";
8
-
9
- using Cursors for Cur;
10
-
11
- abstract contract PeerPullHook {
12
- /// @notice Override to process a single incoming block from the pull request.
13
- /// @param peer Host node ID derived from the caller address.
14
- /// @param input Cursor positioned at the current input block; advance it before returning.
15
- function peerPull(uint peer, Cur memory input) internal virtual;
16
- }
17
-
18
- /// @title PeerPull
19
- /// @notice Peer that pulls assets from a remote host into this one.
20
- /// Each block in the request is dispatched to `peerPull(peer, input)`, where `peer`
21
- /// is derived from `msg.sender`. Restricted to trusted peers.
22
- abstract contract PeerPull is PeerBase, PeerPullHook {
23
- uint internal immutable peerPullId = peerId(NAME);
24
-
25
- constructor(string memory input) {
26
- emit Peer(host, NAME, input, peerPullId, false);
27
- }
28
-
29
- /// @notice Execute the pull peer call.
30
- function peerPull(bytes calldata request) external onlyPeer returns (bytes memory) {
31
- (Cur memory input, , ) = cursor(request, 1);
32
- uint peer = caller();
33
-
34
- while (input.i < input.bound) {
35
- peerPull(peer, input);
36
- }
37
-
38
- input.complete();
39
- return "";
40
- }
41
- }
package/peer/Push.sol DELETED
@@ -1,47 +0,0 @@
1
- // SPDX-License-Identifier: GPL-3.0-only
2
- pragma solidity ^0.8.33;
3
-
4
- import { PeerBase } from "./Base.sol";
5
- import { Cursors, Cur } from "../Cursors.sol";
6
-
7
- string constant NAME = "peerPush";
8
-
9
- using Cursors for Cur;
10
-
11
- abstract contract PeerPushHook {
12
- /// @notice Override to process a single incoming block from the push request.
13
- /// @param peer Host node ID derived from the caller address.
14
- /// @param input Cursor positioned at the current input block; advance it before returning.
15
- function peerPush(uint peer, Cur memory input) internal virtual;
16
- }
17
-
18
- /// @title PeerPush
19
- /// @notice Peer that receives assets pushed from a remote host into this one.
20
- /// Each block in the request is dispatched to `peerPush(peer, input)`, where `peer`
21
- /// is derived from `msg.sender`. Restricted to trusted peers.
22
- abstract contract PeerPush is PeerBase, PeerPushHook {
23
- uint internal immutable peerPushId = peerId(NAME);
24
-
25
- constructor(string memory input) {
26
- emit Peer(host, NAME, input, peerPushId, false);
27
- }
28
-
29
- /// @notice Execute the push peer call.
30
- function peerPush(bytes calldata request) external onlyPeer returns (bytes memory) {
31
- (Cur memory input, , ) = cursor(request, 1);
32
- uint peer = caller();
33
-
34
- while (input.i < input.bound) {
35
- peerPush(peer, input);
36
- }
37
-
38
- input.complete();
39
- return "";
40
- }
41
- }
42
-
43
-
44
-
45
-
46
-
47
-
package/utils/State.sol DELETED
@@ -1,22 +0,0 @@
1
- // SPDX-License-Identifier: GPL-3.0-only
2
- pragma solidity ^0.8.33;
3
-
4
- /// @title State
5
- /// @notice Command state type discriminants.
6
- /// Each constant tags the shape of the encoded state block stream stored
7
- /// in a command's metadata slot, allowing commands to select the correct
8
- /// decode path without inspecting the raw bytes.
9
- library State {
10
- /// @dev No state; the command produces or expects an empty state stream.
11
- uint8 constant Empty = 0x0001;
12
- /// @dev State stream contains STEP blocks (sub-command invocations).
13
- uint8 constant Steps = 0x0002;
14
- /// @dev State stream contains BALANCE blocks.
15
- uint8 constant Balances = 0x0003;
16
- /// @dev State stream contains TRANSACTION blocks.
17
- uint8 constant Transactions = 0x0004;
18
- /// @dev State stream contains CUSTODY blocks.
19
- uint8 constant Custodies = 0x0005;
20
- /// @dev State stream contains claim records.
21
- uint8 constant Claims = 0x0006;
22
- }