Pre-release — The API surface may change. Unaudited.
Callcium LogoCallcium
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.
    bytes path;
    /// Encoded operators. Each item = opCode(1) || data.
    bytes[] operators;
    /// Most negative operand of an equality, comparison or set operator; zero if none.
    int256 leastNegativeOperand;
    /// Greatest operand of an equality, comparison or set operator; zero if none.
    uint256 greatestOperand;
    /// Compiled hint block as carried on the wire; empty when the constraint has no encoding.
    bytes hint;
}

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 c, uint256 value) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, uint256 value) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, uint256 bound) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, uint256 bound) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, uint256 bound) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, uint256 bound) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, uint256 min, uint256 max) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, int256 value) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, int256 value) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, int256 bound) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, int256 bound) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, int256 bound) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, int256 bound) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, int256 min, int256 max) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, address value) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, address value) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, bytes32 value) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, bytes32 value) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, bool value) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, bool value) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, address[] memory values) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, address[] memory values) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, bytes32[] memory values) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, bytes32[] memory values) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, uint256[] memory values) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, uint256[] memory values) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, int256[] memory values) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, int256[] memory values) internal pure returns (Constraint memory);

Parameters

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

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

lengthEq

Requires the dynamic type length to equal length.

Git Source

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

Parameters

NameTypeDescription
cConstraintThe constraint to extend.
lengthuint256The expected length.

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

lengthGt

Requires the dynamic type length to be strictly greater than bound.

Git Source

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

Parameters

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

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

lengthLt

Requires the dynamic type length to be strictly less than bound.

Git Source

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

Parameters

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

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

lengthGte

Requires the dynamic type length to be greater than or equal to bound.

Git Source

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

Parameters

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

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

lengthLte

Requires the dynamic type length to be less than or equal to bound.

Git Source

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

Parameters

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

Returns

NameTypeDescription
<none>ConstraintThe updated constraint.

lengthBetween

Requires the dynamic type length to be within [min, max] inclusive.

Git Source

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

Parameters

NameTypeDescription
cConstraintThe 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 c, uint256 mask) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, uint256 mask) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, uint256 mask) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, uint16 contextPropertyId) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, uint16 contextPropertyId) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, uint16 contextPropertyId) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, uint16 contextPropertyId) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, uint16 contextPropertyId) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, uint16 contextPropertyId) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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 c, uint8 op, bytes memory data) internal pure returns (Constraint memory);

Parameters

NameTypeDescription
cConstraintThe 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();

SetTooLarge

Thrown when a set exceeds the maximum element count.

Git Source

error SetTooLarge();

UnknownContextProperty

Thrown when an unknown context property ID is referenced.

Git Source

error UnknownContextProperty(uint16 contextPropertyId);

On this page