@rootzero/contracts 1.15.0 → 1.16.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 +58 -0
- package/Codec.sol +1 -1
- package/Commands.sol +1 -1
- package/Core.sol +2 -2
- package/Endpoints.sol +5 -4
- package/Events.sol +0 -1
- package/README.md +82 -28
- package/codec/Blocks.sol +79 -21
- package/codec/Buffers.sol +3 -3
- package/codec/Decoders.sol +31 -10
- package/codec/Descriptors.sol +0 -1
- package/codec/Keys.sol +2 -2
- package/codec/Readers.sol +13 -0
- package/codec/Schema.sol +5 -1
- package/codec/Specs.sol +4 -2
- package/codec/Writers.sol +19 -2
- package/commands/Base.sol +6 -15
- package/commands/Burn.sol +2 -2
- package/commands/Credit.sol +35 -3
- package/commands/Debit.sol +46 -13
- package/commands/Deposit.sol +4 -4
- package/commands/Provision.sol +4 -4
- package/commands/Recover.sol +15 -8
- package/commands/Relay.sol +37 -12
- package/commands/Settle.sol +77 -0
- package/commands/Withdraw.sol +2 -2
- package/commands/admin/AllowAssets.sol +2 -2
- package/commands/admin/Allowance.sol +2 -2
- package/commands/admin/Annotate.sol +2 -2
- package/commands/admin/Appoint.sol +2 -2
- package/commands/admin/Authorize.sol +2 -2
- package/commands/admin/DenyAssets.sol +2 -2
- package/commands/admin/Dismiss.sol +2 -2
- package/commands/admin/Execute.sol +3 -3
- package/commands/admin/Unauthorize.sol +2 -2
- package/core/Endpoint.sol +15 -13
- package/core/Pipeline.sol +6 -6
- package/core/Settlement.sol +37 -8
- package/core/Types.sol +13 -1
- package/docs/Schema.md +52 -2
- package/execution/Budget.sol +12 -4
- package/execution/Execution.sol +85 -11
- package/guards/Base.sol +2 -2
- package/package.json +1 -1
- package/ports/Base.sol +2 -2
- package/ports/Dispatch.sol +6 -6
- package/ports/{Settle.sol → Post.sol} +10 -10
- package/queries/Base.sol +2 -2
- package/utils/Actions.sol +1 -0
- package/utils/Cursors.sol +16 -30
- package/events/Position.sol +0 -22
package/utils/Cursors.sol
CHANGED
|
@@ -12,12 +12,12 @@ struct Cur {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
/// @title Cursors
|
|
15
|
-
/// @notice Packed cursor state and navigation for
|
|
15
|
+
/// @notice Packed cursor state and navigation for byte regions.
|
|
16
16
|
/// @dev Each 128-bit cursor uses the following layout:
|
|
17
17
|
/// bits 0-31 i
|
|
18
18
|
/// bits 32-63 offset
|
|
19
19
|
/// bits 64-95 len
|
|
20
|
-
/// bits 96-111
|
|
20
|
+
/// bits 96-111 count (opaque consumer metadata)
|
|
21
21
|
/// bits 112-119 flags (consumer-defined)
|
|
22
22
|
/// bits 120-127 tag
|
|
23
23
|
///
|
|
@@ -28,7 +28,7 @@ struct Cur {
|
|
|
28
28
|
/// cursor into that position while preserving the pair.
|
|
29
29
|
///
|
|
30
30
|
/// A mark is a standalone cursor value used as an immutable positional
|
|
31
|
-
/// reference. It retains the cursor's offset, length,
|
|
31
|
+
/// reference. It retains the cursor's offset, length, count, flags, and tag,
|
|
32
32
|
/// but may carry a different `i`. A mark has no intrinsic boundary or movement
|
|
33
33
|
/// semantics; callers may later use its position for comparison, validation,
|
|
34
34
|
/// seeking, or another operation. Because it has the ordinary single-cursor
|
|
@@ -41,9 +41,6 @@ library Cursors {
|
|
|
41
41
|
/// @dev A cursor position exceeds its logical length.
|
|
42
42
|
error OutOfBounds();
|
|
43
43
|
|
|
44
|
-
/// @dev Two optional group counts are both set but do not match.
|
|
45
|
-
error BadRatio();
|
|
46
|
-
|
|
47
44
|
/// @dev A cursor is not positioned at the expected offset.
|
|
48
45
|
error UnexpectedPosition();
|
|
49
46
|
|
|
@@ -58,14 +55,14 @@ library Cursors {
|
|
|
58
55
|
/// @notice Create a cursor positioned at its beginning.
|
|
59
56
|
/// @param offset Absolute source or buffer offset.
|
|
60
57
|
/// @param len Logical byte length.
|
|
61
|
-
/// @param
|
|
58
|
+
/// @param items Opaque item count associated with the region.
|
|
62
59
|
/// @param flags Consumer-defined flags.
|
|
63
60
|
/// @param tag Cursor identity tag.
|
|
64
61
|
/// @return cur Packed cursor.
|
|
65
|
-
function create(uint offset, uint len, uint
|
|
62
|
+
function create(uint offset, uint len, uint items, uint8 flags, uint8 tag) internal pure returns (uint cur) {
|
|
66
63
|
cur |= max32(offset) << 32;
|
|
67
64
|
cur |= max32(len) << 64;
|
|
68
|
-
cur |= max16(
|
|
65
|
+
cur |= max16(items) << 96;
|
|
69
66
|
cur |= uint(flags) << 112;
|
|
70
67
|
cur |= uint(tag) << 120;
|
|
71
68
|
}
|
|
@@ -113,7 +110,7 @@ library Cursors {
|
|
|
113
110
|
/// @notice Return the active cursor without its position.
|
|
114
111
|
/// @dev Ignores the upper cursor when `cur` is a pair.
|
|
115
112
|
/// @param cur Packed cursor or cursor pair.
|
|
116
|
-
/// @return The lower cursor's offset, length,
|
|
113
|
+
/// @return The lower cursor's offset, length, count, flags, and tag.
|
|
117
114
|
function frame(uint cur) internal pure returns (uint) {
|
|
118
115
|
return clear32(uint128(cur), 0);
|
|
119
116
|
}
|
|
@@ -128,15 +125,20 @@ library Cursors {
|
|
|
128
125
|
|
|
129
126
|
/// @notice Decode the consumer metadata and identity tag from the lower cursor.
|
|
130
127
|
/// @param cur Packed cursor or cursor pair.
|
|
131
|
-
/// @return
|
|
128
|
+
/// @return items Opaque item count.
|
|
132
129
|
/// @return flags Consumer-defined flags.
|
|
133
130
|
/// @return tag Cursor identity tag.
|
|
134
|
-
function meta(uint cur) internal pure returns (uint
|
|
135
|
-
|
|
131
|
+
function meta(uint cur) internal pure returns (uint items, uint8 flags, uint8 tag) {
|
|
132
|
+
items = uint16(cur >> 96);
|
|
136
133
|
flags = uint8(cur >> 112);
|
|
137
134
|
tag = uint8(cur >> 120);
|
|
138
135
|
}
|
|
139
136
|
|
|
137
|
+
/// @notice Return the opaque item count attached to the active cursor.
|
|
138
|
+
function count(uint cur) internal pure returns (uint) {
|
|
139
|
+
return uint16(cur >> 96);
|
|
140
|
+
}
|
|
141
|
+
|
|
140
142
|
/// @notice Return whether both packed cursors remain at their initial positions.
|
|
141
143
|
/// @param cur Packed cursor or cursor pair.
|
|
142
144
|
/// @return Whether both lane positions are zero.
|
|
@@ -233,7 +235,7 @@ library Cursors {
|
|
|
233
235
|
}
|
|
234
236
|
|
|
235
237
|
/// @notice Create a child cursor over `[start, end)` within the lower cursor.
|
|
236
|
-
/// @dev The child starts at position zero, has no
|
|
238
|
+
/// @dev The child starts at position zero, has no recorded count, and uses the
|
|
237
239
|
/// supplied tag. Any higher cursor is omitted.
|
|
238
240
|
/// @param cur Parent cursor or cursor pair.
|
|
239
241
|
/// @param start Child start relative to the parent base.
|
|
@@ -248,22 +250,6 @@ library Cursors {
|
|
|
248
250
|
|
|
249
251
|
// Pairing and selection
|
|
250
252
|
|
|
251
|
-
/// @notice Reconcile both packed cursor lanes with an expected group count.
|
|
252
|
-
/// @dev Zero lanes and lanes with zero groups do not constrain the result.
|
|
253
|
-
/// @param cur Packed cursor or cursor pair.
|
|
254
|
-
/// @param expected Expected group count; zero accepts the encoded count.
|
|
255
|
-
/// @return groups Reconciled effective group count.
|
|
256
|
-
function reconcile(uint cur, uint expected) internal pure returns (uint groups) {
|
|
257
|
-
uint low = uint16(cur >> 96);
|
|
258
|
-
uint high = uint16(cur >> 224);
|
|
259
|
-
if (low != 0 && high != 0 && low != high) revert BadRatio();
|
|
260
|
-
|
|
261
|
-
groups = low != 0 ? low : high;
|
|
262
|
-
if (groups != 0 && expected != 0 && groups != expected) revert BadRatio();
|
|
263
|
-
if (groups == 0) groups = expected;
|
|
264
|
-
max16(groups);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
253
|
/// @notice Combine two cursors into one packed word.
|
|
268
254
|
/// @dev Zero represents absence and acts as the identity value.
|
|
269
255
|
/// @param low Cursor placed in the lower lane.
|
package/events/Position.sol
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
-
pragma solidity ^0.8.33;
|
|
3
|
-
|
|
4
|
-
import {EventEmitter} from "./Emitter.sol";
|
|
5
|
-
|
|
6
|
-
/// @notice Emitted when the reported value of an asset-backed position changes or is observed.
|
|
7
|
-
/// A value of 0 should be interpreted as a closed position.
|
|
8
|
-
abstract contract PositionEvent is EventEmitter {
|
|
9
|
-
string private constant ABI = "event Position(bytes32 indexed account, bytes32 asset, uint value, uint32 action, uint context, uint queryId)";
|
|
10
|
-
|
|
11
|
-
/// @param account Account identifier that owns or is associated with the position.
|
|
12
|
-
/// @param asset Asset identifier for the asset class.
|
|
13
|
-
/// @param value Context-specific position value; 0 indicates a closed position.
|
|
14
|
-
/// @param action Primary operation hint from `Actions`.
|
|
15
|
-
/// @param context Reserved context value for future use.
|
|
16
|
-
/// @param queryId Query ID associated with the position lookup or reporting context.
|
|
17
|
-
event Position(bytes32 indexed account, bytes32 asset, uint value, uint32 action, uint context, uint queryId);
|
|
18
|
-
|
|
19
|
-
constructor() {
|
|
20
|
-
emit EventAbi(ABI);
|
|
21
|
-
}
|
|
22
|
-
}
|