Signature
Description
Creates a composite policy that evaluates authorization by combining the results of two to four existing simple policies.PolicyType ABI-encodes as uint8.
UNION— authorizes an account if any child policy authorizes it (OR).INTERSECT— authorizes an account only if every child policy authorizes it (AND).
UNION short-circuits on the first authorizing child; INTERSECT short-circuits on the first non-authorizing child. Because composite children are rejected at write time, authorization never recurses beyond depth 1.
A composite policy ID can be stored in a B20 policy scope exactly like a simple policy ID. B20 calls isAuthorized generically against the opaque uint64 and requires no code changes.
Parameters
Returns
Revert conditions
Reverts are checked in this order:
Panics with
Panic(0x11) (arithmetic overflow) if the policy counter has reached its maximum value.
Events emitted
Emitted in this order on success:PolicyCreated(policyId, creator, policyType)PolicyAdminUpdated(policyId, address(0), admin)CompositePolicyUpdated(policyId, creator, childPolicyIds)
Access control
Permissionless creation, but state-changing registry calls require the feature to be active.Gas
Each child policy evaluated byisAuthorized requires a membership storage read. The worst-case cost occurs when all four children are evaluated. Place the child most likely to short-circuit first to minimize gas.
Example
Create a UNION composite policy