Owner Two Step Renounce Module
Two-step ownership renouncement with ERC-173 logic
- Implements a two-step ownership renouncement pattern.
- Uses internal functions for direct interaction with diamond storage.
- Emits an
OwnershipTransferredevent upon successful renouncement. - Compatible with ERC-2535 diamonds and the shared storage pattern.
This module provides internal functions for use in your custom facets. Import it to access shared logic and storage.
Overview
This module implements a two-step ownership renouncement process, adhering to ERC-173 semantics. It provides internal functions to manage ownership transitions, ensuring that functions restricted to the owner are disabled only after a confirmed two-step process. This approach enhances security by preventing accidental or malicious immediate ownership loss.
Storage
OwnerStorage
storage-location: erc8042:erc173.owner
PendingOwnerStorage
storage-location: erc8042:erc173.owner.pending
State Variables
| Property | Type | Description |
|---|---|---|
OWNER_STORAGE_POSITION | bytes32 | Diamond storage slot position for this module (Value: keccak256("erc173.owner")) |
PENDING_OWNER_STORAGE_POSITION | bytes32 | Diamond storage slot position for this module (Value: keccak256("erc173.owner.pending")) |
Functions
getOwnerStorage
Returns a pointer to the ERC-173 storage struct. Uses inline assembly to access the storage slot defined by OWNER_STORAGE_POSITION.
Returns:
| Property | Type | Description |
|---|---|---|
s | OwnerStorage | The OwnerStorage struct in storage. |
getPendingOwnerStorage
Returns a pointer to the PendingOwner storage struct. Uses inline assembly to access the storage slot defined by PENDING_OWNER_STORAGE_POSITION.
Returns:
| Property | Type | Description |
|---|---|---|
s | PendingOwnerStorage | The PendingOwnerStorage struct in storage. |
renounceOwnership
Renounce ownership of the contract. Sets the owner to address(0) and clears any pending owner, disabling all functions restricted to the owner.
Events
Errors
Best Practices
- Ensure the caller has the appropriate permissions before invoking state-changing functions.
- Verify that the
OWNER_STORAGE_POSITIONandPENDING_OWNER_STORAGE_POSITIONare correctly configured in the diamond's storage layout. - Handle the
OwnerUnauthorizedAccounterror if the caller is not the authorized account for ownership operations.
Integration Notes
This module interacts with diamond storage at the slots defined by OWNER_STORAGE_POSITION and PENDING_OWNER_STORAGE_POSITION. The renounceOwnership function directly modifies the owner field within the OwnerStorage struct located at OWNER_STORAGE_POSITION, setting it to address(0) and clearing any pending owner. These changes are immediately visible to all facets that access the same storage slots.