@rootzero/contracts 0.6.2 → 0.6.3

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 (2) hide show
  1. package/core/Operation.sol +13 -0
  2. package/package.json +1 -1
@@ -42,6 +42,19 @@ abstract contract OperationBase is AccessControl {
42
42
  (, count, quotient) = cur.primeRun(group);
43
43
  }
44
44
 
45
+ /// @notice Open a cursor, prime it, and assert that its normalized quotient matches `expectedQuotient`.
46
+ /// Equivalent to `open(source)` followed by `primeRun(group)` and `checkQuotient(quotient, expectedQuotient)`.
47
+ /// Reverts with `Cursors.BadRatio` when the quotient does not match.
48
+ /// @param source Calldata slice to parse.
49
+ /// @param group Expected block group size (e.g. 1 for single, 2 for paired).
50
+ /// @param expectedQuotient Required number of groups in the first run.
51
+ /// @return cur Cursor with `bound` set to the end of the first run.
52
+ function cursor(bytes calldata source, uint group, uint expectedQuotient) internal pure returns (Cur memory cur) {
53
+ cur = Cursors.open(source);
54
+ (, , uint quotient) = cur.primeRun(group);
55
+ if (quotient != expectedQuotient) revert Cursors.BadRatio();
56
+ }
57
+
45
58
  /// @notice Assert that two normalized group quotients are equal.
46
59
  /// Reverts with `Cursors.BadRatio` when `lq != rq`.
47
60
  /// @param lq Left-hand quotient.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rootzero/contracts",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "description": "Solidity contracts and protocol building blocks for rootzero hosts and commands.",
5
5
  "private": false,
6
6
  "license": "GPL-3.0-only",