Callcium
API

PolicyBuilder

Fluent API for drafting policies from constraints.

Git Source

Functions

createRaw

Creates a selectorless draft from a comma-separated type list.

Git Source

function createRaw(string memory typesCsv) internal pure returns (PolicyDraft memory draft);

Parameters

NameTypeDescription
typesCsvstringThe comma-separated ABI types (for example "uint256,address").

Returns

NameTypeDescription
draftPolicyDraftThe initialized draft.

create

Creates a draft from a function signature.

Git Source

function create(string memory signature) internal pure returns (PolicyDraft memory draft);

Parameters

NameTypeDescription
signaturestringThe function signature.

Returns

NameTypeDescription
draftPolicyDraftThe initialized draft.

add

Adds a constraint to the active group with validation. A path through Path.ALL or Path.ANY adds its operators to the body of the group's loop over that array with that quantifier.

Git Source

function add(PolicyDraft memory draft, Constraint memory constraint) internal pure returns (PolicyDraft memory);

Parameters

NameTypeDescription
draftPolicyDraftThe draft state.
constraintConstraintThe constraint to add.

Returns

NameTypeDescription
<none>PolicyDraftThe updated draft state with the constraint's rules appended.

or

Starts a new constraint group (OR semantics between groups).

Git Source

function or(PolicyDraft memory draft) internal pure returns (PolicyDraft memory);

Parameters

NameTypeDescription
draftPolicyDraftThe draft state.

Returns

NameTypeDescription
<none>PolicyDraftThe updated draft state with a new empty group.

build

Builds the final policy blob with strict validation.

Reverts with the storage validation error of a blob that fails it, and with every validation issue when there is any.

Git Source

function build(PolicyDraft memory draft) internal pure returns (bytes memory policy);

Parameters

NameTypeDescription
draftPolicyDraftThe draft state to build from.

Returns

NameTypeDescription
policybytesThe encoded policy blob.

buildUnsafe

Builds the final policy blob without validation.

Skips validation. The resulting policy can be invalid.

Git Source

function buildUnsafe(PolicyDraft memory draft) internal pure returns (bytes memory);

Parameters

NameTypeDescription
draftPolicyDraftThe draft state to build from.

Returns

NameTypeDescription
<none>bytesThe encoded policy blob.

validate

Validates the policy that a draft contains.

Git Source

function validate(PolicyDraft memory draft) internal pure returns (Issue[] memory);

Parameters

NameTypeDescription
draftPolicyDraftThe draft state to validate.

Returns

NameTypeDescription
<none>Issue[]Every issue validation reports on the encoded policy.

Errors

NoConstraintOperators

Thrown when the constraint has no operators.

Git Source

error NoConstraintOperators();

InvalidContextPath

Thrown when a context-scope path does not have exactly one step.

Git Source

error InvalidContextPath(uint256 depth);

Parameters

NameTypeDescription
depthuint256The path depth.

UnknownPathStep

Thrown when a path step lies in the reserved marker range and is neither Path.ALL nor Path.ANY.

Git Source

error UnknownPathStep(bytes path, uint256 stepIndex);

Parameters

NameTypeDescription
pathbytesThe encoded be16 path.
stepIndexuint256The step index of the marker.

InvalidNestedLoop

Thrown when a path contains more than one quantifier step.

Git Source

error InvalidNestedLoop(bytes path, uint256 stepIndex);

Parameters

NameTypeDescription
pathbytesThe encoded be16 path.
stepIndexuint256The step index of the second quantifier.

SetTooLarge

Thrown when a set contains more members than the data length can represent at its operand type's width.

Git Source

error SetTooLarge();

EmptyGroup

Thrown when a group is empty.

Git Source

error EmptyGroup(uint256 groupIndex);

Parameters

NameTypeDescription
groupIndexuint256The index of the empty group.

On this page