@rootzero/contracts 1.18.0 → 1.20.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,102 @@
3
3
  Until the protocol reaches integration-stable status, minor versions may include
4
4
  breaking API changes. Breaking changes are called out explicitly.
5
5
 
6
+ ## 1.20.0
7
+
8
+ ### Breaking Changes
9
+
10
+ - `Nodes.toCommand`, `toPort`, `toQuery`, and `toGuard` now take an endpoint
11
+ name instead of a precomputed selector. The `Selectors` library was removed;
12
+ endpoint node IDs now derive their canonical selectors internally.
13
+ - Renamed the memory-backed pipeline adapters from `InternalDebitAccount`,
14
+ `InternalCreditAccount`, and `InternalSettle` to `DebitAccountInternal`,
15
+ `CreditAccountInternal`, and `SettleInternal`.
16
+ - Replaced `RelayPayableHook.relayTo(portal, resources, payload, funds)` with
17
+ `relay(portal, resources, account, state, input, funds)`. Relay commands now
18
+ pass their semantic context fields to the host instead of encoding a
19
+ `CONTEXT` payload before invoking the hook.
20
+ - `DispatchPayablePort` now uses the dedicated
21
+ `DispatchPayableHook.dispatchTo(portal, resources, payload, funds)` hook
22
+ instead of sharing `RelayPayableHook`.
23
+
24
+ ### Added
25
+
26
+ - Added `RelayEvent`, with account, portal, resources, correlation key, and
27
+ digest fields for recording outbound relay references.
28
+
29
+ ### Changed
30
+
31
+ - Relay hooks retain state and nested relay input as calldata until an
32
+ implementation chooses to encode or otherwise consume the destination
33
+ context.
34
+
35
+ ### Upgrade Compatibility
36
+
37
+ - Pass endpoint names directly to the `Nodes.to*` helpers and remove imports of
38
+ `Selectors`.
39
+ - Update inherited internal adapter names and imports to the new postfix
40
+ convention.
41
+ - Implement the structured `RelayPayableHook.relay` hook for relay commands and
42
+ `DispatchPayableHook.dispatchTo` for opaque dispatch payloads. Hosts that
43
+ support both surfaces must implement both hooks.
44
+
45
+ ## 1.19.0
46
+
47
+ ### Breaking Changes
48
+
49
+ - Renamed port endpoint contracts from the `Port*` prefix convention to the
50
+ `*Port` postfix convention: `PortAllowAssets`, `PortAllowance`,
51
+ `PortCreditAccount`, `PortDebitAccount`, `PortDenyAssets`,
52
+ `PortDispatchPayable`, `PortPipePayable`, `PortPost`, and
53
+ `PortRedeemBalance` are now `AllowAssetsPort`, `AllowancePort`,
54
+ `CreditAccountPort`, `DebitAccountPort`, `DenyAssetsPort`,
55
+ `DispatchPayablePort`, `PipePayablePort`, `PostPort`, and
56
+ `RedeemBalancePort` respectively. Endpoint selectors are unchanged.
57
+ - Removed `Blocks.readUint`; cast `uint(Blocks.read32(abs))` when an unchecked
58
+ absolute word read is required, or use the new cursor-consuming `next32`
59
+ helpers while decoding.
60
+ - `Cursors.advance` and `Cursors.slice` now assume the documented packed-cursor
61
+ invariant `i <= len` instead of pre-validating manually constructed cursor
62
+ words. Invalid raw cursor words may now produce an arithmetic panic rather
63
+ than `Cursors.OutOfBounds`.
64
+
65
+ ### Added
66
+
67
+ - Added `enter` and `expectAbs` to `Decoders` and `Executions` for entering a
68
+ parent payload, decoding its children in place, and proving exact final
69
+ consumption.
70
+ - Added consuming `next1`, `next2`, `next4`, `next8`, `next16`, and `next32`
71
+ helpers to `Decoders` and `Executions` for compact fixed-width schema fields.
72
+ - Added calldata-copy encoding across `Buffers`, `Blocks`, `Writers`, and
73
+ `Executions`. In-place helpers use `copy*`, execution helpers use
74
+ `outputCopy*`, and allocating block factories use the `*Copy` suffix.
75
+ - Added allocating factories for LIST, EVM, CONTEXT, and RECOVER blocks, plus
76
+ memory and calldata factory pairs for dynamic leaf and composite blocks.
77
+
78
+ ### Changed
79
+
80
+ - Block factories now allocate once and delegate to their canonical `write*`
81
+ or `copy*` encoder instead of assembling nested intermediate byte arrays.
82
+ - Relay and dispatch paths preserve calldata slices until their destination
83
+ requires memory, avoiding unnecessary explicit calldata-to-memory casts.
84
+ - `Settlement.settle` now implements its documented behavior by routing the
85
+ liability leg through the virtual `repay` primitive before crediting the
86
+ asset leg.
87
+ - Documented that restricting schema `bytesN` fields to power-of-two widths is
88
+ under consideration; all widths from `bytes1` through `bytes32` remain valid.
89
+
90
+ ### Upgrade Compatibility
91
+
92
+ - Update inherited port contract names and their imports to the new `*Port`
93
+ names. No endpoint selector or wire-format migration is required.
94
+ - Replace `Blocks.readUint(abs)` with `uint(Blocks.read32(abs))`, or migrate
95
+ sequential custom decoders to `enter`, `next*`, and `expectAbs`.
96
+ - Code that constructs packed cursors manually must establish `i <= len`
97
+ before calling navigation helpers. Normal cursor constructors and composition
98
+ helpers already preserve this invariant.
99
+ - `Settlement` subclasses that override `repay` will now have that override
100
+ invoked by `settle`, matching the documented extension point.
101
+
6
102
  ## 1.18.0
