@rootzero/contracts 0.9.2 → 0.9.4

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/Commands.sol +4 -3
  2. package/Core.sol +3 -0
  3. package/Cursors.sol +1 -1
  4. package/README.md +18 -24
  5. package/blocks/Cursors.sol +332 -335
  6. package/blocks/Keys.sol +38 -57
  7. package/blocks/Schema.sol +55 -114
  8. package/blocks/Writers.sol +361 -255
  9. package/commands/Base.sol +6 -48
  10. package/commands/Burn.sol +4 -4
  11. package/commands/Credit.sol +5 -4
  12. package/commands/Debit.sol +6 -5
  13. package/commands/Deposit.sol +17 -14
  14. package/commands/Provision.sol +17 -14
  15. package/commands/Transfer.sol +4 -4
  16. package/commands/Withdraw.sol +5 -4
  17. package/commands/admin/AllowAssets.sol +3 -3
  18. package/commands/admin/Allowance.sol +3 -3
  19. package/commands/admin/Authorize.sol +3 -3
  20. package/commands/admin/DenyAssets.sol +3 -3
  21. package/commands/admin/Destroy.sol +1 -1
  22. package/commands/admin/Execute.sol +9 -8
  23. package/commands/admin/Init.sol +1 -1
  24. package/commands/admin/Unauthorize.sol +3 -3
  25. package/core/Access.sol +11 -0
  26. package/core/Context.sol +11 -13
  27. package/core/Payable.sol +57 -0
  28. package/core/Pipeline.sol +55 -0
  29. package/docs/Schema.md +194 -0
  30. package/events/Admin.sol +5 -1
  31. package/events/Command.sol +6 -2
  32. package/events/Listing.sol +3 -4
  33. package/events/Peer.sol +5 -3
  34. package/events/Query.sol +5 -2
  35. package/package.json +2 -2
  36. package/peer/AllowAssets.sol +3 -3
  37. package/peer/Allowance.sol +3 -3
  38. package/peer/BalancePull.sol +43 -0
  39. package/peer/DenyAssets.sol +3 -3
  40. package/peer/Pipe.sol +38 -0
  41. package/peer/Settle.sol +3 -3
  42. package/queries/Assets.sol +7 -6
  43. package/queries/Balances.sol +5 -4
  44. package/queries/Positions.sol +14 -14
  45. package/utils/Value.sol +8 -14
  46. package/commands/Pipe.sol +0 -67
  47. package/docs/GETTING_STARTED.md +0 -294
  48. package/peer/AssetPull.sol +0 -43
package/blocks/Keys.sol CHANGED
@@ -1,88 +1,69 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-only
2
2
  pragma solidity ^0.8.33;
3
3
 
4
- import {Forms} from "./Schema.sol";
5
-
6
4
  /// @title Keys
7
5
  /// @notice Block type selectors for the rootzero block stream protocol.
