LibDiamond

Git Source


Author: Nick Mudge nick@perfectabstractions.com (https://twitter.com/mudgen) EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 /*****************************************************************************

State Variables

DIAMOND_STORAGE_POSITION

bytes32 constant DIAMOND_STORAGE_POSITION = keccak256("diamond.standard.diamond.storage");

Functions

diamondStorage

function diamondStorage() internal pure returns (DiamondStorage storage ds);

setContractOwner

function setContractOwner(address _newOwner) internal;

contractOwner

function contractOwner() internal view returns (address contractOwner_);

enforceIsContractOwner

function enforceIsContractOwner() internal view;

diamondCut

function diamondCut(IDiamondCut.FacetCut[] memory _diamondCut, address _init, bytes memory _calldata) internal;

addFunctions

function addFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal;

replaceFunctions

function replaceFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal;

removeFunctions

function removeFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal;

addFacet

function addFacet(DiamondStorage storage ds, address _facetAddress) internal;

addFunction

function addFunction(DiamondStorage storage ds, bytes4 _selector, uint96 _selectorPosition, address _facetAddress)
    internal;

removeFunction

function removeFunction(DiamondStorage storage ds, address _facetAddress, bytes4 _selector) internal;

initializeDiamondCut

function initializeDiamondCut(address _init, bytes memory _calldata) internal;

enforceHasContractCode

function enforceHasContractCode(address _contract, string memory _errorMessage) internal view;

Events

OwnershipTransferred

event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

DiamondCut

event DiamondCut(IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata);

Structs

FacetAddressAndPosition

struct FacetAddressAndPosition {
    address facetAddress;
    uint96 functionSelectorPosition;
}

FacetFunctionSelectors

struct FacetFunctionSelectors {
    bytes4[] functionSelectors;
    uint256 facetAddressPosition;
}

DiamondStorage

struct DiamondStorage {
    mapping(bytes4 => FacetAddressAndPosition) selectorToFacetAndPosition;
    mapping(address => FacetFunctionSelectors) facetFunctionSelectors;
    address[] facetAddresses;
    mapping(bytes4 => bool) supportedInterfaces;
    address contractOwner;
}