Callcium
API

Constraint

Fluent API operators for building constraints.

Git Source

Git Source

struct Constraint {
    /// SCOPE_CONTEXT or SCOPE_CALLDATA.
    uint8 scope;
    /// BE16-encoded path to the target value. A `Path.ALL` or `Path.ANY` step stands for each element of an array.
    bytes path;
    /// Encoded operators. Each item = opCode(1) || data.
    bytes[] operators;
    /// Most negative operand of an equality, comparison or set operator, or zero if none.
    int256 leastNegativeOperand;
    /// Greatest operand of an equality, comparison or set operator, or zero if none.
    uint256 greatestOperand;
}

Git Source

function msgSender() pure returns (Constraint memory);

Returns

NameTypeDescription
<none>ConstraintA context-scoped constraint for msg.sender.

Git Source

function msgValue() pure returns (Constraint memory);

Returns

NameTypeDescription
<none>ConstraintA context-scoped constraint for msg.value.

Git Source

function blockTimestamp() pure returns (Constraint memory);

Returns

NameTypeDescription
<none>ConstraintA context-scoped constraint for block.timestamp.

Git Source

function blockNumber() pure returns (Constraint memory);

Returns

NameTypeDescription
<none>ConstraintA context-scoped constraint for block.number.

Git Source

function chainId() pure returns (Constraint memory);

Returns

NameTypeDescription
<none>ConstraintA context-scoped constraint for block.chainid.

Git Source

function txOrigin() pure returns (Constraint memory);

Returns

NameTypeDescription
<none>ConstraintA context-scoped constraint for tx.origin.

Git Source

function baseFee() pure returns (Constraint memory);

Returns

NameTypeDescription
<none>ConstraintA context-scoped constraint for block.basefee.

Git Source

function gasPrice() pure returns (Constraint memory);

Returns

NameTypeDescription
<none>ConstraintA context-scoped constraint for tx.gasprice.

arg(uint16)

Creates a constraint targeting a top-level argument.

Git Source

function arg(uint16 p0) pure returns (Constraint memory);

Parameters

NameTypeDescription
p0uint16The argument index.

Returns

NameTypeDescription
<none>ConstraintA calldata-scoped constraint at the given path.

arg(uint16, uint16)

Creates a constraint targeting a nested path of depth 2.

Git Source

function arg(uint16 p0, uint16 p1) pure returns (Constraint memory);

Parameters

NameTypeDescription
p0uint16The argument index.
p1uint16The second path step.

Returns

NameTypeDescription
<none>ConstraintA calldata-scoped constraint at the given path.

arg(uint16, uint16, uint16)

Creates a constraint targeting a nested path of depth 3.

Git Source

function arg(uint16 p0, uint16 p1, uint16 p2) pure returns (Constraint memory);

Parameters

NameTypeDescription
p0uint16The argument index.
p1uint16The second path step.
p2uint16The third path step.

Returns

NameTypeDescription
<none>ConstraintA calldata-scoped constraint at the given path.

arg(uint16, uint16, uint16, uint16)

Creates a constraint targeting a nested path of depth 4.

Git Source

function arg(uint16 p0, uint16 p1, uint16 p2, uint16 p3) pure returns (Constraint memory);

Parameters

NameTypeDescription
p0uint16The argument index.
p1uint16The second path step.
p2uint16The third path step.
p3uint16The fourth path step.

Returns

NameTypeDescription
<none>ConstraintA calldata-scoped constraint at the given path.

arg(bytes)

Creates a constraint from a pre-encoded BE16 path.

Git Source

function arg(bytes memory path) pure returns (Constraint memory);

Parameters

NameTypeDescription
pathbytesThe pre-encoded BE16 path bytes.

Returns

NameTypeDescription
<none>ConstraintA calldata-scoped constraint at the given path.

Functions

eq

Requires the value to equal value.

Git Source

function eq(Constraint memory constraint, uint256 value) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
valueuint256The expected value.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

neq

Requires the value to not equal value.

Git Source

function neq(Constraint memory constraint, uint256 value) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
valueuint256The excluded value.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

gt

