PolicyEnforcer
Enforces that `callData` complies with a `policy`.
Functions
enforce
Reverts when callData violates policy.
Requires a structurally validated policy blob; behavior on an unvalidated blob is undefined.
function enforce(bytes memory policy, bytes calldata callData) internal view;Parameters
| Name | Type | Description |
|---|---|---|
policy | bytes | The policy blob with embedded descriptor. |
callData | bytes | The calldata to validate. |
check
Returns true if callData complies with policy.
Requires a structurally validated policy blob; behavior on an unvalidated blob is undefined. Reverts on abort violations and integrity errors; returns false for group-local violations.
function check(bytes memory policy, bytes calldata callData) internal view returns (bool ok);Parameters
| Name | Type | Description |
|---|---|---|
policy | bytes | The policy blob with embedded descriptor. |
callData | bytes | The calldata to validate. |
Returns
| Name | Type | Description |
|---|---|---|
ok | bool | True if calldata complies with the policy. |
Errors
PolicyViolation
Thrown when policy validation fails.
error PolicyViolation(uint32 groupIndex, uint32 ruleIndex);SelectorMismatch
Thrown when the function selector does not match the policy header.
error SelectorMismatch(bytes4 expected, bytes4 actual);UnknownOperator
Thrown when an unknown operator code is encountered.
error UnknownOperator(uint8 opCode);UnknownContextProperty
Thrown when an unknown context property ID is requested.
error UnknownContextProperty(uint16 contextId);MissingSelector
Thrown when calldata is too short to contain a selector.
error MissingSelector();QuantifierLimitExceeded
Thrown when array exceeds max length for quantified iteration.
error QuantifierLimitExceeded(uint256 length, uint256 maxLength);NonCanonicalValue
Thrown when a resolved word is not the canonical encoding of its declared type.
error NonCanonicalValue(uint8 typeCode, bytes32 value);Parameters
| Name | Type | Description |
|---|---|---|
typeCode | uint8 | The declared type of the target. |
value | bytes32 | The raw 32-byte word. |