@rootzero/contracts 1.20.0 → 1.22.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 (59) hide show
  1. package/CHANGELOG.md +91 -0
  2. package/Codec.sol +1 -1
  3. package/Commands.sol +1 -0
  4. package/Endpoints.sol +1 -0
  5. package/Events.sol +2 -2
  6. package/README.md +25 -15
  7. package/annotations/Schema.sol +35 -2
  8. package/codec/Blocks.sol +64 -2
  9. package/codec/Decoders.sol +71 -9
  10. package/codec/Descriptors.sol +28 -28
  11. package/codec/Readers.sol +39 -0
  12. package/codec/Schema.sol +45 -36
  13. package/codec/Specs.sol +9 -27
  14. package/codec/Writers.sol +8 -0
  15. package/commands/Allocate.sol +1 -1
  16. package/commands/Base.sol +3 -8
  17. package/commands/Burn.sol +1 -1
  18. package/commands/Credit.sol +1 -1
  19. package/commands/Debit.sol +1 -1
  20. package/commands/Deposit.sol +3 -10
  21. package/commands/Payout.sol +1 -1
  22. package/commands/Provision.sol +3 -3
  23. package/commands/Recover.sol +3 -3
  24. package/commands/Relay.sol +5 -4
  25. package/commands/Repay.sol +3 -3
  26. package/commands/Settle.sol +3 -3
  27. package/commands/Withdraw.sol +1 -1
  28. package/commands/admin/AllowAssets.sol +2 -2
  29. package/commands/admin/Allowance.sol +2 -2
  30. package/commands/admin/Annotate.sol +2 -2
  31. package/commands/admin/Appoint.sol +2 -2
  32. package/commands/admin/Authorize.sol +2 -2
  33. package/commands/admin/Base.sol +1 -1
  34. package/commands/admin/DenyAssets.sol +2 -8
  35. package/commands/admin/Dismiss.sol +2 -2
  36. package/commands/admin/Execute.sol +2 -2
  37. package/commands/admin/Unauthorize.sol +2 -2
  38. package/core/Host.sol +7 -10
  39. package/core/Portal.sol +11 -8
  40. package/events/Dispatch.sol +1 -1
  41. package/events/Relay.sol +1 -1
  42. package/events/Resolved.sol +17 -0
  43. package/events/Route.sol +1 -1
  44. package/events/Unresolved.sol +18 -0
  45. package/execution/Execution.sol +92 -5
  46. package/package.json +2 -3
  47. package/ports/AllowAssets.sol +1 -1
  48. package/ports/Allowance.sol +1 -1
  49. package/ports/Base.sol +3 -3
  50. package/ports/Credit.sol +1 -1
  51. package/ports/Debit.sol +1 -1
  52. package/ports/DenyAssets.sol +1 -1
  53. package/ports/Dispatch.sol +4 -2
  54. package/ports/Pipe.sol +2 -1
  55. package/ports/Post.sol +1 -1
  56. package/ports/Redeem.sol +1 -1
  57. package/docs/Schema.md +0 -403
  58. package/events/Recovered.sol +0 -17
  59. package/events/Undelivered.sol +0 -18
package/codec/Readers.sol CHANGED
@@ -45,6 +45,45 @@ library Readers {
45
45
  return cur.i != cur.source.length;
46
46
  }
47
47
 
48
+ /// @notice Return whether the current block has `key` and an empty payload.
49
+ /// @param cur Reader inspected without advancing.
50
+ /// @param key Expected block key.
51
+ /// @return Whether a complete matching empty block header occurs at the current position.
52
+ function isEmpty(Reader memory cur, bytes4 key) internal pure returns (bool) {
53
+ bytes memory source = cur.source;
54
+ uint i = cur.i;
55
+ if (i > source.length || source.length - i < Sizes.Header) return false;
56
+
57
+ uint header;
58
+ assembly ("memory-safe") {
59
+ header := mload(add(add(source, 0x20), i))
60
+ }
61
+ return bytes4(uint32(header >> 224)) == key && uint32(header >> 192) == 0;
62
+ }
63
+
64
+ /// @notice Consume a matching empty block from the reader when present.
65
+ /// @param cur Reader advanced only when the matching block is empty.
66
+ /// @param key Expected block key.
67
+ /// @return Whether an empty block was consumed.
68
+ function tryConsumeEmpty(Reader memory cur, bytes4 key) internal pure returns (bool) {
69
+ bytes memory source = cur.source;
70
+ uint i = cur.i;
71
+ if (i > source.length || source.length - i < Sizes.Header) revert InvalidBlock();
72
+
73
+ bytes4 current;
74
+ uint len;
75
+ assembly ("memory-safe") {
76
+ let header := mload(add(add(source, 0x20), i))
77
+ current := header
78
+ len := and(shr(192, header), 0xffffffff)
79
+ }
80
+
81
+ if (len > source.length - i - Sizes.Header) revert InvalidBlock();
82
+ if (current != key || len != 0) return false;
83
+ cur.i += Sizes.Header;
84
+ return true;
85
+ }
86
+
48
87
  /// @notice Validate and consume the current block, advancing `cur.i` past it.