7
103
 
8
104
  ### Added
package/Endpoints.sol CHANGED
@@ -5,57 +5,52 @@ pragma solidity ^0.8.33;
5
5
  // Import this file to inherit from the full rootzero callable host surface without managing individual paths.
6
6
 
7
7
  // Shared endpoint hooks
8
- import { CreditAccountHook, DebitAccountHook, PostHook, RepayHook, SettleHook } from "./core/Settlement.sol";
8
+ import {CreditAccountHook, DebitAccountHook, PostHook, RepayHook, SettleHook} from "./core/Settlement.sol";
9
9
 
10
10
  // Commands
11
- import { CommandBase } from "./commands/Base.sol";
12
- import { Allocate, AllocateHook } from "./commands/Allocate.sol";
13
- import { Burn, BurnHook } from "./commands/Burn.sol";
14
- import { CreditAccount, InternalCreditAccount } from "./commands/Credit.sol";
15
- import { DebitAccount, InternalDebitAccount } from "./commands/Debit.sol";
16
- import { Deposit, DepositHook, DepositPayable, DepositPayableHook } from "./commands/Deposit.sol";
17
- import { Payout, PayoutHook } from "./commands/Payout.sol";
18
- import { Provision, ProvisionHook, ProvisionPayable, ProvisionPayableHook } from "./commands/Provision.sol";
19
- import { RecoverPayable, RecoverPayableHook } from "./commands/Recover.sol";
20
- import { Repay, RepayPayable, RepayPayableHook } from "./commands/Repay.sol";
21
- import { RelayPayable, RelayBalancePayable, RelayPayableHook } from "./commands/Relay.sol";
22
- import {
23
- InternalSettle,
24
- Settle,
25
- SettlePayable,
26
- SettlePayableHook
27
- } from "./commands/Settle.sol";
28
- import { Withdraw, WithdrawHook } from "./commands/Withdraw.sol";
11
+ import {CommandBase} from "./commands/Base.sol";
12
+ import {Allocate, AllocateHook} from "./commands/Allocate.sol";
13
+ import {Burn, BurnHook} from "./commands/Burn.sol";
14
+ import {CreditAccount, CreditAccountInternal} from "./commands/Credit.sol";
15
+ import {DebitAccount, DebitAccountInternal} from "./commands/Debit.sol";
16
+ import {Deposit, DepositHook, DepositPayable, DepositPayableHook} from "./commands/Deposit.sol";
17
+ import {Payout, PayoutHook} from "./commands/Payout.sol";
18
+ import {Provision, ProvisionHook, ProvisionPayable, ProvisionPayableHook} from "./commands/Provision.sol";
19
+ import {RecoverPayable, RecoverPayableHook} from "./commands/Recover.sol";
20
+ import {Repay, RepayPayable, RepayPayableHook} from "./commands/Repay.sol";
21
+ import {RelayPayable, RelayBalancePayable, RelayPayableHook} from "./commands/Relay.sol";
22
+ import {Settle, SettlePayable, SettlePayableHook, SettleInternal} from "./commands/Settle.sol";
23
+ import {Withdraw, WithdrawHook} from "./commands/Withdraw.sol";
29
24
 