8
- /// Each key is the first 4 bytes of the keccak256 hash of its schema string,
9
- /// matching the ABI-selector convention used in `Schemas`.
6
+ /// Each key is the first 4 bytes of the keccak256 hash of its block name.
10
7
  library Keys {
11
8
  /// @dev Empty / unset key.
12
9
  bytes4 constant Empty = bytes4(0);
13
10
  /// @dev Input amount - (bytes32 asset, bytes32 meta, uint amount)
14
- bytes4 constant Amount = bytes4(keccak256("amount(bytes32 asset, bytes32 meta, uint amount)"));
11
+ bytes4 constant Amount = bytes4(keccak256("#amount"));
15
12
  /// @dev Ledger balance - (bytes32 asset, bytes32 meta, uint amount)
16
- bytes4 constant Balance = bytes4(keccak256("balance(bytes32 asset, bytes32 meta, uint amount)"));
13
+ bytes4 constant Balance = bytes4(keccak256("#balance"));
17
14
  /// @dev Host-scoped request amount - (uint host, bytes32 asset, bytes32 meta, uint amount)
18
- bytes4 constant Allocation = bytes4(keccak256("allocation(uint host, bytes32 asset, bytes32 meta, uint amount)"));
15
+ bytes4 constant Allocation = bytes4(keccak256("#allocation"));
19
16
  /// @dev Host-scoped allowance cap - (uint host, bytes32 asset, bytes32 meta, uint amount)
20
- bytes4 constant Allowance = bytes4(keccak256("allowance(uint host, bytes32 asset, bytes32 meta, uint amount)"));
17
+ bytes4 constant Allowance = bytes4(keccak256("#allowance"));
21
18
  /// @dev Cross-host custody state - (uint host, bytes32 asset, bytes32 meta, uint amount)
22
- bytes4 constant Custody = bytes4(keccak256("custody(uint host, bytes32 asset, bytes32 meta, uint amount)"));
19
+ bytes4 constant Custody = bytes4(keccak256("#custody"));
23
20
  /// @dev Minimum acceptable output - (bytes32 asset, bytes32 meta, uint amount)
24
- bytes4 constant Minimum = bytes4(keccak256("minimum(bytes32 asset, bytes32 meta, uint amount)"));
21
+ bytes4 constant Minimum = bytes4(keccak256("#minimum"));
25
22
  /// @dev Maximum allowable spend - (bytes32 asset, bytes32 meta, uint amount)
26
- bytes4 constant Maximum = bytes4(keccak256("maximum(bytes32 asset, bytes32 meta, uint amount)"));
27
- /// @dev Signed min/max bounds - (int min, int max)
28
- bytes4 constant Bounds = bytes4(keccak256("bounds(int min, int max)"));
23
+ bytes4 constant Maximum = bytes4(keccak256("#maximum"));
29
24
  /// @dev Fee amount - (uint amount)
30
- bytes4 constant Fee = bytes4(keccak256("fee(uint amount)"));
31
- /// @dev Hard stop / iteration sentinel - ()
32
- bytes4 constant Break = bytes4(keccak256("break()"));
33
- /// @dev Bundle wrapper - (bytes data); payload is an embedded block stream
34
- bytes4 constant Bundle = bytes4(keccak256("bundle(bytes data)"));
35
- /// @dev List wrapper - (bytes data); payload is an embedded repeated block stream
36
- bytes4 constant List = bytes4(keccak256("list(bytes data)"));
37
- /// @dev Frame wrapper - (bytes data); payload is schema-defined concatenated member payloads
38
- bytes4 constant Frame = bytes4(keccak256("frame(bytes data)"));
39
- /// @dev Extensible routing field - (bytes data); layout is command-defined
40
- bytes4 constant Route = bytes4(keccak256("route(bytes data)"));
41
- /// @dev Extensible list item field - (bytes data); layout is implementation-defined
42
- bytes4 constant Item = bytes4(keccak256("item(bytes data)"));
43
- /// @dev EVM-encoded payload field - (bytes data); layout follows standard ABI tuple encoding
44
- bytes4 constant Evm = bytes4(keccak256("evm(bytes data)"));
45
- /// @dev Extensible query field - (bytes data); layout is query-defined, key is always `Keys.Query`
46
- bytes4 constant Query = bytes4(keccak256("query(bytes data)"));
47
- /// @dev Extensible response field - (bytes data); layout is response-defined, key is always `Keys.Response`
48
- bytes4 constant Response = bytes4(keccak256("response(bytes data)"));
49
- /// @dev Plain scalar amount - (uint amount)
50
- bytes4 constant Quantity = bytes4(keccak256("quantity(uint amount)"));
51
- /// @dev Ratio or rate value - (uint value)
52
- bytes4 constant Rate = bytes4(keccak256("rate(uint value)"));
25
+ bytes4 constant Fee = bytes4(keccak256("#fee"));
26
+ /// @dev List wrapper; payload is an embedded repeated block stream
27
+ bytes4 constant List = bytes4(keccak256("#list"));
28
+ /// @dev Extensible data field; layout is schema-defined
29
+ bytes4 constant Data = bytes4(keccak256("#data"));
30
+ /// @dev EVM-encoded payload field; layout follows standard ABI tuple encoding
31
+ bytes4 constant Evm = bytes4(keccak256("#evm"));
32
+ /// @dev Reserved raw bytes child block.
33
+ bytes4 constant Bytes = bytes4(keccak256("#bytes"));
53
34
  /// @dev Account identifier - (bytes32 account)
54
- bytes4 constant Account = bytes4(keccak256("account(bytes32 account)"));
35
+ bytes4 constant Account = bytes4(keccak256("#account"));
55
36
  /// @dev Transfer payout request - (bytes32 account, bytes32 asset, bytes32 meta, uint amount)
56
- bytes4 constant Payout = bytes4(keccak256("payout(bytes32 account, bytes32 asset, bytes32 meta, uint amount)"));
37
+ bytes4 constant Payout = bytes4(keccak256("#payout"));
57
38
  /// @dev Transfer record passed through the pipeline - (bytes32 from, bytes32 to, bytes32 asset, bytes32 meta, uint amount)
58
- bytes4 constant Transaction = bytes4(
59
- keccak256("transaction(bytes32 from, bytes32 to, bytes32 asset, bytes32 meta, uint amount)")
60
- );
61
- /// @dev Sub-command invocation - (uint target, uint value, bytes request)
62
- bytes4 constant Step = bytes4(keccak256("step(uint target, uint value, bytes request)"));
63
- /// @dev Raw external call - (uint target, uint value, bytes data)
64
- bytes4 constant Call = bytes4(keccak256("call(uint target, uint value, bytes data)"));
65
- /// @dev Authentication proof - (uint cid, uint deadline, bytes proof); must appear last in its segment
66
- bytes4 constant Auth = bytes4(keccak256("auth(uint cid, uint deadline, bytes proof)"));
39
+ bytes4 constant Transaction = bytes4(keccak256("#transaction"));
40
+ /// @dev Sub-command invocation - (uint target, uint value, #bytes as request)
41
+ bytes4 constant Step = bytes4(keccak256("#step"));
42
+ /// @dev Raw external call - (uint target, uint value, #bytes as payload)
43
+ bytes4 constant Call = bytes4(keccak256("#call"));
44
+ /// @dev Command context transport - (bytes32 account, #bytes as state, #bytes as request)
45
+ bytes4 constant Context = bytes4(keccak256("#context"));
46
+ /// @dev Authentication proof - (uint cid, uint deadline, #bytes as proof); must appear last in its segment
47
+ bytes4 constant Auth = bytes4(keccak256("#auth"));
67
48
  /// @dev Asset descriptor without amount - (bytes32 asset, bytes32 meta)
68
- bytes4 constant Asset = bytes4(keccak256("asset(bytes32 asset, bytes32 meta)"));
49
+ bytes4 constant Asset = bytes4(keccak256("#asset"));
69
50
  /// @dev Node identifier - (uint id)
70
- bytes4 constant Node = bytes4(keccak256("node(uint id)"));
51
+ bytes4 constant Node = bytes4(keccak256("#node"));
71
52
  /// @dev Relayer bounty - (uint amount, bytes32 relayer)
72
- bytes4 constant Bounty = bytes4(keccak256("bounty(uint amount, bytes32 relayer)"));
53
+ bytes4 constant Bounty = bytes4(keccak256("#bounty"));
73
54
 
74
55
  /// @dev Structural status form - (bool ok)
75
- bytes4 constant Status = bytes4(keccak256(bytes(Forms.Status)));
56
+ bytes4 constant Status = bytes4(keccak256("#status"));
76
57
  /// @dev Structural asset amount form - (bytes32 asset, bytes32 meta, uint amount)
77
- bytes4 constant AssetAmount = bytes4(keccak256(bytes(Forms.AssetAmount)));
58
+ bytes4 constant AssetAmount = bytes4(keccak256("#assetAmount"));
78
59
  /// @dev Structural account asset form - (bytes32 account, bytes32 asset, bytes32 meta)
79
- bytes4 constant AccountAsset = bytes4(keccak256(bytes(Forms.AccountAsset)));
60
+ bytes4 constant AccountAsset = bytes4(keccak256("#accountAsset"));
80
61
  /// @dev Structural account amount form - (bytes32 account, bytes32 asset, bytes32 meta, uint amount)
81
- bytes4 constant AccountAmount = bytes4(keccak256(bytes(Forms.AccountAmount)));
62
+ bytes4 constant AccountAmount = bytes4(keccak256("#accountAmount"));
82
63
  /// @dev Structural host amount form - (uint host, bytes32 asset, bytes32 meta, uint amount)
83
- bytes4 constant HostAmount = bytes4(keccak256(bytes(Forms.HostAmount)));
64
+ bytes4 constant HostAmount = bytes4(keccak256("#hostAmount"));
84
65
  /// @dev Structural host account asset form - (uint host, bytes32 account, bytes32 asset, bytes32 meta)
85
- bytes4 constant HostAccountAsset = bytes4(keccak256(bytes(Forms.HostAccountAsset)));
66
+ bytes4 constant HostAccountAsset = bytes4(keccak256("#hostAccountAsset"));
86
67
  /// @dev Structural host account amount form - (uint host, bytes32 account, bytes32 asset, bytes32 meta, uint amount)
87
- bytes4 constant HostAccountAmount = bytes4(keccak256(bytes(Forms.HostAccountAmount)));
68
+ bytes4 constant HostAccountAmount = bytes4(keccak256("#hostAccountAmount"));
88
69
  }