Requires the value to be strictly greater than bound.

Git Source

function gt(Constraint memory constraint, uint256 bound) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
bounduint256The lower bound (exclusive).

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

lt

Requires the value to be strictly less than bound.

Git Source

function lt(Constraint memory constraint, uint256 bound) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
bounduint256The upper bound (exclusive).

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

gte

Requires the value to be greater than or equal to bound.

Git Source

function gte(Constraint memory constraint, uint256 bound) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
bounduint256The lower bound (inclusive).

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

lte

Requires the value to be less than or equal to bound.

Git Source

function lte(Constraint memory constraint, uint256 bound) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
bounduint256The upper bound (inclusive).

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

between

Requires the value to be within [min, max] inclusive.

Git Source

function between(Constraint memory constraint, uint256 min, uint256 max) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
minuint256The lower bound (inclusive).
maxuint256The upper bound (inclusive).

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

eq

Requires the signed value to equal value.

Git Source

function eq(Constraint memory constraint, int256 value) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
valueint256The expected value.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

neq

Requires the signed value to not equal value.

Git Source

function neq(Constraint memory constraint, int256 value) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
valueint256The excluded value.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

gt

Requires the signed value to be strictly greater than bound.

Git Source

function gt(Constraint memory constraint, int256 bound) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
boundint256The lower bound (exclusive).

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

lt

Requires the signed value to be strictly less than bound.

Git Source

function lt(Constraint memory constraint, int256 bound) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
boundint256The upper bound (exclusive).

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

gte

Requires the signed value to be greater than or equal to bound.

Git Source

function gte(Constraint memory constraint, int256 bound) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
boundint256The lower bound (inclusive).

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

lte

Requires the signed value to be less than or equal to bound.

Git Source

function lte(Constraint memory constraint, int256 bound) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
boundint256The upper bound (inclusive).

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

between

Requires the signed value to be within [min, max] inclusive.

Git Source

function between(Constraint memory constraint, int256 min, int256 max) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
minint256The lower bound (inclusive).
maxint256The upper bound (inclusive).

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

eq

Requires the value to equal value (address).

Git Source

function eq(Constraint memory constraint, address value) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
valueaddressThe expected address.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

neq

Requires the value to not equal value (address).

Git Source

function neq(Constraint memory constraint, address value) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
valueaddressThe excluded address.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

eq

Requires the value to equal value (bytes32).

Git Source

function eq(Constraint memory constraint, bytes32 value) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
valuebytes32The expected bytes32 value.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

neq

Requires the value to not equal value (bytes32).

Git Source

function neq(Constraint memory constraint, bytes32 value) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
valuebytes32The excluded bytes32 value.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

eq

Requires the value to equal value (bool).

Git Source

function eq(Constraint memory constraint, bool value) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
valueboolThe expected boolean.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

neq

Requires the value to not equal value (bool).

Git Source

function neq(Constraint memory constraint, bool value) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
valueboolThe excluded boolean.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

isIn

Requires the value to be in the given address set.

Git Source

function isIn(Constraint memory constraint, address[] memory values) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
valuesaddress[]The allowed addresses.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

notIn

Requires the value to not be in the given address set.

Git Source

function notIn(Constraint memory constraint, address[] memory values) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
valuesaddress[]The excluded addresses.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

isIn

Requires the value to be in the given bytes32 set.

Git Source

function isIn(Constraint memory constraint, bytes32[] memory values) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
valuesbytes32[]The allowed values.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

notIn

Requires the value to not be in the given bytes32 set.

Git Source

function notIn(Constraint memory constraint, bytes32[] memory values) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
valuesbytes32[]The excluded values.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

isIn

Requires the value to be in the given uint256 set.

Git Source

function isIn(Constraint memory constraint, uint256[] memory values) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
valuesuint256[]The allowed values.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

notIn

Requires the value to not be in the given uint256 set.

Git Source

function notIn(Constraint memory constraint, uint256[] memory values) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
valuesuint256[]The excluded values.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

isIn

Requires the value to be in the given int256 set.

Git Source