30
25
  // Admin commands
31
- import { AdminBase } from "./commands/admin/Base.sol";
32
- import { AllowAssets, AllowAssetsHook } from "./commands/admin/AllowAssets.sol";
33
- import { Allowance, AllowanceHook } from "./commands/admin/Allowance.sol";
34
- import { Annotate } from "./commands/admin/Annotate.sol";
35
- import { Appoint } from "./commands/admin/Appoint.sol";
36
- import { Authorize } from "./commands/admin/Authorize.sol";
37
- import { DenyAssets, DenyAssetsHook } from "./commands/admin/DenyAssets.sol";
38
- import { Dismiss } from "./commands/admin/Dismiss.sol";
39
- import { ExecutePayable } from "./commands/admin/Execute.sol";
40
- import { Unauthorize } from "./commands/admin/Unauthorize.sol";
26
+ import {AdminBase} from "./commands/admin/Base.sol";
27
+ import {AllowAssets, AllowAssetsHook} from "./commands/admin/AllowAssets.sol";
28
+ import {Allowance, AllowanceHook} from "./commands/admin/Allowance.sol";
29
+ import {Annotate} from "./commands/admin/Annotate.sol";
30
+ import {Appoint} from "./commands/admin/Appoint.sol";
31
+ import {Authorize} from "./commands/admin/Authorize.sol";
32
+ import {DenyAssets, DenyAssetsHook} from "./commands/admin/DenyAssets.sol";
33
+ import {Dismiss} from "./commands/admin/Dismiss.sol";
34
+ import {ExecutePayable} from "./commands/admin/Execute.sol";
35
+ import {Unauthorize} from "./commands/admin/Unauthorize.sol";
41
36
 
42
37
  // Port endpoints
43
- import { PortBase } from "./ports/Base.sol";
44
- import { PortAllowAssets } from "./ports/AllowAssets.sol";
45
- import { PortAllowance } from "./ports/Allowance.sol";
46
- import { PortRedeemBalance, RedeemBalanceHook } from "./ports/Redeem.sol";
47
- import { PortCreditAccount } from "./ports/Credit.sol";
48
- import { PortDebitAccount } from "./ports/Debit.sol";
49
- import { PortDenyAssets } from "./ports/DenyAssets.sol";
50
- import { PortPipePayable } from "./ports/Pipe.sol";
51
- import { PortDispatchPayable } from "./ports/Dispatch.sol";
52
- import { PortPost } from "./ports/Post.sol";
38
+ import {PortBase} from "./ports/Base.sol";
39
+ import {AllowAssetsPort} from "./ports/AllowAssets.sol";
40
+ import {AllowancePort} from "./ports/Allowance.sol";
41
+ import {RedeemBalancePort, RedeemBalanceHook} from "./ports/Redeem.sol";
42
+ import {CreditAccountPort} from "./ports/Credit.sol";
43
+ import {DebitAccountPort} from "./ports/Debit.sol";
44
+ import {DenyAssetsPort} from "./ports/DenyAssets.sol";
45
+ import {PipePayablePort} from "./ports/Pipe.sol";
46
+ import {DispatchPayablePort, DispatchPayableHook} from "./ports/Dispatch.sol";
47
+ import {PostPort} from "./ports/Post.sol";
53
48
 
