IGovernedDiamondCut
Title: IGovernedDiamondCut
Author: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80)
External interface for the governance-gated diamond-cut facet. Exposes the EIP-2535
diamondCut function at the canonical selector 0x1f931c1c so it transparently
replaces diamond-lib's owner-gated DiamondCutFacet in a governed deployment.
The single function makes type(IGovernedDiamondCut).interfaceId == 0x1f931c1c, equal to
IDiamondCut. ERC-165 support for 0x1f931c1c is therefore already registered by
DiamondLib.registerInterface(); this module does not mint a separate ERC-165 slot.
Functions
diamondCut
Add/replace/remove any number of functions and optionally execute a function with
delegatecall — but only when not emergency-stopped and the caller holds
UPGRADE_EXECUTOR_ROLE. That role is granted solely to address(this) at init AND is
pinned to administer itself, so DEFAULT_ADMIN_ROLE cannot grant it out-of-band. In the
governed recipes the only way to reach this function is a timelock-relayed passed
proposal; a co-cut facet that makes the diamond call itself for an outside caller (e.g.
AccessManager execute) reaches it without one.
function diamondCut(FacetCut[] calldata _diamondCut, address _init, bytes calldata _calldata) external payable;Parameters
| Name | Type | Description |
|---|---|---|
| _diamondCut | FacetCut[] | The facet addresses, cut actions, and function selectors. |
| _init | address | The address of the contract or facet to delegatecall after the cut (0 to skip). |
| _calldata | bytes | The calldata passed to _init. |
Events
UpgradeExecuted
Emitted after a governed cut is authorized and applied. Mirrors that the guard (emergency-stop, then UPGRADE_EXECUTOR_ROLE) passed before delegating to DiamondLib.
event UpgradeExecuted(address indexed executor, uint256 facetCutCount, address indexed init);Parameters
| Name | Type | Description |
|---|---|---|
| executor | address | The caller that passed the role gate (the timelock relaying a passed proposal). |
| facetCutCount | uint256 | The number of FacetCut entries applied. |
| init | address | The init address delegatecalled after the cut (address(0) if none). |
Errors
GovernedDiamondCutUnauthorized
Thrown when a caller without UPGRADE_EXECUTOR_ROLE attempts a cut.
error GovernedDiamondCutUnauthorized(address caller);Parameters
| Name | Type | Description |
|---|---|---|
| caller | address | The unauthorized caller. |