@rootzero/contracts 1.6.0 → 1.8.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 (48) hide show
  1. package/CHANGELOG.md +54 -1
  2. package/Core.sol +1 -1
  3. package/Endpoints.sol +15 -15
  4. package/Events.sol +2 -1
  5. package/README.md +9 -9
  6. package/blocks/Cursors.sol +36 -49
  7. package/blocks/Keys.sol +5 -5
  8. package/blocks/Schema.sol +4 -2
  9. package/blocks/Writers.sol +0 -35
  10. package/commands/Deposit.sol +2 -2
  11. package/commands/Provision.sol +2 -2
  12. package/commands/Recover.sol +48 -0
  13. package/commands/Relay.sol +4 -4
  14. package/commands/admin/Execute.sol +2 -4
  15. package/core/Calls.sol +74 -38
  16. package/core/Commitments.sol +1 -1
  17. package/core/Payable.sol +15 -28
  18. package/core/Pipeline.sol +1 -1
  19. package/docs/Schema.md +13 -2
  20. package/events/Commitment.sol +4 -4
  21. package/events/Dispatch.sol +20 -0
  22. package/events/Port.sol +22 -0
  23. package/guards/Base.sol +0 -11
  24. package/package.json +1 -1
  25. package/ports/AllowAssets.sol +40 -0
  26. package/ports/Allowance.sol +37 -0
  27. package/ports/Base.sol +30 -0
  28. package/ports/Credit.sol +35 -0
  29. package/ports/Debit.sol +35 -0
  30. package/ports/DenyAssets.sol +40 -0
  31. package/{peer → ports}/Dispatch.sol +11 -15
  32. package/ports/Pipe.sol +39 -0
  33. package/{peer → ports}/Redeem.sol +11 -15
  34. package/ports/Settle.sol +37 -0
  35. package/queries/Base.sol +0 -11
  36. package/utils/Layout.sol +3 -3
  37. package/utils/Nodes.sol +21 -21
  38. package/utils/Value.sol +12 -5
  39. package/events/Peer.sol +0 -22
  40. package/peer/AllowAssets.sol +0 -44
  41. package/peer/Allowance.sol +0 -41
  42. package/peer/Base.sol +0 -41
  43. package/peer/Credit.sol +0 -39
  44. package/peer/Debit.sol +0 -39
  45. package/peer/DenyAssets.sol +0 -44
  46. package/peer/Pipe.sol +0 -44
  47. package/peer/Recover.sol +0 -51
  48. package/peer/Settle.sol +0 -41
package/peer/Recover.sol DELETED
@@ -1,51 +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 IPeerRecover {
10
- function peerRecover(bytes calldata request) external returns (bytes memory);
11
- }
12
-
13
- abstract contract RecoverHook {
14
- /// @notice Override to recover one incoming pipe context from a peer host.
15
- /// @dev Implementations may refund, retry, compensate, reconcile, or otherwise
16
- /// handle the supplied state and remaining steps.
17
- /// @param account Account identifier for the recovery context.
18
- /// @param state Embedded recovery state block stream.
19
- /// @param steps Embedded recovery step block stream.
20
- function recover(bytes32 account, bytes calldata state, bytes calldata steps) internal virtual;
21
- }
22
-
23
- /// @title PeerRecover
24
- /// @notice Peer endpoint for recovering an interrupted or failed pipe context.
25
- /// @dev Commonly used when a cross-chain pipe fails at its destination, but the
26
- /// hook is host-defined and may implement any recovery strategy. Each PIPE
27
- /// block carries chain resources plus a CONTEXT block; the nested context
28
- /// is passed to the recovery hook and resources are not allocated.
29
- abstract contract PeerRecover is PeerBase, RecoverHook, IPeerRecover {
30
- uint internal immutable peerRecoverId = peerId(this.peerRecover.selector);
31
-
32
- constructor() {
33
- emit Peer(host, peerRecoverId, "1:0", Schemas.Pipe, "", false);
34
- emit Labeled(peerRecoverId, bytes32(0), "peerRecover");
35
- }
36
-
37
- /// @notice Forward peer-supplied recovery pipes to the host-defined recovery hook.
38
- /// @param request PIPE block stream supplied by the trusted peer.
39
- /// @return Empty response bytes.
40
- function peerRecover(bytes calldata request) external onlyPeer returns (bytes memory) {
41
- (Cur memory input, , ) = Cursors.init(request, 1);
42
-
43
- while (input.i < input.len) {
44
- (, bytes32 account, bytes calldata state, bytes calldata steps) = input.unpackPipe();
45
- recover(account, state, steps);
46
- }
47
-
48
- input.complete();
49
- return "";
50
- }
51
- }
package/peer/Settle.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 { CreditAccountHook } from "../commands/Credit.sol";
6
- import { DebitAccountHook } from "../commands/Debit.sol";
7
- import { Cursors, Cur, Schemas } from "../Cursors.sol";
8
-
9
- using Cursors for Cur;
10
-
11
- interface IPeerSettle {
12
- function peerSettle(bytes calldata request) external returns (bytes memory);
13
- }
14
-
15
- /// @title PeerSettle
16
- /// @notice Peer that consumes peer-supplied TRANSACTION blocks through debit and credit hooks.
17
- /// Each TRANSACTION block calls `debitAccount` for `from` and `creditAccount` for `to`.
18
- abstract contract PeerSettle is PeerBase, DebitAccountHook, CreditAccountHook, IPeerSettle {
19
- uint internal immutable peerSettleId = peerId(this.peerSettle.selector);
20
-
21
- constructor() {
22
- emit Peer(host, peerSettleId, "1:0", Schemas.Transaction, "", false);
23
- emit Labeled(peerSettleId, bytes32(0), "peerSettle");
24
- }
25
-
26
- /// @notice Execute the peer-settle call.
27
- /// @param request TRANSACTION block stream supplied by the trusted peer.
28
- /// @return Empty response bytes.
29
- function peerSettle(bytes calldata request) external onlyPeer returns (bytes memory) {
30
- (Cur memory state, , ) = Cursors.init(request, 1);
31
-
32
- while (state.i < state.len) {
33
- (bytes32 from, bytes32 to, bytes32 asset, uint amount) = state.unpackTransaction();
34
- if (from != 0) debitAccount(from, asset, amount);
35
- if (to != 0) creditAccount(to, asset, amount);
36
- }
37
-
38
- state.complete();
39
- return "";
40
- }
41
- }