11// SPDX-License-Identifier: MIT
22pragma solidity ^ 0.8.4 ;
33
4- import {FacetCut, FacetCutAction} from "@diamond/libraries/types/DiamondTypes.sol " ;
4+ import {
5+ FacetCut,
6+ FacetCutAction,
7+ DiamondStorage,
8+ DIAMOND_STORAGE_LOCATION
9+ } from "@diamond/libraries/types/DiamondTypes.sol " ;
510import {DiamondCut} from "@diamond/libraries/logs/DiamondLogs.sol " ;
611import {
712 CannotAddFunctionToDiamondThatAlreadyExists,
@@ -18,39 +23,6 @@ import {
1823 RemoveFacetAddressMustBeZeroAddress
1924} from "@diamond/libraries/errors/DiamondErrors.sol " ;
2025
21- //*//////////////////////////////////////////////////////////////////////////
22- // DIAMOND STORAGE TYPES
23- //////////////////////////////////////////////////////////////////////////*//
24-
25- /// @dev This struct is used to store the facet address and position of the
26- /// function selector in the facetToSelectorsAndPosition.functionSelectors
27- /// array.
28- struct FacetAddressAndPosition {
29- address facetAddress;
30- uint96 functionSelectorPosition;
31- }
32-
33- /// @dev This struct is used to store the function selectors and position of
34- /// the facet address in the facetAddresses array.
35- struct FacetFunctionSelectorsAndPosition {
36- bytes4 [] functionSelectors;
37- uint256 facetAddressPosition;
38- }
39-
40- /// @notice Storage structure for managing facets and interface support in a Diamond (EIP-2535) proxy
41- /// @dev Tracks function selector mappings, facet lists, and ERC-165 interface support
42- /// @custom:storage-location erc7201:diamond.standard.diamond.storage
43- struct DiamondStorage {
44- /// @notice Maps each function selector to the facet address and selector’s position in that facet
45- mapping (bytes4 => FacetAddressAndPosition) selectorToFacetAndPosition;
46- /// @notice Maps each facet address to its function selectors and the facet’s position in the global list
47- mapping (address => FacetFunctionSelectorsAndPosition) facetToSelectorsAndPosition;
48- /// @notice Array of all facet addresses registered in the diamond
49- address [] facetAddresses;
50- /// @notice Tracks which interface IDs (ERC-165) are supported by the diamond
51- mapping (bytes4 => bool ) supportedInterfaces;
52- }
53-
5426/// @notice Internal library providing core functionality for EIP-2535 Diamond proxy management.
5527/// @author David Dada
5628/// @author Modified from Nick Mudge (https://github.com/mudgen/diamond-3-hardhat/blob/main/contracts/libraries/LibDiamond.sol)
@@ -62,10 +34,6 @@ library LibDiamond {
6234 // DIAMOND STORAGE
6335 //////////////////////////////////////////////////////////////////////////*//
6436
65- // keccak256(abi.encode(uint256(keccak256("diamond.standard.diamond.storage")) - 1)) & ~bytes32(uint256(0xff));
66- bytes32 private constant DIAMOND_STORAGE_LOCATION =
67- 0x44fefae66705534388ac21ba5f0775616856a675b8eaea9bb0b2507f06238700 ;
68-
6937 /// @dev Get the diamond storage.
7038 function diamondStorage () internal pure returns (DiamondStorage storage ds ) {
7139 bytes32 position = DIAMOND_STORAGE_LOCATION;
0 commit comments