package/blocks/Schema.sol CHANGED
@@ -3,81 +3,26 @@ pragma solidity ^0.8.33;
3
3
 
4
4
  // Block stream:
5
5
  // - encoding is [bytes4 key][bytes4 payloadLen][payload]
6
- // - `payloadLen` covers only the block payload
6
+ // - `payloadLen` is big-endian and covers only the block payload
7
7
  // - payload layout is block-specific
8
8
  //
9
- // Extensible payloads:
10
- // - self payload may be [head][dynamic tail]
11
- // - head layout is implied by the block key
12
- // - one dynamic field may consume the rest of self payload without its own length prefix
13
- // - reserved extensible forms keep one fixed key while their declared field list remains descriptive schema metadata
14
- // - chain-specific payload blocks are encoded using the local chain/runtime's native conventions
15
- // - on EVM-family chains, `evm(<fields...>)` payloads use standard ABI tuple encoding via `abi.encode(...)`
16
- // and can be decoded with `abi.decode`
17
- // - chain-specific payload blocks are request-only escape hatches and should never be used for pipeline state
18
- // - prefer ordinary protocol blocks whenever possible; chain-specific payload blocks should be a last resort
19
- //
20
- // Schema DSL:
21
- // - `;` separates top-level sibling blocks
22
- // - `&` bundles adjacent blocks into one bundle block
23
- // - `+` frames adjacent fixed-layout block payloads into one frame block
24
- // - `&` and `+` follow the same grouping and normalization rules, except they emit different wrapper blocks
25
- // - `name = a & b` introduces a named bundle item with a local key derived from the raw input string
26
- // - `name = a + b` introduces a named frame item with a local key derived from the raw input string
27
- // - `bundle = a & b` introduces an anonymous child bundle item
28
- // - `frame = a + b` introduces an anonymous child frame item, like `bundle = ...` and `list = ...`
29
- // - postfix `[]` marks a repeated list in the simple suffix form, e.g. `asset(...)[]`
30
- // - `name[] = a & b` introduces a named list with a local key derived from the raw input string
31
- // - `list = a & b` introduces an anonymous list whose repeated item is the bundled shape `a & b`
32
- // - empty entries are ignored, but structural markers are preserved after normalization
33
- // - grouping parentheses are not part of the DSL; parentheses are only used in block field lists
34
- // - `+` binds tighter than `&`, so `a & b + c` normalizes as `a & (b + c)`
35
- // - if `&` appears, the result remains a bundle even when only one non-empty child remains
36
- // - if `+` appears, the result remains a frame even when only one non-empty child remains
37
- // - after ignoring empty entries, repeated adjacent separators collapse while preserving bundle/frame/list shape
38
- // - bundled blocks preserve member order, so `a & b` differs from `b & a`
39
- // - a bundle block's self payload is an embedded normal block stream of its bundled members
40
- // - bundled members keep their ordinary block encoding, so dynamic blocks are allowed inside bundles
41
- // - a list block's self payload is an embedded normal block stream representing the repeated items
42
- // - a frame block's self payload is the concatenated payload fields of its framed members
43
- // - framed members do not keep their ordinary block headers; the emitted schema defines the frame layout
44
- // - framed members must be fixed-layout block forms because frame payloads contain no child lengths or block keys
45
- // - frames may be bundled like ordinary block items, but bundles/lists cannot be framed
46
- // - top-level blocks of the same type should be grouped together
47
- // - primary / driving blocks should appear before auxiliary blocks
48
- // - `route(<fields...>)`, `item(<fields...>)`, `evm(<fields...>)`, `query(<fields...>)`,
49
- // and `response(<fields...>)` are reserved extensible schema forms whose keys are always
50
- // `Keys.Route`, `Keys.Item`, `Keys.Evm`, `Keys.Query`, and `Keys.Response` respectively
51
- // - these extensible forms work like dynamic `bytes` blocks: they may carry arbitrary
52
- // payload bytes while keeping one fixed key per semantic block type
53
- // - `evm(<fields...>)` differs from bundle/list payloads: its bytes are not an embedded block stream
54
- // - `evm(uint foo, uint bar)` is a schema declaration only; on-chain the block key is still `Keys.Evm`
55
- // and the payload can be decoded from `bytes data` using the local runtime's native decoder
56
- // - on EVM, `evm(bool flag)` occupies one full 32-byte ABI word, exactly like `abi.encode(flag)`
57
- // - anonymous `&` compiles to a `Keys.Bundle` block whose self payload is the bundled member block stream
58
- // - anonymous `[]` compiles to a `Keys.List` block whose self payload is the repeated item block stream
59
- // - anonymous `+` compiles to a `Keys.Frame` block whose self payload is the framed member payload fields
60
- // - named lists, bundles, and frames use bytes4(keccak256(bytes(rawSchemaInput))) as their block key
61
- // - named structural keys are custom/local identifiers, not global protocol keys; formatting is part of identity
62
- // - `asset(...)[]` means a list whose repeated item is the block `asset(...)`
63
- // - `steps[] = asset(...) & account(...)` means a named list whose repeated item is the bundle
64
- // `asset(...) & account(...)`
65
- // - `payment = amount(...) + fee(...)` means a named frame whose payload is
66
- // `asset | meta | amount | fee` and whose on-chain key is derived from that raw schema string
67
- // - `amount(...) & fee(...) + account(...)` means `amount(...) & (fee(...) + account(...))`;
68
- // it compiles to a bundle containing one amount block followed by one frame block
69
- // - `bundle = account(...) & evm(bytes routeData)` means an anonymous child bundle with those bundled members
70
- // - `frame = amount(...) + fee(...)` means an anonymous child frame with those framed payload fields
71
- // - `list = asset(...) & account(...)` means an anonymous child list whose repeated item is the
72
- // bundle `asset(...) & account(...)`
73
- // - `"amount(...) &"` and `"& amount(...)"` both normalize to a bundle containing one `amount(...)` child
74
- // - `"amount(...) +"` and `"+ amount(...)"` both normalize to a frame containing one `amount(...)` payload
75
- // - canonical blocks are `amount(...)` for request amounts, `balance(...)` for state balances,
76
- // `allocation(...)` for host-scoped provision requests, `allowance(...)` for host-scoped caps,
77
- // `custody(...)` for host-scoped state,
78
- // `minimum(...)` for result floors, `maximum(...)` for spend ceilings, and `quantity(...)`
79
- // for plain scalar amounts
80
- // - `auth(uint cid, uint deadline, bytes proof)` is a proof-separator block and must be emitted last
9
+ // Schema:
10
+ // - blocks are written as `#name { fields }`
11
+ // - a block without braces has no payload, e.g. `#unit`
12
+ // - commas separate siblings at every level
13
+ // - braces define parent-child boundaries
14
+ // - top-level item 0 is the prime item; later top-level items are globals
15
+ // - prime items may repeat at top level for batching
16
+ // - `maybe #x { ... }` marks an optional block item
17
+ // - `many #x { ... }` emits one generic list block containing repeated `#x` items
18
+ // - fixed fields are packed in declaration order
19
+ // - blocks have fixed fields followed by a dynamic child-block tail
20
+ // - child block tails are embedded directly, without an extra stream wrapper
21
+ // - `#bytes` is a reserved child block that stores raw bytes and has no body
22
+ // - generic `#data` uses the stable key derived from `#data`
23
+ // - generic lists use the stable key derived from `#list`
24
+ // - keys are derived from block names, e.g. bytes4(keccak256("#amount"))
25
+ // - see `docs/Schema.md` for the full working spec
81
26
  //
