Owner Two Step Transfer Facet
Manages ownership transfer via a two-step process
- Exposes external functions for diamond routing.
- Manages ownership transfer through a two-step verification process.
- Operates on shared diamond storage using inline assembly.
- Provides a mechanism to export facet selectors.
Overview
This facet implements a two-step ownership transfer mechanism for a diamond. It exposes external functions for initiating and accepting ownership changes, operating on shared diamond storage. Developers integrate this facet to manage diamond ownership securely and upgradeably.
Storage
OwnerStorage
PendingOwnerStorage
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
transferOwnership
Set the address of the new owner of the contract
Parameters:
| Property | Type | Description |
|---|---|---|
_newOwner | address | The address of the new owner of the contract |
acceptOwnership
exportSelectors
Exports the function selectors of the OwnerTwoStepTransferFacet This function is use as a selector discovery mechanism for diamonds
Returns:
| Property | Type | Description |
|---|---|---|
- | bytes | selectors The exported function selectors of the OwnerTwoStepTransferFacet |
Events
Errors
Best Practices
- Initialize the owner address during diamond deployment.
- Ensure the
transferOwnershipfunction is called by the current owner. - Verify that the
acceptOwnershipfunction is called by the pending owner address.
Security Considerations
The transferOwnership function is restricted to the current owner via internal access control checks within the facet. The acceptOwnership function requires the caller to be the pending owner. No reentrancy guards are explicitly present; follow standard Solidity reentrancy best practices for external calls within the diamond.