Pre-release — The API surface may change. Unaudited.
Callcium LogoCallcium
API

PolicyManager

EIP-7201 namespaced policy storage.

Git Source

Functions

_policyStore

Returns the namespaced policy store.

Git Source

function _policyStore() private view returns (PolicyRegistry.Store storage);

_storePolicy

Stores a policy blob via SSTORE2.

Stored policies are trusted at enforcement time without semantic validation. Access to this function is the primary security boundary for enforcement integrity.

Git Source

function _storePolicy(bytes memory policy) internal returns (bytes32 policyHash, address pointer);

Parameters

NameTypeDescription
policybytesThe encoded policy blob.

Returns

NameTypeDescription
policyHashbytes32The keccak256 hash of the policy.
pointeraddressThe SSTORE2 pointer address.

_bindPolicy

Binds a stored policy to a target under the policy's own selector.

Binding a policy activates it for enforcement on the given target. The selector is derived from the stored policy, so a policy binds only under the selector it declares. Restrict access as tightly as policy storage itself.

Git Source

function _bindPolicy(address target, bytes32 policyHash) internal;

Parameters

NameTypeDescription
targetaddressThe contract address to bind the policy to.
policyHashbytes32The policy hash (must already be stored).

_unbindPolicy

Unbinds a policy from a (target, selector) pair.

Unbinding deactivates enforcement for the pair, reopening the guarded selector. Reverts when the pair has no binding. Restrict access as tightly as policy storage itself.

Git Source

function _unbindPolicy(address target, bytes4 selector) internal;

Parameters

NameTypeDescription
targetaddressThe contract address.
selectorbytes4The function selector.

_storeAndBindPolicy

Stores a policy and binds it to targets in one call.

Stored policies are trusted at enforcement time without semantic validation, and binding activates them immediately. Access to this function is the primary security boundary.

Git Source

function _storeAndBindPolicy(address[] calldata targets, bytes memory policy)
    internal
    returns (bytes32 policyHash);

Parameters

NameTypeDescription
targetsaddress[]Target addresses to bind to. Use address(0) for default.
policybytesThe encoded policy blob.

Returns

NameTypeDescription
policyHashbytes32The policy hash.

_storeAndBindPolicy

Stores a policy and binds it to a single target.

Stored policies are trusted at enforcement time without semantic validation, and binding activates them immediately. Access to this function is the primary security boundary.

Git Source

function _storeAndBindPolicy(address target, bytes memory policy) internal returns (bytes32 policyHash);

Parameters

NameTypeDescription
targetaddressThe target address. Use address(0) for default.
policybytesThe encoded policy blob.

Returns

NameTypeDescription
policyHashbytes32The policy hash.

_resolvePolicy

Resolves and loads the policy for a (target, selector) pair.

Git Source

function _resolvePolicy(address target, bytes4 selector) internal view returns (bytes memory);

Parameters

NameTypeDescription
targetaddressThe contract address.
selectorbytes4The function selector.

Returns

NameTypeDescription
<none>bytesThe policy blob, or empty bytes if none bound.

_policyHashFor

Returns the policy hash for a (target, selector) pair.

Git Source

function _policyHashFor(address target, bytes4 selector) internal view returns (bytes32);

Parameters

NameTypeDescription
targetaddressThe contract address.
selectorbytes4The function selector.

Returns

NameTypeDescription
<none>bytes32The policy hash, or bytes32(0) if none bound.

_loadPolicy

Loads a policy blob by its hash.

Git Source

function _loadPolicy(bytes32 policyHash) internal view returns (bytes memory);

Parameters

NameTypeDescription
policyHashbytes32The policy hash.

Returns

NameTypeDescription
<none>bytesThe policy blob, or empty bytes if not found.

_policyExists

Checks if a policy exists in storage.

Git Source

function _policyExists(bytes32 policyHash) internal view returns (bool);

Parameters

NameTypeDescription
policyHashbytes32The policy hash to check.

Returns

NameTypeDescription
<none>boolTrue if the policy exists.

_policyPointerOf

Returns the SSTORE2 pointer for a policy hash.

Git Source

function _policyPointerOf(bytes32 policyHash) internal view returns (address);

Parameters

NameTypeDescription
policyHashbytes32The policy hash.

Returns

NameTypeDescription
<none>addressThe pointer address, or address(0) if not found.

Events

PolicyStored

Emitted when a policy blob is stored.

Emitted on every store call, including deduplicated stores of an existing blob.

Git Source

event PolicyStored(bytes32 indexed policyHash, address pointer);

Parameters

NameTypeDescription
policyHashbytes32The keccak256 hash of the policy blob.
pointeraddressThe SSTORE2 pointer address.

PolicyBindingChanged

Emitted when the policy binding for a (target, selector) pair changes.

Git Source

event PolicyBindingChanged(
    address indexed target, bytes4 indexed selector, bytes32 previousHash, bytes32 indexed newHash
);

Parameters

NameTypeDescription
targetaddressThe contract address the binding applies to.
selectorbytes4The bind selector.
previousHashbytes32The previously bound policy hash, or zero when none was bound.
newHashbytes32The newly bound policy hash, or zero when the binding was removed.

On this page