82
27
  // Pipeline state:
83
28
  // - `balance(...)` and `custody(...)` are live, linear state in the active command pipeline
@@ -91,56 +36,52 @@ pragma solidity ^0.8.33;
91
36
  //
92
37
  // Signed blocks:
93
38
  // - an authenticated input segment ends with one trailing AUTH block
94
- // - auth is typically grouped with the signed payload in one bundle, with AUTH as the final member
95
39
  // - only the final AUTH is treated specially; earlier AUTH blocks remain ordinary signed bytes
96
40
  // - the signed slice runs from the segment start through the AUTH head, excluding only AUTH proof bytes
97
41
  // - `cid` binds the signature to one command; `deadline` acts as expiry and nonce
98
42
  // - current helpers assume proof layout `[bytes20 signer][bytes65 sig]`
99
43
 
100
44
  /// @title Schemas
101
- /// @notice Human-readable ABI-signature string constants for each block type.
102
- /// These strings are the canonical source from which `Keys` constants are derived
103
- /// and are used when emitting schema descriptors in command events.
45
+ /// @notice Human-readable schema string constants for each block type.
46
+ /// These strings describe payload layout for discovery events and docs; block
47
+ /// keys are derived only from block names.
104
48
  library Schemas {
105
- string constant Node = "node(uint id)";
106
- string constant Account = "account(bytes32 account)";
107
- string constant Asset = "asset(bytes32 asset, bytes32 meta)";
108
- string constant Balance = "balance(bytes32 asset, bytes32 meta, uint amount)";
109
- string constant Amount = "amount(bytes32 asset, bytes32 meta, uint amount)";
110
- string constant Minimum = "minimum(bytes32 asset, bytes32 meta, uint amount)";
111
- string constant Maximum = "maximum(bytes32 asset, bytes32 meta, uint amount)";
112
- string constant Custody = "custody(uint host, bytes32 asset, bytes32 meta, uint amount)";
113
- string constant Payout = "payout(bytes32 account, bytes32 asset, bytes32 meta, uint amount)";
114
- string constant Allocation = "allocation(uint host, bytes32 asset, bytes32 meta, uint amount)";
115
- string constant Allowance = "allowance(uint host, bytes32 asset, bytes32 meta, uint amount)";
116
- string constant Transaction = "transaction(bytes32 from, bytes32 to, bytes32 asset, bytes32 meta, uint amount)";
117
- string constant Call = "call(uint target, uint value, bytes data)";
118
- string constant Step = "step(uint target, uint value, bytes request)";
119
- string constant Bounty = "bounty(uint amount, bytes32 relayer)";
120
- string constant Quantity = "quantity(uint amount)";
121
- string constant Fee = "fee(uint amount)";
122
- string constant Rate = "rate(uint value)";
123
- string constant Bounds = "bounds(int min, int max)";
124
- string constant Auth = "auth(uint cid, uint deadline, bytes proof)";
125
- string constant Route = "route(bytes data)";
126
- string constant Item = "item(bytes data)";
127
- string constant Evm = "evm(bytes data)";
128
- string constant Query = "query(bytes data)";
129
- string constant Response = "response(bytes data)";
130
- string constant Break = "break()";
49
+ string constant Unit = "#unit";
50
+ string constant Node = "#node { uint id }";
51
+ string constant Account = "#account { bytes32 account }";
52
+ string constant Asset = "#asset { bytes32 asset, bytes32 meta }";
53
+ string constant Balance = "#balance { bytes32 asset, bytes32 meta, uint amount }";
54
+ string constant Amount = "#amount { bytes32 asset, bytes32 meta, uint amount }";
55
+ string constant Minimum = "#minimum { bytes32 asset, bytes32 meta, uint amount }";
56
+ string constant Maximum = "#maximum { bytes32 asset, bytes32 meta, uint amount }";
57
+ string constant Custody = "#custody { uint host, bytes32 asset, bytes32 meta, uint amount }";
58
+ string constant Payout = "#payout { bytes32 account, bytes32 asset, bytes32 meta, uint amount }";
59
+ string constant Allocation = "#allocation { uint host, bytes32 asset, bytes32 meta, uint amount }";
60
+ string constant Allowance = "#allowance { uint host, bytes32 asset, bytes32 meta, uint amount }";
61
+ string constant Transaction = "#transaction { bytes32 from, bytes32 to, bytes32 asset, bytes32 meta, uint amount }";
62
+ string constant Call = "#call { uint target, uint value, #bytes as payload }";
63
+ string constant Step = "#step { uint target, uint value, #bytes as request }";
64
+ string constant Context = "#context { bytes32 account, uint value, #bytes as state, #bytes as request }";
65
+ string constant Bounty = "#bounty { uint amount, bytes32 relayer }";
66
+ string constant Fee = "#fee { uint amount }";
67
+ string constant Auth = "#auth { uint cid, uint deadline, #bytes as proof }";
68
+ string constant Bytes = "#bytes";
69
+ string constant Data = "#data";
70
+ string constant List = "#list";
71
+ string constant Evm = "#evm";
131
72
  }
