PolicyEnforcer
Evaluation of ABI-encoded data against policy blobs.
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 calldata violates the policy.
error PolicyViolation(uint32 groupIndex, uint32 ruleIndex);SelectorMismatch
Thrown when the function selector does not match the policy header.
error SelectorMismatch(bytes4 expected, bytes4 actual);MissingSelector
Thrown when calldata is too short to contain a selector.
error MissingSelector();UnsupportedMinor
Thrown when the policy's minor version is above the highest one this release implements.
error UnsupportedMinor(uint8 minor);Parameters
| Name | Type | Description |
|---|---|---|
minor | uint8 | The declared minor version. |
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. |