49
88
  /// @param cur Reader to advance.
50
89
  /// @param key Expected block key.
package/codec/Schema.sol CHANGED
@@ -8,24 +8,34 @@ pragma solidity ^0.8.33;
8
8
  //
9
9
  // Schema:
10
10
  // - block aliases are published separately from payload schemas
11
- // - payload schemas are written as `{ fields }`
11
+ // - payload schemas are `""` or a comma-separated item sequence; one optional
12
+ // pair of outer braces may wrap a non-empty sequence without changing meaning
12
13
  // - an empty schema string means the block has no structured payload
13
14
  // - commas separate siblings at every level
14
- // - braces define the current block payload body
15
+ // - braces are presentation-only and do not change payload layout
15
16
  // - command inputs are a single run when the input schema is non-empty
16
17
  // - command state is a single active state run without trailing globals
17
18
  // - run items may repeat at top level for batching
18
- // - `maybe #x` marks an optional block item
19
- // - `many #x` emits one generic list block containing repeated `#x` items
20
- // - endpoint descriptor lanes are `[key bytes4][item bytes4]`; normal keys widen to `[key][0]`
21
- // - descriptor lanes for `many #x` use `[Keys.List][keyOfX]`; bare `[Keys.List][0]`
22
- // is incomplete discovery metadata and should be rejected by tooling
23
- // - `portal` fields are routing identifiers, often destination host IDs
19
+ // - every declared child block header is present when its parent is non-empty
20
+ // - any block may use a zero-length payload as its empty form
21
+ // - `maybe #x` hints that the onchain consumer accepts the empty form of `#x`
22
+ // when emptiness is not already intrinsic to the referenced block type
23
+ // - `many #x` alongside other items emits one generic list block containing
24
+ // zero or more repeated `#x` items; the list header is always present
25
+ // - a custom schema consisting of exactly one `many #x` item uses its custom
26
+ // key for the outer list block and contains repeated `#x` items directly,
27
+ // whether or not the item is wrapped in braces
28
+ // - endpoint descriptor lanes identify their top-level block key directly
29
+ // - `portal` fields identify destination portal hosts. By convention the value
30
+ // is the portal implementation's host ID; core passes it through unchanged
31
+ // and hooks may validate or resolve it for their transport
24
32
  // - `resources` fields are chain-specific resource words. A portal adapter
25
33
  // interprets them for the destination runtime. EVM resources use the low
26
34
  // 128 bits as native value.
27
35
  // - dotted field names and aliases, e.g. `dst.portal` or `#bytes as dst.payload`,
28
36
  // are offchain projection metadata only and do not change runtime encoding
37
+ // - `at N` assigns an offchain presentation position to one sibling; explicit
38
+ // positions are reserved first and unannotated siblings retain relative order
29
39
  // - child blocks resolve by alias in the active schema context; unresolved aliases are invalid
30
40
  // - schema strings describe the payload body only; the `Block` event carries the alias
31
41
  // - items are encoded in declaration order