132
73
 
133
74
  /// @title Forms
134
75
  /// @notice Reusable structural block schemas for core tuple shapes.
135
76
  /// These describe payload form without assigning command or query semantics.
136
77
  library Forms {
137
- string constant Status = "status(bool ok)";
138
- string constant AssetAmount = "assetAmount(bytes32 asset, bytes32 meta, uint amount)";
139
- string constant AccountAsset = "accountAsset(bytes32 account, bytes32 asset, bytes32 meta)";
140
- string constant AccountAmount = "accountAmount(bytes32 account, bytes32 asset, bytes32 meta, uint amount)";
141
- string constant HostAmount = "hostAmount(uint host, bytes32 asset, bytes32 meta, uint amount)";
142
- string constant HostAccountAsset = "hostAccountAsset(uint host, bytes32 account, bytes32 asset, bytes32 meta)";
143
- string constant HostAccountAmount = "hostAccountAmount(uint host, bytes32 account, bytes32 asset, bytes32 meta, uint amount)";
78
+ string constant Status = "#status { bool ok }";
79
+ string constant AssetAmount = "#assetAmount { bytes32 asset, bytes32 meta, uint amount }";
80
+ string constant AccountAsset = "#accountAsset { bytes32 account, bytes32 asset, bytes32 meta }";
81
+ string constant AccountAmount = "#accountAmount { bytes32 account, bytes32 asset, bytes32 meta, uint amount }";
82
+ string constant HostAmount = "#hostAmount { uint host, bytes32 asset, bytes32 meta, uint amount }";
83
+ string constant HostAccountAsset = "#hostAccountAsset { uint host, bytes32 account, bytes32 asset, bytes32 meta }";
84
+ string constant HostAccountAmount = "#hostAccountAmount { uint host, bytes32 account, bytes32 asset, bytes32 meta, uint amount }";
144
85
  }
