@perfect-abstractions/compose/diamond/DiamondInspectFacet.solIt lets you inspect the diamond’s routing table and retrieve the registered facet list.
DIAMOND_STORAGE_POSITION).DIAMOND_STORAGE_POSITIONbytes32keccak256("erc8153.diamond"))Used as a return type for the facets function.
Gets the facet address that handles the given selector. If facet is not found, return address(0).
Parameters:
_functionSelectorbytes4Returns:
facetaddressaddress(0))Gets the function selectors exported by the given facet and returns them as bytes4[].
_facet does not implement exportSelectors() with the expected packing, the call will revert.Parameters:
_facetaddressexportSelectors()</b> (packed bytes4 selectors).Returns:
facetSelectorsbytes4[]facet.exportSelectors(), or an empty array if the facet is not registered.Gets the facet addresses used by the diamond.
If no facets are registered, this returns an empty array.
Returns:
allFacetsaddress[]Returns the facet address and function selectors of all facets in the diamond.
Returns:
facetsAndSelectorsFacet[]Facet structs containing each facet address and its function selectors.exportSelectors())exportSelectors() returns a packed bytes blob where each bytes4 selector is encoded into 4 consecutive bytes (a bytes.concat(sel1, sel2, ...) style packing).
DiamondInspectFacet follows that convention:
facetFunctionSelectors(facet) calls facet.exportSelectors() and unpacks the packed bytes into a bytes4[].facets() does the same for every facet discovered in the diamond.facetAddress to determine which facet handles a specific function selector.facets and facetFunctionSelectors for comprehensive diamond structure analysis.Most functions are view/pure and do not mutate state.
However, facetFunctionSelectors() and facets() perform external calls to IFacet(facet).exportSelectors().
If the provided address is not a valid IFacet implementation (or if exportSelectors() reverts / returns unexpected data), these calls can revert.