@@ -63,7 +73,6 @@ pragma solidity ^0.8.33;
63
73
  library Schemas {
64
74
  // Empty and reserved payloads
65
75
 
66
- string constant Unit = "";
67
76
  string constant Bytes = "";
68
77
  string constant String = "";
69
78
  string constant List = "";
@@ -71,47 +80,47 @@ library Schemas {
71
80
 
72
81
  // One-word payloads
73
82
 
74
- string constant Node = "{ uint id }";
75
- string constant Account = "{ bytes32 account }";
76
- string constant Asset = "{ bytes32 asset }";
77
- string constant Status = "{ uint code }";
83
+ string constant Node = "uint node";
84
+ string constant Account = "bytes32 account";
85
+ string constant Asset = "bytes32 asset";
86
+ string constant Status = "uint code";
78
87
 
79
88
  // Two-word payloads
80
89
 
81
- string constant Amount = "{ bytes32 asset, uint amount }";
82
- string constant Balance = "{ bytes32 asset, uint amount }";
83
- string constant AccountAsset = "{ bytes32 account, bytes32 asset }";
84
- string constant HostAsset = "{ uint host, bytes32 asset }";
90
+ string constant Amount = "bytes32 asset, uint amount";
91
+ string constant Balance = "bytes32 asset, uint amount";
92
+ string constant AccountAsset = "bytes32 account, bytes32 asset";
93
+ string constant HostAsset = "uint host, bytes32 asset";
85
94
 
86
95
  // Three-word payloads
87
96
 
88
- string constant Allocation = "{ uint host, bytes32 asset, uint amount }";
89
- string constant Allowance = "{ uint host, bytes32 asset, uint amount }";
90
- string constant Custody = "{ uint host, bytes32 asset, uint amount }";
91
- string constant AccountAmount = "{ bytes32 account, bytes32 asset, uint amount }";
92
- string constant HostAmount = "{ uint host, bytes32 asset, uint amount }";
93
- string constant HostAccountAsset = "{ uint host, bytes32 account, bytes32 asset }";
97
+ string constant Allocation = "uint host, bytes32 asset, uint amount";
98
+ string constant Allowance = "uint host, bytes32 asset, uint amount";
99
+ string constant Custody = "uint host, bytes32 asset, uint amount";
100
+ string constant AccountAmount = "bytes32 account, bytes32 asset, uint amount";
101
+ string constant HostAmount = "uint host, bytes32 asset, uint amount";
102
+ string constant HostAccountAsset = "uint host, bytes32 account, bytes32 asset";
94
103
 
95
104
  // Four-word payloads
96
105
 
97
- string constant Position = "{ bytes32 asset, uint amount, bytes32 liability, uint debt }";
98
- string constant Transaction = "{ bytes32 from, bytes32 to, bytes32 asset, uint amount }";
99
- string constant HostAccountAmount = "{ uint host, bytes32 account, bytes32 asset, uint amount }";
106
+ string constant Position = "bytes32 asset, uint amount, bytes32 liability, uint debt";
107
+ string constant Transaction = "bytes32 from, bytes32 to, bytes32 asset, uint amount";
108
+ string constant HostAccountAmount = "uint host, bytes32 account, bytes32 asset, uint amount";
100
109
 
101
110
  // Composite payloads
102
111
 
103
- string constant Call = "{ uint target, uint resources, #bytes as payload }";
104
- string constant Step = "{ uint cmd, uint resources, #bytes as input }";
105
- string constant Relay = "{ uint portal, uint resources, #bytes as input }";
106
- string constant Dispatch = "{ uint portal, uint resources, #bytes as payload }";
107
- string constant Context = "{ bytes32 account, #bytes as state, #bytes as input }";
108
- string constant Recover = "{ uint handler, uint resources, bytes32 key, #bytes as witness }";
109
- string constant Annotation = "{ uint entity, #bytes as data }";
112
+ string constant Call = "uint target, uint resources, #bytes as payload";
113
+ string constant Step = "uint cmd, uint resources, #bytes as input";
114
+ string constant Relay = "uint portal, uint resources, #bytes as input";
115
+ string constant Dispatch = "uint portal, uint resources, #bytes as payload";
116
+ string constant Context = "bytes32 account, #bytes as state, #bytes as input";
117
+ string constant Recover = "uint handler, uint resources, bytes32 key, #bytes as witness";
118
+ string constant Annotation = "uint entity, #bytes as data";
110
119
 
111
120
  // Annotation payloads
112
121
 
113
- string constant Action = "{ uint action }";
114
- string constant Label = "{ bytes32 namespace, #string as name }";
115
- string constant Schema = "{ uint spec, #string as body, bytes32 name }";
122
+ string constant Action = "uint action";
123
+ string constant Label = "bytes32 namespace, #string as name";
124
+ string constant Schema = "uint spec, #string as body, bytes32 name";
116
125
  }
117
126
 
package/codec/Specs.sol CHANGED
@@ -2,7 +2,7 @@
2
2
  pragma solidity ^0.8.33;
3
3
 
4
4
  import {Keys} from "./Keys.sol";
5
- import {max24, replace8, replace32} from "../utils/Utils.sol";
5
+ import {max24, replace8} from "../utils/Utils.sol";
6
6
 
7
7
  /// @title Sizes
8
8
  /// @notice Total byte sizes for fixed-width block types, including the 8-byte header (4-byte key + 4-byte payloadLen).
@@ -39,15 +39,13 @@ library Sizes {
39
39
 
40
40
  /// @title Specs
41
41
  /// @notice Word-aligned block specifications encoded as
42
- /// `[key:4][min:4][max:4][hint:3][stride:1][container:4][reserved:12]`.
42
+ /// `[key:4][min:4][max:4][hint:3][stride:1][reserved:16]`.
43
43
  /// The upper eight bytes of a fixed-layout spec are its encoded block header,
44
44
  /// allowing the entire spec word to be written directly as that header.
45
45
  /// A maximum of zero means unbounded and requires a growable writer.
46
46
  library Specs {
47
47
  /// @dev A payload is incompatible with its block specification.
48
48
  error InvalidSpec();
49
- /// @dev A direct specification cannot contain a wrapper block.
50
- error InvalidContainer();
51
49
  uint private constant SizeFields = (uint(1) << 192) | (uint(1) << 160) | (uint(1) << 136);
52
50
 
53
51
  // Reusable field shapes keep public specs readable while remaining valid
@@ -156,29 +154,20 @@ library Specs {
156
154
 
157
155
  /// @notice Return the canonical form of `spec` with implicit defaults resolved.
158
156
  /// @param spec Packed block specification.
159
- /// @param direct Whether the specification must not contain a wrapper block.
160
157
  /// @dev A present spec with an encoded zero stride receives stride one;
161
158
  /// the empty spec remains unchanged.
162
159
  /// @return Canonical specification.
163
- function normalize(uint spec, bool direct) internal pure returns (uint) {
164
- if (direct && uint32(spec >> 96) != 0) revert InvalidContainer();
160
+ function normalize(uint spec) internal pure returns (uint) {
165
161
  if (stride(spec) == 0 && key(spec) != bytes4(0)) spec |= uint(1) << 128;
166
162
  return spec;
167
163
  }
168
164
 
169
- /// @notice Return the effective outer block key and optional wrapped child key.
170
- /// @dev A direct spec returns its own key as `outer` and a zero `child`.
165
+ /// @notice Return the canonical descriptor lane metadata for `spec`.
171
166
  /// @param spec Packed block specification.
172
- /// @return outer Effective outer block key.
173
- /// @return child Wrapped child key, or zero for a direct specification.
174
- function keys(uint spec) internal pure returns (bytes4 outer, bytes4 child) {
175
- child = key(spec);
176
- outer = bytes4(uint32(spec >> 96));
177
-
178
- if (outer == bytes4(0)) {
179
- outer = child;
180
- child = bytes4(0);
181
- }
167
+ /// @return Packed `[key:4][stride:1]` lane metadata.
168
+ function lane(uint spec) internal pure returns (uint40) {
169
+ spec = normalize(spec);
170
+ return (uint40(uint32(key(spec))) << 8) | stride(spec);
182
171
  }
183
172
 
184
173
  /// @notice Return whether a payload size lies within a specification's bounds.
@@ -213,7 +202,7 @@ library Specs {
213
202
  /// @param groups Number of groups.
214
203
  /// @return Number of blocks across all groups.
215
204
  function count(uint spec, uint groups) internal pure returns (uint) {
216
- return groups * stride(normalize(spec, false));
205
+ return groups * stride(normalize(spec));
217
206
  }
218
207
 
219
208
  /// @notice Return the buffer configuration for `groups` of `spec`.
@@ -227,13 +216,6 @@ library Specs {
227
216
  growable = uint32(spec >> 160) == 0;
228
217
  }
229
218
 
230
- /// @notice Return `spec` annotated as a generic LIST item.
231
- /// @param spec Child block specification.
232
- /// @return Specification wrapped in a LIST container.
233
- function many(uint spec) internal pure returns (uint) {
234
- return replace32(spec, 96, uint32(key(List)));
235
- }
236
-
237
219
  /// @notice Return `spec` grouped with an explicit stride.
238
220
  /// @param spec Packed block specification.
239
221
  /// @param n Number of blocks per group.
package/codec/Writers.sol CHANGED
@@ -73,6 +73,14 @@ library Writers {
73
73
  // Append helpers
74
74
  // -------------------------------------------------------------------------
75
75
 
76
+ /// @notice Append an empty block.
77
+ /// @param writer Destination writer.
78
+ /// @param key Block key.
79
+ function appendEmpty(Writer memory writer, bytes4 key) internal pure {
80
+ uint i = reserve(writer, Sizes.Header);
81
+ Blocks.writeEmpty(writer.dst, i, key);
82
+ }
83
+
76
84
  /// @notice Append arbitrary bytes to the writer.
77
85
  /// @param writer Destination writer; `i` is advanced by `data.length`.
78
86
  /// @param data Bytes to append.
@@ -24,7 +24,7 @@ abstract contract Allocate is CommandBase, AllocateHook {
24
24
  uint private immutable descriptor;
25
25
 
26
26
  constructor() {
27
- (, descriptor) = command("allocate", Specs.Balance, Specs.Node, Specs.Custody, 0, false, false);
27
+ (, descriptor) = command("allocate", Specs.Balance, Specs.Node, Specs.Custody, 0, 0);
28
28
  }
29
29
 
30
30
  /// @notice Allocate BALANCE state blocks to matching NODE input blocks.
package/commands/Base.sol CHANGED
@@ -9,7 +9,7 @@ import {HostAmount, Position} from "../core/Types.sol";
9
9
  import {Execution, Executions, Lanes} from "../execution/Execution.sol";
10
10
  import {ReceivedEvent} from "../events/Received.sol";
11
11
  import {Actions} from "../utils/Actions.sol";
12
- import {Descriptors} from "../codec/Descriptors.sol";
12
+ import {Descriptors, Flags} from "../codec/Descriptors.sol";
13
13
  import {Nodes} from "../utils/Nodes.sol";
14
14
  import {Cursors} from "../utils/Cursors.sol";
15
15
 
@@ -44,8 +44,7 @@ abstract contract CommandBase is CallerAccess, EndpointBase, ReceivedEvent {
44
44
  /// @param input Input block specification.
45
45
  /// @param output Output block specification.
46
46
  /// @param transactions Number of transaction blocks produced per batch, or zero for none.
47
- /// @param funded Whether the command accepts nonzero native value.
48
- /// @param admin Whether the command is restricted to the admin account.
47
+ /// @param flags Packed command behavior flags.
49
48
  /// @return id Command node ID.
50
49
  /// @return descriptor Packed endpoint lane metadata and flags.
51
50
  function command(
@@ -54,12 +53,8 @@ abstract contract CommandBase is CallerAccess, EndpointBase, ReceivedEvent {
54
53
  uint input,
55
54
  uint output,
56
55
  uint8 transactions,
57
- bool funded,
58
- bool admin
56
+ uint8 flags
59
57
  ) internal returns (uint id, uint descriptor) {
60
- uint8 flags = 0;
61
- if (funded) flags |= Descriptors.Funded;
62
- if (admin) flags |= Descriptors.Admin;
63
58
  descriptor = Descriptors.create(state, input, output, transactions, flags);
64
59
  return command(name, descriptor);
65
60
  }
package/commands/Burn.sol CHANGED
@@ -25,7 +25,7 @@ abstract contract Burn is CommandBase, BurnHook, Action {
25
25
 
26
26
  constructor() {
27
27
  uint id;
28
- (id, descriptor) = command("burn", Specs.Balance, Specs.Empty, Specs.Empty, 0, false, false);
28
+ (id, descriptor) = command("burn", Specs.Balance, Specs.Empty, Specs.Empty, 0, 0);
29
29
  action(id, Actions.Burn);
30
30
  }
31
31
 
@@ -17,7 +17,7 @@ abstract contract CreditAccount is CommandBase, CreditAccountHook {
17
17
  uint private immutable id;
18
18
 
19
19
  constructor() {
20
- (id, descriptor) = command("creditAccount", Specs.Balance, Specs.Empty, Specs.Empty, 0, false, false);
20
+ (id, descriptor) = command("creditAccount", Specs.Balance, Specs.Empty, Specs.Empty, 0, 0);
21
21
  }
22
22
 
23
23
  /// @notice Return the registered CREDIT_ACCOUNT command ID.
@@ -20,7 +20,7 @@ abstract contract DebitAccount is CommandBase, DebitAccountHook {
20
20
  uint private immutable id;
21
21
 
22
22
  constructor() {
23
- (id, descriptor) = command("debitAccount", Specs.Empty, Specs.Amount, Specs.Balance, 0, false, false);
23
+ (id, descriptor) = command("debitAccount", Specs.Empty, Specs.Amount, Specs.Balance, 0, 0);
24
24
  }
25
25
 
26
26
  /// @notice Return the registered DEBIT_ACCOUNT command ID.
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-only
2
2
  pragma solidity ^0.8.33;
3
3
 
4
- import { Execution, Executions, CommandBase, Lanes, Specs } from "./Base.sol";
4
+ import {Execution, Executions, CommandBase, Flags, Lanes, Specs} from "./Base.sol";
5
5
  import {Action} from "../annotations/Action.sol";
6
6
  import {Actions} from "../utils/Actions.sol";
7
7
 
@@ -39,7 +39,7 @@ abstract contract Deposit is CommandBase, DepositHook, Action {
39
39
 
40
40
  constructor() {
41
41
  uint id;
42
- (id, descriptor) = command("deposit", Specs.Empty, Specs.Amount, Specs.Balance, 0, false, false);
42
+ (id, descriptor) = command("deposit", Specs.Empty, Specs.Amount, Specs.Balance, 0, 0);
43
43
  action(id, Actions.Deposit);
44
44
  }
45
45
 
@@ -72,7 +72,7 @@ abstract contract DepositPayable is CommandBase, DepositPayableHook, Action {
72
72
 
73
73
  constructor() {
74
74
  uint id;
75
- (id, descriptor) = command("depositPayable", Specs.Empty, Specs.Amount, Specs.Balance, 0, true, false);
75
+ (id, descriptor) = command("depositPayable", Specs.Empty, Specs.Amount, Specs.Balance, 0, Flags.Funded);
76
76
  action(id, Actions.Deposit);
77
77
  }
78
78
 
@@ -96,10 +96,3 @@ abstract contract DepositPayable is CommandBase, DepositPayableHook, Action {
96
96
  return close(exec, account);
97
97
  }
98
98
  }
99
-
100
-
101
-
102
-
103
-
104
-
105
-
@@ -26,7 +26,7 @@ abstract contract Payout is CommandBase, PayoutHook, Action {
26
26
 
27
27
  constructor() {
28
28
  uint id;
29
- (id, descriptor) = command("payout", Specs.Balance, Specs.Account, Specs.Empty, 0, false, false);
29
+ (id, descriptor) = command("payout", Specs.Balance, Specs.Account, Specs.Empty, 0, 0);
30
30
  action(id, Actions.Payout);
31
31
  }
32
32
 
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-only
2
2
  pragma solidity ^0.8.33;
3
3
 
4
- import {Execution, Executions, CommandBase, HostAmount, Lanes, Specs} from "./Base.sol";
4
+ import {Execution, Executions, CommandBase, Flags, HostAmount, Lanes, Specs} from "./Base.sol";
5
5
  using Executions for Execution;
6
6
 
7
7
  /// @notice Shared provision hook used by `Provision`.
@@ -32,7 +32,7 @@ abstract contract Provision is CommandBase, ProvisionHook {
32
32
  uint private immutable descriptor;
33
33
 
34
34
  constructor() {
35
- (, descriptor) = command("provision", Specs.Empty, Specs.Allocation, Specs.Custody, 0, false, false);
35
+ (, descriptor) = command("provision", Specs.Empty, Specs.Allocation, Specs.Custody, 0, 0);
36
36
  }
37
37
 
38
38
  /// @notice Provision ALLOCATION input blocks and output matching CUSTODY state blocks.
@@ -64,7 +64,7 @@ abstract contract ProvisionPayable is CommandBase, ProvisionPayableHook {
64
64
  uint private immutable descriptor;
65
65
 
66
66
  constructor() {
67
- (, descriptor) = command("provisionPayable", Specs.Empty, Specs.Allocation, Specs.Custody, 0, true, false);
67
+ (, descriptor) = command("provisionPayable", Specs.Empty, Specs.Allocation, Specs.Custody, 0, Flags.Funded);
68
68
  }
69
69
 
70
70
  /// @notice Provision ALLOCATION input blocks with access to a mutable native-value budget.
@@ -1,11 +1,11 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-only
2
2
  pragma solidity ^0.8.33;
3
3
 
4
- import {Execution, Executions, CommandBase, Lanes, Specs} from "./Base.sol";
4
+ import {Execution, Executions, CommandBase, Flags, Lanes, Specs} from "./Base.sol";
5
5
 
6
6
  using Executions for Execution;
7
7
 
8
- /// @notice Hook implemented by hosts that recover previously undelivered payloads.
8
+ /// @notice Hook implemented by hosts that recover previously unresolved payloads.
9
9
  abstract contract RecoverPayableHook {
10
10
  /// @notice Override to recover a witness through `handler`.
11
11
  /// @param handler Port that should attempt recovery.
@@ -31,7 +31,7 @@ abstract contract RecoverPayable is CommandBase, RecoverPayableHook {
31
31
  uint private immutable descriptor;
32
32
 
33
33
  constructor() {
34
- (, descriptor) = command("recoverPayable", Specs.Empty, Specs.Recover, Specs.Empty, 0, true, false);
34
+ (, descriptor) = command("recoverPayable", Specs.Empty, Specs.Recover, Specs.Empty, 0, Flags.Funded);
35
35
  }
36
36
 
37
37
  /// @notice Recover each recover block in the command input.
@@ -1,14 +1,15 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-only
2
2
  pragma solidity ^0.8.33;
3
3
 
4
- import {Execution, Executions, CommandBase, Lanes, Specs} from "./Base.sol";
4
+ import {Execution, Executions, CommandBase, Flags, Lanes, Specs} from "./Base.sol";
5
5
 
6
6
  using Executions for Execution;
7
7
 
8
8
  /// @notice Hook implemented by hosts that relay command contexts.
9
9
  abstract contract RelayPayableHook {
10
10
  /// @notice Override to relay a command context to `portal`.
11
- /// @param portal Destination portal identifier, often the destination host ID.
11
+ /// @param portal Destination portal implementation's host ID. Implementations
12
+ /// may validate or resolve it for their transport.
12
13
  /// @param resources Chain-specific destination resources. EVM adapters
13
14
  /// may interpret this as packed execution gas and destination value.
14
15
  /// @param account Destination command account.
@@ -32,7 +33,7 @@ abstract contract RelayPayable is CommandBase, RelayPayableHook {
32
33
  uint private immutable descriptor;
33
34
 
34
35
  constructor() {
35
- (, descriptor) = command("relayPayable", Specs.Empty, Specs.Relay, Specs.Empty, 0, true, false);
36
+ (, descriptor) = command("relayPayable", Specs.Empty, Specs.Relay, Specs.Empty, 0, Flags.Funded);
36
37
  }
37
38
 
38
39
  /// @notice Relay one RELAY input block with the command account and empty state.
@@ -58,7 +59,7 @@ abstract contract RelayBalancePayable is CommandBase, RelayPayableHook {
58
59
  uint private immutable descriptor;
59
60
 
60
61
  constructor() {
61
- (, descriptor) = command("relayBalancePayable", Specs.Balance, Specs.Relay, Specs.Empty, 0, true, false);
62
+ (, descriptor) = command("relayBalancePayable", Specs.Balance, Specs.Relay, Specs.Empty, 0, Flags.Funded);
62
63
  }
63
64
 
64
65
  /// @notice Relay one RELAY input block with the command account and current state.
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-only
2
2
  pragma solidity ^0.8.33;
3
3
 
4
- import {Execution, Executions, CommandBase, Lanes, Specs} from "./Base.sol";
4
+ import {Execution, Executions, CommandBase, Flags, Lanes, Specs} from "./Base.sol";
5
5
  import {RepayHook} from "../core/Settlement.sol";
6
6
  import {Action} from "../annotations/Action.sol";
7
7
  import {Actions} from "../utils/Actions.sol";
@@ -25,7 +25,7 @@ abstract contract Repay is CommandBase, RepayHook, Action {
25
25
 
26
26
  constructor() {
27
27
  uint id;
28
- (id, descriptor) = command("repay", Specs.Position, Specs.Empty, Specs.Balance, 0, false, false);
28
+ (id, descriptor) = command("repay", Specs.Position, Specs.Empty, Specs.Balance, 0, 0);
29
29
  action(id, Actions.Settle);
30
30
  }
31
31
 
@@ -57,7 +57,7 @@ abstract contract RepayPayable is CommandBase, RepayPayableHook, Action {
57
57
 
58
58
  constructor() {
59
59
  uint id;
60
- (id, descriptor) = command("repayPayable", Specs.Position, Specs.Empty, Specs.Balance, 0, true, false);
60
+ (id, descriptor) = command("repayPayable", Specs.Position, Specs.Empty, Specs.Balance, 0, Flags.Funded);
61
61
  action(id, Actions.Settle);
62
62
  }
63
63
 
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-only
2
2
  pragma solidity ^0.8.33;
3
3
 
4
- import {Execution, Executions, CommandBase, Lanes, Specs} from "./Base.sol";
4
+ import {Execution, Executions, CommandBase, Flags, Lanes, Specs} from "./Base.sol";
5
5
  import {SettleHook} from "../core/Settlement.sol";
6
6
  import {Action} from "../annotations/Action.sol";
7
7
  import {Actions} from "../utils/Actions.sol";
@@ -37,7 +37,7 @@ abstract contract Settle is CommandBase, SettleHook, Action {
37
37
  uint private immutable id;
38
38
 
39
39
  constructor() {
40
- (id, descriptor) = command("settle", Specs.Position, Specs.Empty, Specs.Empty, 0, false, false);
40
+ (id, descriptor) = command("settle", Specs.Position, Specs.Empty, Specs.Empty, 0, 0);
41
41
  action(id, Actions.Settle);
42
42
  }
43
43
 
@@ -73,7 +73,7 @@ abstract contract SettlePayable is CommandBase, SettlePayableHook, Action {
73
73
 
74
74
  constructor() {
75
75
  uint id;
76
- (id, descriptor) = command("settlePayable", Specs.Position, Specs.Empty, Specs.Empty, 0, true, false);
76
+ (id, descriptor) = command("settlePayable", Specs.Position, Specs.Empty, Specs.Empty, 0, Flags.Funded);
77
77
  action(id, Actions.Settle);
78
78
  }
79
79
 
@@ -25,7 +25,7 @@ abstract contract Withdraw is CommandBase, WithdrawHook, Action {
25
25
 
26
26
  constructor() {
27
27
  uint id;
28
- (id, descriptor) = command("withdraw", Specs.Balance, Specs.Empty, Specs.Empty, 0, false, false);
28
+ (id, descriptor) = command("withdraw", Specs.Balance, Specs.Empty, Specs.Empty, 0, 0);
29
29
  action(id, Actions.Withdraw);
30
30
  }
31
31
 
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-only
2
2
  pragma solidity ^0.8.33;
3
3
 
4
- import { AdminBase, Execution, Executions, Lanes, Specs } from "./Base.sol";
4
+ import { AdminBase, Execution, Executions, Flags, Lanes, Specs } from "./Base.sol";
5
5
  using Executions for Execution;
6
6
 
7
7
  /// @notice Hook implemented by hosts that allow assets.
@@ -19,7 +19,7 @@ abstract contract AllowAssets is AdminBase, AllowAssetsHook {
19
19
  uint private immutable descriptor;
20
20
 
21
21
  constructor() {
22
- (, descriptor) = command("allowAssets", Specs.Empty, Specs.Asset, Specs.Empty, 0, false, true);
22
+ (, descriptor) = command("allowAssets", Specs.Empty, Specs.Asset, Specs.Empty, 0, Flags.Admin);
23
23
  }
24
24
 
25
25
  /// @notice Allow each ASSET block in the admin input.
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-only
2
2
  pragma solidity ^0.8.33;
3
3
 
4
- import {AdminBase, Execution, Executions, Lanes, Specs} from "./Base.sol";
4
+ import {AdminBase, Execution, Executions, Flags, Lanes, Specs} from "./Base.sol";
5
5
  using Executions for Execution;
6
6
 
7
7
  /// @notice Hook implemented by hosts that configure peer asset allowances.
@@ -23,7 +23,7 @@ abstract contract Allowance is AdminBase, AllowanceHook {
23
23
  uint private immutable descriptor;
24
24
 
25
25
  constructor() {
26
- (, descriptor) = command("allowance", Specs.Empty, Specs.Allowance, Specs.Empty, 0, false, true);
26
+ (, descriptor) = command("allowance", Specs.Empty, Specs.Allowance, Specs.Empty, 0, Flags.Admin);
27
27
  }
28
28
 
29
29
  /// @notice Apply each ALLOWANCE block in the admin input.
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-only
2
2
  pragma solidity ^0.8.33;
3
3
 
4
- import {AdminBase, Execution, Executions, Lanes, Specs} from "./Base.sol";
4
+ import {AdminBase, Execution, Executions, Flags, Lanes, Specs} from "./Base.sol";
5
5
  using Executions for Execution;
6
6
 
7
7
  /// @title Annotate
@@ -12,7 +12,7 @@ abstract contract Annotate is AdminBase {
12
12
  uint private immutable descriptor;
13
13
 
14
14
  constructor() {
15
- (, descriptor) = command("annotate", Specs.Empty, Specs.Annotation, Specs.Empty, 0, false, true);
15
+ (, descriptor) = command("annotate", Specs.Empty, Specs.Annotation, Specs.Empty, 0, Flags.Admin);
16
16
  }
17
17
 
18
18
  /// @notice Publish each ANNOTATION block in the admin input.
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-only
2
2
  pragma solidity ^0.8.33;
3
3
 
4
- import { AdminBase, Execution, Executions, Lanes, Specs } from "./Base.sol";
4
+ import { AdminBase, Execution, Executions, Flags, Lanes, Specs } from "./Base.sol";
5
5
  import { GuardianAccess } from "../../core/Access.sol";
6
6
  using Executions for Execution;
7
7
 
@@ -13,7 +13,7 @@ abstract contract Appoint is GuardianAccess, AdminBase {
13
13
  uint private immutable descriptor;
14
14
 
15
15
  constructor() {
16
- (, descriptor) = command("appoint", Specs.Empty, Specs.Account, Specs.Empty, 0, false, true);
16
+ (, descriptor) = command("appoint", Specs.Empty, Specs.Account, Specs.Empty, 0, Flags.Admin);
17
17
  }
18
18
 
19
19
  /// @notice Appoint each user ACCOUNT block in the admin input as a guardian.
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-only
2
2
  pragma solidity ^0.8.33;
3
3
 
4
- import {AdminBase, Execution, Executions, Lanes, Specs} from "./Base.sol";
4
+ import {AdminBase, Execution, Executions, Flags, Lanes, Specs} from "./Base.sol";
5
5
  using Executions for Execution;
6
6
 
7
7
  /// @title Authorize
@@ -13,7 +13,7 @@ abstract contract Authorize is AdminBase {
13
13
  uint private immutable id;
14
14
 
15
15
  constructor() {
16
- (id, descriptor) = command("authorize", Specs.Empty, Specs.Node, Specs.Empty, 0, false, true);
16
+ (id, descriptor) = command("authorize", Specs.Empty, Specs.Node, Specs.Empty, 0, Flags.Admin);
17
17
  }
18
18
 
19
19
  /// @notice Return the registered AUTHORIZE command ID.