145
86
 
146
87
  /// @title Sizes
@@ -162,14 +103,14 @@ library Sizes {
162
103
  uint constant B160 = Header + 5 * Word;
163
104
  /// @dev AUTH proof segment only: 20-byte signer + 65-byte signature = 85 bytes
164
105
  uint constant Proof = 85;
165
- /// @dev AUTH block: 8 header + 32 cid + 32 deadline + 85 proof = 157 bytes
166
- uint constant Auth = B64 + Proof;
106
+ /// @dev AUTH block: 8 header + 32 cid + 32 deadline + nested BYTES block with 85-byte proof = 165 bytes
107
+ uint constant Auth = B64 + Header + Proof;
108
+ /// @dev STATUS block: 8 header + 1 bool byte = 9 bytes
109
+ uint constant Status = Header + 1;
167
110
  /// @dev AMOUNT block: 8 header + 32 asset + 32 meta + 32 amount = 104 bytes
168
111
  uint constant Amount = B96;
169
112
  /// @dev BALANCE block: 8 header + 32 asset + 32 meta + 32 amount = 104 bytes
170
113
  uint constant Balance = B96;
171
- /// @dev BOUNDS block: 8 header + 32 min + 32 max = 72 bytes
172
- uint constant Bounds = B64;
173
114
  /// @dev FEE block: 8 header + 32 amount = 40 bytes
174
115
  uint constant Fee = B32;
175
116
  /// @dev BOUNTY block: 8 header + 32 amount + 32 relayer = 72 bytes