Constraint
Fluent API operators for building Constraints.
struct Constraint {
/// SCOPE_CONTEXT or SCOPE_CALLDATA.
uint8 scope;
/// BE16-encoded path to the target value.
bytes path;
/// Encoded operators. Each item = opCode(1) || data.
bytes[] operators;
}arg(uint16)
Creates a constraint targeting a top-level argument.
function arg(uint16 p0) pure returns (Constraint memory);arg(uint16, uint16)
Creates a constraint targeting a nested path of depth 2.
function arg(uint16 p0, uint16 p1) pure returns (Constraint memory);arg(uint16, uint16, uint16)
Creates a constraint targeting a nested path of depth 3.
function arg(uint16 p0, uint16 p1, uint16 p2) pure returns (Constraint memory);arg(uint16, uint16, uint16, uint16)
Creates a constraint targeting a nested path of depth 4.
function arg(uint16 p0, uint16 p1, uint16 p2, uint16 p3) pure returns (Constraint memory);arg(bytes)
Creates a constraint from a pre-encoded BE16 path.
function arg(bytes memory path) pure returns (Constraint memory);function blockNumber() pure returns (Constraint memory);Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | A context-scoped constraint for block.number. |
function blockTimestamp() pure returns (Constraint memory);Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | A context-scoped constraint for block.timestamp. |
function chainId() pure returns (Constraint memory);Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | A context-scoped constraint for block.chainid. |
function msgSender() pure returns (Constraint memory);Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | A context-scoped constraint for msg.sender. |
function msgValue() pure returns (Constraint memory);Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | A context-scoped constraint for msg.value. |
function txOrigin() pure returns (Constraint memory);Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | A context-scoped constraint for tx.origin. |
Functions
eq
Requires the value to equal value.
function eq(Constraint memory c, uint256 value) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
value | uint256 | The expected value. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
neq
Requires the value to not equal value.
function neq(Constraint memory c, uint256 value) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
value | uint256 | The excluded value. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
gt
Requires the value to be strictly greater than bound.
function gt(Constraint memory c, uint256 bound) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
bound | uint256 | The lower bound (exclusive). |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
lt
Requires the value to be strictly less than bound.
function lt(Constraint memory c, uint256 bound) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
bound | uint256 | The upper bound (exclusive). |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
gte
Requires the value to be greater than or equal to bound.
function gte(Constraint memory c, uint256 bound) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
bound | uint256 | The lower bound (inclusive). |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
lte
Requires the value to be less than or equal to bound.
function lte(Constraint memory c, uint256 bound) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
bound | uint256 | The upper bound (inclusive). |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
between
Requires the value to be within [min, max] inclusive.
function between(Constraint memory c, uint256 min, uint256 max) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
min | uint256 | The lower bound (inclusive). |
max | uint256 | The upper bound (inclusive). |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
eq
Requires the signed value to equal value.
function eq(Constraint memory c, int256 value) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
value | int256 | The expected value. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
neq
Requires the signed value to not equal value.
function neq(Constraint memory c, int256 value) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
value | int256 | The excluded value. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
gt
Requires the signed value to be strictly greater than bound.
function gt(Constraint memory c, int256 bound) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
bound | int256 | The lower bound (exclusive). |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
lt
Requires the signed value to be strictly less than bound.
function lt(Constraint memory c, int256 bound) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
bound | int256 | The upper bound (exclusive). |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
gte
Requires the signed value to be greater than or equal to bound.
function gte(Constraint memory c, int256 bound) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
bound | int256 | The lower bound (inclusive). |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
lte
Requires the signed value to be less than or equal to bound.
function lte(Constraint memory c, int256 bound) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
bound | int256 | The upper bound (inclusive). |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
between
Requires the signed value to be within [min, max] inclusive.
function between(Constraint memory c, int256 min, int256 max) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
min | int256 | The lower bound (inclusive). |
max | int256 | The upper bound (inclusive). |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
eq
Requires the value to equal value (address).
function eq(Constraint memory c, address value) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
value | address | The expected address. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
neq
Requires the value to not equal value (address).
function neq(Constraint memory c, address value) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
value | address | The excluded address. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
eq
Requires the value to equal value (bytes32).
function eq(Constraint memory c, bytes32 value) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
value | bytes32 | The expected bytes32 value. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
neq
Requires the value to not equal value (bytes32).
function neq(Constraint memory c, bytes32 value) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
value | bytes32 | The excluded bytes32 value. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
eq
Requires the value to equal value (bool).
function eq(Constraint memory c, bool value) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
value | bool | The expected boolean. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
neq
Requires the value to not equal value (bool).
function neq(Constraint memory c, bool value) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
value | bool | The excluded boolean. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
isIn
Requires the value to be in the given address set.
function isIn(Constraint memory c, address[] memory values) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
values | address[] | The allowed addresses. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
notIn
Requires the value to not be in the given address set.
function notIn(Constraint memory c, address[] memory values) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
values | address[] | The excluded addresses. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
isIn
Requires the value to be in the given bytes32 set.
function isIn(Constraint memory c, bytes32[] memory values) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
values | bytes32[] | The allowed values. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
notIn
Requires the value to not be in the given bytes32 set.
function notIn(Constraint memory c, bytes32[] memory values) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
values | bytes32[] | The excluded values. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
isIn
Requires the value to be in the given uint256 set.
function isIn(Constraint memory c, uint256[] memory values) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
values | uint256[] | The allowed values. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
notIn
Requires the value to not be in the given uint256 set.
function notIn(Constraint memory c, uint256[] memory values) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
values | uint256[] | The excluded values. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
isIn
Requires the value to be in the given int256 set.
function isIn(Constraint memory c, int256[] memory values) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
values | int256[] | The allowed values. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
notIn
Requires the value to not be in the given int256 set.
function notIn(Constraint memory c, int256[] memory values) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
values | int256[] | The excluded values. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
lengthEq
Requires the dynamic type length to equal length.
function lengthEq(Constraint memory c, uint256 length) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
length | uint256 | The expected length. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
lengthGt
Requires the dynamic type length to be strictly greater than bound.
function lengthGt(Constraint memory c, uint256 bound) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
bound | uint256 | The lower bound (exclusive). |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
lengthLt
Requires the dynamic type length to be strictly less than bound.
function lengthLt(Constraint memory c, uint256 bound) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
bound | uint256 | The upper bound (exclusive). |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
lengthGte
Requires the dynamic type length to be greater than or equal to bound.
function lengthGte(Constraint memory c, uint256 bound) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
bound | uint256 | The lower bound (inclusive). |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
lengthLte
Requires the dynamic type length to be less than or equal to bound.
function lengthLte(Constraint memory c, uint256 bound) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
bound | uint256 | The upper bound (inclusive). |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
lengthBetween
Requires the dynamic type length to be within [min, max] inclusive.
function lengthBetween(Constraint memory c, uint256 min, uint256 max) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
min | uint256 | The lower bound (inclusive). |
max | uint256 | The upper bound (inclusive). |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
bitmaskAll
Requires all bits in mask to be set.
function bitmaskAll(Constraint memory c, uint256 mask) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
mask | uint256 | The bitmask to check. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
bitmaskAny
Requires at least one bit in mask to be set.
function bitmaskAny(Constraint memory c, uint256 mask) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
mask | uint256 | The bitmask to check. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
bitmaskNone
Requires no bits in mask to be set.
function bitmaskNone(Constraint memory c, uint256 mask) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
mask | uint256 | The bitmask to check. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
addOp
Appends a raw operator with its data payload.
function addOp(Constraint memory c, uint8 op, bytes memory data) internal pure returns (Constraint memory);Parameters
| Name | Type | Description |
|---|---|---|
c | Constraint | The constraint to extend. |
op | uint8 | The operator code byte. |
data | bytes | The operator data payload. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Constraint | The updated constraint. |
Errors
InvalidRange
Thrown when the range minimum exceeds the maximum.
error InvalidRange();EmptySet
Thrown when an empty set is passed to a set membership operator.
error EmptySet();SetTooLarge
Thrown when a set exceeds the maximum element count (2047).
error SetTooLarge();