Skip to main content

Owner Two Step Data Facet

Manages pending owner state for two-step ownership transfers

Key Features
  • Exposes external pendingOwner function for read-only access to ownership state.
  • Provides internal getStorage function for facets to access shared storage.
  • Includes exportSelectors for diamond discovery and management.
  • Operates within the Compose diamond standard, utilizing shared diamond storage.

Overview

This facet provides access to the pending owner state within a diamond. It exposes functions to retrieve the pending owner address and access internal storage structures. Developers integrate this facet to manage ownership transitions in a two-step process, ensuring clarity and security.

Storage

PendingOwnerStorage

Definition
struct PendingOwnerStorage {
address pendingOwner;
}

State Variables

PropertyTypeDescription
STORAGE_POSITIONbytes32Diamond storage slot position for this module (Value: keccak256("erc173.owner.pending"))

Functions

pendingOwner

Get the address of the pending owner

function pendingOwner() external view returns (address);

Returns:

PropertyTypeDescription
-addressThe address of the pending owner.

exportSelectors

Exports the function selectors of the OwnerTwoStepDataFacet This function is use as a selector discovery mechanism for diamonds

function exportSelectors() external pure returns (bytes memory);

Returns:

PropertyTypeDescription
-bytesselectors The exported function selectors of the OwnerTwoStepDataFacet

Best Practices

Best Practice
  • Initialize the pendingOwner to the zero address before the first transfer.
  • Ensure other facets that manage ownership (e.g., transfer or renounce) properly interact with the state managed by this facet.
  • When upgrading, verify that the STORAGE_POSITION for PendingOwnerStorage remains consistent or is handled correctly during the upgrade process.

Security Considerations

Security

The pendingOwner function is a view function and poses no direct reentrancy risk. The exportSelectors function is pure and also poses no risk. The getStorage function uses inline assembly to access storage; ensure the STORAGE_POSITION defined for PendingOwnerStorage is correctly managed and does not conflict with other storage slots within the diamond.

Was this helpful?
Last updated:

Newsletter

Get notified about releases, feature announcements, and technical deep-dives on building smart contracts with Compose.

No spam. Unsubscribe anytime.