function isIn(Constraint memory constraint, int256[] memory values) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
valuesint256[]The allowed values.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

notIn

Requires the value to not be in the given int256 set.

Git Source

function notIn(Constraint memory constraint, int256[] memory values) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
valuesint256[]The excluded values.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

lengthEq

Requires the length of the bytes, string or dynamic array to equal length.

Git Source

function lengthEq(Constraint memory constraint, uint256 length) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
lengthuint256The expected length.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

lengthGt

Requires the length of the bytes, string or dynamic array to be strictly greater than bound.

Git Source

function lengthGt(Constraint memory constraint, uint256 bound) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
bounduint256The lower bound (exclusive).

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

lengthLt

Requires the length of the bytes, string or dynamic array to be strictly less than bound.

Git Source

function lengthLt(Constraint memory constraint, uint256 bound) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
bounduint256The upper bound (exclusive).

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

lengthGte

Requires the length of the bytes, string or dynamic array to be greater than or equal to bound.

Git Source

function lengthGte(Constraint memory constraint, uint256 bound) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
bounduint256The lower bound (inclusive).

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

lengthLte

Requires the length of the bytes, string or dynamic array to be less than or equal to bound.

Git Source

function lengthLte(Constraint memory constraint, uint256 bound) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
bounduint256The upper bound (inclusive).

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

lengthBetween

Requires the length of the bytes, string or dynamic array to be within [min, max] inclusive.

Git Source

function lengthBetween(
    Constraint memory constraint,
    uint256 min,
    uint256 max
)
    internal
    pure
    returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
minuint256The lower bound (inclusive).
maxuint256The upper bound (inclusive).

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

bitmaskAll

Requires all bits in mask to be set.

Git Source

function bitmaskAll(Constraint memory constraint, uint256 mask) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
maskuint256The bitmask to check.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

bitmaskAny

Requires at least one bit in mask to be set.

Git Source

function bitmaskAny(Constraint memory constraint, uint256 mask) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
maskuint256The bitmask to check.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

bitmaskNone

Requires no bits in mask to be set.

Git Source

function bitmaskNone(Constraint memory constraint, uint256 mask) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
maskuint256The bitmask to check.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

eqCtx

Requires the value to equal the context property contextPropertyId.

Git Source

function eqCtx(Constraint memory constraint, uint16 contextPropertyId) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
contextPropertyIduint16The context property ID.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

neqCtx

Requires the value to not equal the context property contextPropertyId.

Git Source

function neqCtx(Constraint memory constraint, uint16 contextPropertyId) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
contextPropertyIduint16The context property ID.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

gtCtx

Requires the value to be strictly greater than the context property contextPropertyId.

Git Source

function gtCtx(Constraint memory constraint, uint16 contextPropertyId) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
contextPropertyIduint16The context property ID.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

ltCtx

Requires the value to be strictly less than the context property contextPropertyId.

Git Source

function ltCtx(Constraint memory constraint, uint16 contextPropertyId) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
contextPropertyIduint16The context property ID.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

gteCtx

Requires the value to be greater than or equal to the context property contextPropertyId.

Git Source

function gteCtx(Constraint memory constraint, uint16 contextPropertyId) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
contextPropertyIduint16The context property ID.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

lteCtx

Requires the value to be less than or equal to the context property contextPropertyId.

Git Source

function lteCtx(Constraint memory constraint, uint16 contextPropertyId) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
contextPropertyIduint16The context property ID.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

addOp

Appends a raw operator with its data payload.

Git Source

function addOp(Constraint memory constraint, uint8 op, bytes memory data)
    internal
    pure
    returns (Constraint memory);

Parameters

NameTypeDescription
constraintConstraintThe constraint to extend.
opuint8The operator code byte.
databytesThe operator data payload.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

Errors

InvalidRange

Thrown when the range minimum exceeds the maximum.

Git Source

error InvalidRange();

EmptySet

Thrown when an empty set is passed to a set membership operator.

Git Source

error EmptySet();

UnknownContextProperty

Thrown when an unknown context property ID is referenced.

Git Source

error UnknownContextProperty(uint16 contextPropertyId);

On this page