-
Notifications
You must be signed in to change notification settings - Fork 1
/
DiamondCutFacet.sol
48 lines (42 loc) · 1.78 KB
/
DiamondCutFacet.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// SPDX-License-Identifier: MIT
pragma solidity 0.8.14;
/******************************************************************************\
* Author: Nick Mudge <nick@perfectabstractions.com> (https://twitter.com/mudgen)
* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535
/******************************************************************************/
import {IDiamondCut} from "../interfaces/IDiamondCut.sol";
import {LibDiamond} from "../libraries/LibDiamond.sol";
// Remember to add the loupe functions from DiamondLoupeFacet to the diamond.
// The loupe functions are required by the EIP2535 Diamonds standard
contract DiamondCutFacet is IDiamondCut {
/// @notice Add/replace/remove any number of functions and optionally execute
/// a function with delegatecall
/// @param _diamondCut Contains the facet addresses and function selectors
/// @param _init The address of the contract or facet to execute _calldata
/// @param _calldata A function call, including function selector and arguments
/// _calldata is executed with delegatecall on _init
function diamondCut(
FacetCut[] calldata _diamondCut,
address _init,
bytes calldata _calldata
) external override {
LibDiamond.enforceIsContractOwner();
LibDiamond.diamondCut(_diamondCut, _init, _calldata);
}
function proposeDiamondCut(
FacetCut[] calldata _diamondCut,
address _init,
bytes calldata _calldata
) external {
LibDiamond.enforceIsContractOwner();
LibDiamond.proposeDiamondCut(_diamondCut, _init, _calldata);
}
function rescindDiamondCut(
FacetCut[] calldata _diamondCut,
address _init,
bytes calldata _calldata
) external {
LibDiamond.enforceIsContractOwner();
LibDiamond.rescindDiamondCut(_diamondCut, _init, _calldata);
}
}