Created
April 7, 2023 19:26
-
-
Save ssadler/cd55feba60cfb677f04eb8ca73012040 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.8.16; | |
import '../lib/diamond-3-hardhat/contracts/facets/DiamondCutFacet.sol'; | |
import '../lib/diamond-3-hardhat/contracts/facets/OwnershipFacet.sol'; | |
import '../lib/diamond-3-hardhat/contracts/facets/DiamondLoupeFacet.sol'; | |
import '../lib/diamond-3-hardhat/contracts/libraries/LibDiamond.sol'; | |
import '../lib/diamond-3-hardhat/contracts/interfaces/IERC165.sol'; | |
import '../lib/diamond-3-hardhat/contracts/interfaces/IERC173.sol'; | |
contract QueryDiamond is OwnershipFacet, DiamondCutFacet, DiamondLoupeFacet { | |
constructor() { | |
LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); | |
ds.contractOwner = msg.sender; | |
ds.supportedInterfaces[type(IERC165).interfaceId] = true; | |
ds.supportedInterfaces[type(IERC173).interfaceId] = true; | |
ds.supportedInterfaces[type(IDiamondCut).interfaceId] = true; | |
ds.supportedInterfaces[type(IDiamondLoupe).interfaceId] = true; | |
} | |
function lookupSelector(bytes4 selector) external view returns (address) { | |
LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); | |
return ds.selectorToFacetAndPosition[selector].facetAddress; | |
} | |
function setImmutableFacet(address facet) external { | |
LibDiamond.enforceIsContractOwner(); | |
LibDiamond.setImmutableFacet(facet); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment