@rootzero/contracts 1.4.0 → 1.5.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 (56) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/Endpoints.sol +4 -3
  3. package/Events.sol +1 -1
  4. package/README.md +58 -31
  5. package/Utils.sol +4 -3
  6. package/blocks/Cursors.sol +83 -143
  7. package/blocks/Keys.sol +15 -15
  8. package/blocks/Schema.sol +27 -28
  9. package/blocks/Writers.sol +26 -33
  10. package/commands/Base.sol +2 -2
  11. package/commands/Burn.sol +3 -4
  12. package/commands/Credit.sol +3 -4
  13. package/commands/Debit.sol +4 -5
  14. package/commands/Deposit.sol +8 -10
  15. package/commands/Payout.sol +3 -6
  16. package/commands/Withdraw.sol +3 -4
  17. package/commands/admin/AllowAssets.sol +5 -6
  18. package/commands/admin/Allowance.sol +3 -4
  19. package/commands/admin/DenyAssets.sol +5 -6
  20. package/commands/admin/Execute.sol +2 -2
  21. package/core/Access.sol +2 -2
  22. package/core/Balances.sol +10 -11
  23. package/core/Calls.sol +7 -7
  24. package/core/Host.sol +2 -2
  25. package/core/Runtime.sol +3 -3
  26. package/core/Types.sol +0 -14
  27. package/docs/Schema.md +29 -10
  28. package/events/Asset.sol +17 -3
  29. package/events/Balance.sol +2 -3
  30. package/events/Locked.sol +2 -3
  31. package/events/Position.sol +2 -3
  32. package/events/Received.sol +2 -3
  33. package/events/Spent.sol +2 -3
  34. package/events/Unlocked.sol +2 -3
  35. package/guards/Base.sol +4 -4
  36. package/package.json +1 -1
  37. package/peer/AllowAssets.sol +3 -3
  38. package/peer/Allowance.sol +2 -2
  39. package/peer/Base.sol +4 -4
  40. package/peer/Credit.sol +10 -10
  41. package/peer/Debit.sol +10 -10
  42. package/peer/DenyAssets.sol +3 -3
  43. package/peer/Recover.sol +51 -0
  44. package/peer/Redeem.sol +48 -0
  45. package/peer/Settle.sol +3 -3
  46. package/queries/Assets.sol +7 -8
  47. package/queries/Balances.sol +8 -9
  48. package/queries/Base.sol +4 -4
  49. package/queries/Positions.sol +4 -6
  50. package/utils/Accounts.sol +76 -58
  51. package/utils/Assets.sol +55 -115
  52. package/utils/Ids.sol +33 -233
  53. package/utils/Layout.sol +11 -17
  54. package/utils/Nodes.sol +263 -0
  55. package/utils/Utils.sol +9 -24
  56. package/peer/BalancePull.sol +0 -49
@@ -1,49 +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, Schemas} from "../Cursors.sol";
6
-
7
- using Cursors for Cur;
8
-
9
- interface IPeerBalancePull {
10
- function peerBalancePull(bytes calldata request) external returns (bytes memory);
11
- }
12
-
13
- abstract contract BalancePullHook {
14
- /// @notice Override to process one incoming balance-based pull request from a peer host.
15
- /// @param peer Peer host node ID for this request.
16
- /// @param asset Requested asset identifier.
17
- /// @param meta Requested asset metadata slot.
18
- /// @param amount Requested amount in the asset's native units.
19
- function balancePull(uint peer, bytes32 asset, bytes32 meta, uint amount) internal virtual;
20
- }
21
-
22
- /// @title PeerBalancePull
23
- /// @notice Peer that pulls requested balances from a peer host into this one.
24
- /// Each BALANCE block in the request calls `balancePull(peer, asset, meta, amount)`.
25
- /// Restricted to trusted peers.
26
- abstract contract PeerBalancePull is PeerBase, BalancePullHook, IPeerBalancePull {
27
- uint internal immutable peerBalancePullId = peerId(this.peerBalancePull.selector);
28
-
29
- constructor() {
30
- emit Peer(host, peerBalancePullId, "1:0", Schemas.Balance, "", false);
31
- emit Labeled(peerBalancePullId, bytes32(0), "peerBalancePull");
32
- }
33
-
34
- /// @notice Execute the balance-pull peer call.
35
- /// @param request BALANCE block stream requested by the trusted peer.
36
- /// @return Empty response bytes.
37
- function peerBalancePull(bytes calldata request) external onlyPeer returns (bytes memory) {
38
- (Cur memory input, , ) = Cursors.init(request, 1);
39
- uint peer = caller();
40
-
41
- while (input.i < input.len) {
42
- (bytes32 asset, bytes32 meta, uint amount) = input.unpackBalance();
43
- balancePull(peer, asset, meta, amount);
44
- }
45
-
46
- input.complete();
47
- return "";
48
- }
49
- }