PolicyRegistry
The PolicyRegistry is an informational on-chain registry of reveal policy contracts. It provides a discovery mechanism for wallets, UIs, and indexers to find available policies. Registration is not required for a policy to function -- any contract implementing IRevealPolicy can be used with commitWithPolicy regardless of registry status.
Deployed address: 0x2DC1641d5A32D6788264690D42710edC843Cb1db
Functions
register
function register(address policy) external
Registers a policy contract in the registry.
Parameters:
| Name | Type | Description |
|---|---|---|
policy | address | The address of the policy contract to register. |
Behavior:
- Verifies the address contains code (is a contract).
- Adds the policy to the internal registry.
- Records the registrant (
msg.sender) and registration timestamp.
Reverts if:
policyis the zero address.policyhas no code (is an EOA).policyis already registered.
isRegistered
function isRegistered(address policy) external view returns (bool)
Checks whether a policy address is registered.
Parameters:
| Name | Type | Description |
|---|---|---|
policy | address | The address to check. |
Returns:
| Name | Type | Description |
|---|---|---|
| (unnamed) | bool | true if the policy is registered, false otherwise. |
getPolicy
function getPolicy(address policy) external view returns (
address registrant,
uint256 registeredAt,
bool active
)
Returns metadata about a registered policy.
Parameters:
| Name | Type | Description |
|---|---|---|
policy | address | The policy address to query. |
Returns:
| Name | Type | Description |
|---|---|---|
registrant | address | The address that registered the policy. |
registeredAt | uint256 | Block timestamp when the policy was registered. |
active | bool | Whether the policy is currently active in the registry. |
getPolicies
function getPolicies() external view returns (address[] memory)
Returns an array of all registered policy addresses.
Returns:
| Name | Type | Description |
|---|---|---|
| (unnamed) | address[] | Array of all registered policy contract addresses. |
Storage
struct PolicyInfo {
address registrant;
uint256 registeredAt;
bool active;
}
mapping(address => PolicyInfo) public policies;
address[] public policyList;
Usage Examples
Registering a Custom Policy
// After deploying a custom policy contract
MyCustomPolicy policy = new MyCustomPolicy();
// Register it for discoverability
PolicyRegistry(registryAddress).register(address(policy));
Querying Available Policies
// Get all registered policies
address[] memory allPolicies = PolicyRegistry(registryAddress).getPolicies();
// Check a specific policy
bool registered = PolicyRegistry(registryAddress).isRegistered(policyAddress);
// Get policy details
(address registrant, uint256 registeredAt, bool active) =
PolicyRegistry(registryAddress).getPolicy(policyAddress);
Front-End Integration
const registry = new ethers.Contract(registryAddress, registryABI, provider);
// List all available policies for a UI dropdown
const policies = await registry.getPolicies();
for (const addr of policies) {
const info = await registry.getPolicy(addr);
console.log(`Policy: ${addr}, Registered by: ${info.registrant}, Active: ${info.active}`);
}
Notes
- The registry is informational only. It does not enforce any behavior in the
CommitRevealVault. A policy does not need to be registered to be used withcommitWithPolicy. - Registration is permissionless. Anyone can register a policy contract. The
registrantfield provides attribution but does not imply endorsement. - The built-in Specter policies (
TimelockExpiry,DestinationRestriction,ThresholdWitness) are pre-registered at deployment time.