DiamondInspectFacet
Inspects diamond facets and storage mappings
- Provides external view functions for diamond inspection.
- Accesses diamond storage via inline assembly for direct state retrieval.
- Returns facet addresses and function-to-facet mappings.
- Follows EIP-2535 diamond standard conventions.
Overview
This facet provides read-only access to the diamond's facet mappings and storage structure. It exposes functions to retrieve facet addresses by function selector and to list all function-to-facet pairings. Developers integrate this facet to inspect diamond functionality and understand its on-chain configuration.
Storage
FacetAndPosition
DiamondStorage
FunctionFacetPair
State Variables
| Property | Type | Description |
|---|---|---|
DIAMOND_STORAGE_POSITION | bytes32 | Diamond storage slot position for this module (Value: keccak256("erc8109.diamond")) |
Functions
facetAddress
Gets the facet address that handles the given selector. If facet is not found return address(0).
Parameters:
| Property | Type | Description |
|---|---|---|
_functionSelector | bytes4 | The function selector. |
Returns:
| Property | Type | Description |
|---|---|---|
facet | address | The facet address. |
functionFacetPairs
Returns an array of all function selectors and their corresponding facet addresses. Iterates through the diamond's stored selectors and pairs each with its facet.
Returns:
| Property | Type | Description |
|---|---|---|
pairs | FunctionFacetPair[] | An array of FunctionFacetPair structs, each containing a selector and its facet address. |
Best Practices
- Ensure this facet is added to the diamond during initialization.
- Call
facetAddressto determine which facet handles a specific function selector. - Use
functionFacetPairsto get a comprehensive view of the diamond's function dispatch.
Security Considerations
This facet contains only view functions and does not modify state. Standard Solidity security practices apply. Input validation is handled by the underlying diamond proxy and facet dispatch mechanism.