54
49
  // Guard endpoints
55
- import { GuardBase } from "./guards/Base.sol";
56
- import { Revoke, RevokeAllowance, RevokeAsset } from "./guards/Revoke.sol";
50
+ import {GuardBase} from "./guards/Base.sol";
51
+ import {Revoke, RevokeAllowance, RevokeAsset} from "./guards/Revoke.sol";
57
52
 
58
53
  // Query endpoints
59
- import { QueryBase } from "./queries/Base.sol";
60
- import { AssetStatus, AssetStatusHook } from "./queries/Assets.sol";
61
- import { GetBalances, GetBalancesHook } from "./queries/Balances.sol";
54
+ import {QueryBase} from "./queries/Base.sol";
55
+ import {AssetStatus, AssetStatusHook} from "./queries/Assets.sol";
56
+ import {GetBalances, GetBalancesHook} from "./queries/Balances.sol";
package/Events.sol CHANGED
@@ -13,6 +13,7 @@ import { DispatchEvent } from "./events/Dispatch.sol";
13
13
  import { EndpointEvent } from "./events/Endpoint.sol";
14
14
  import { ReceivedEvent } from "./events/Received.sol";
15
15
  import { RecoveredEvent } from "./events/Recovered.sol";
16
+ import { RelayEvent } from "./events/Relay.sol";
16
17
  import { EventEmitter } from "./events/Emitter.sol";
17
18
  import { GuardianEvent } from "./events/Guardian.sol";
18
19
  import { IntroductionEvent } from "./events/Introduction.sol";
package/README.md CHANGED
@@ -378,8 +378,8 @@ command batching — and `resources` is a chain-specific word interpreted by the
378
378
  portal adapter (on EVM, the low 128 bits are native value in wei, drawn from a
379
379
  shared budget), so the same pipeline bytes are meaningful to every port.
380
380
 
381
- Hosts that implement a pipeline locally can inherit `InternalDebitAccount`,
382
- `InternalCreditAccount`, and `InternalSettle` to advertise the canonical command
381
+ Hosts that implement a pipeline locally can inherit `DebitAccountInternal`,
382
+ `CreditAccountInternal`, and `SettleInternal` to advertise the canonical command
383
383
  endpoints while routing their local command IDs through `executeDebitAccount`,
384
384
  `executeCreditAccount`, and `executeSettle`. These adapters consume the
385
385
  memory-backed pipeline state directly and avoid an external self-call. Pass the
package/Utils.sol CHANGED
@@ -11,7 +11,6 @@ import { Amounts, Assets } from "./utils/Assets.sol";
11
11
  import { ECDSA } from "./utils/ECDSA.sol";
12
12
  import { Ids } from "./utils/Ids.sol";
13
13
  import { Nodes } from "./utils/Nodes.sol";
14
- import { Selectors } from "./utils/Selectors.sol";
15
14
  import { Layout } from "./utils/Layout.sol";
16
15
  import { addrOr, applyBps, beforeBps, bytes32ToInt, bytes32ToString, clear8, clear16, clear32, clear64, divisible, ensureAddr, hash32, intToBytes32, isFamily, matchesBase, MAX_BPS, max8, max16, max24, max32, max40, max64, max96, max128, max160, NotDivisible, replace8, replace16, replace32, replace64, retryTicket, toLocalBase, toUnspecifiedBase, ValueOverflow, ZeroAddress } from "./utils/Utils.sol";
17
16
 
@@ -13,11 +13,7 @@ abstract contract Label is AnnotationEvent {
13
13
  /// @param entity Entity receiving the label annotation.
14
14
  /// @param namespace Label namespace.
15
15
  /// @param name Human-readable name within the namespace.
16
- function label(
17
- uint entity,
18
- bytes32 namespace,
19
- string memory name
20
- ) internal virtual {
16
+ function label(uint entity, bytes32 namespace, string memory name) internal virtual {
21
17
  emit Annotation(entity, Blocks.label(namespace, name));
22
18
  }
23
19
  }