hardhat-deploy 0.9.25 → 0.9.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # hardhat-deploy
2
2
 
3
+ ## 0.9.26
4
+
5
+ ### Patch Changes
6
+
7
+ - adding onlyOwner for Diamond
8
+
3
9
  ## 0.9.25
4
10
 
5
11
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hardhat-deploy",
3
- "version": "0.9.25",
3
+ "version": "0.9.26",
4
4
  "description": "Hardhat Plugin For Replicable Deployments And Tests",
5
5
  "repository": "github:wighawag/hardhat-deploy",
6
6
  "author": "wighawag",
@@ -0,0 +1,12 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.7.0;
3
+
4
+ import "./libraries/LibDiamond.sol";
5
+
6
+ contract UsingDiamondOwner {
7
+ modifier onlyOwner() {
8
+ LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();
9
+ require(msg.sender == ds.contractOwner, "Only owner is allowed to perform this action");
10
+ _;
11
+ }
12
+ }
@@ -0,0 +1,12 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ import "./libraries/LibDiamond.sol";
5
+
6
+ contract UsingDiamondOwner {
7
+ modifier onlyOwner() {
8
+ LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();
9
+ require(msg.sender == ds.contractOwner, "Only owner is allowed to perform this action");
10
+ _;
11
+ }
12
+ }
@@ -0,0 +1,38 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ library LibDiamond {
5
+ bytes32 constant DIAMOND_STORAGE_POSITION = keccak256("diamond.standard.diamond.storage");
6
+
7
+ struct FacetAddressAndPosition {
8
+ address facetAddress;
9
+ uint16 functionSelectorPosition; // position in facetFunctionSelectors.functionSelectors array
10
+ }
11
+
12
+ struct FacetFunctionSelectors {
13
+ bytes4[] functionSelectors;
14
+ uint16 facetAddressPosition; // position of facetAddress in facetAddresses array
15
+ }
16
+
17
+ struct DiamondStorage {
18
+ // maps function selector to the facet address and
19
+ // the position of the selector in the facetFunctionSelectors.selectors array
20
+ mapping(bytes4 => FacetAddressAndPosition) selectorToFacetAndPosition;
21
+ // maps facet addresses to function selectors
22
+ mapping(address => FacetFunctionSelectors) facetFunctionSelectors;
23
+ // facet addresses
24
+ address[] facetAddresses;
25
+ // Used to query if a contract implements an interface.
26
+ // Used to implement ERC-165.
27
+ mapping(bytes4 => bool) supportedInterfaces;
28
+ // owner of the contract
29
+ address contractOwner;
30
+ }
31
+
32
+ function diamondStorage() internal pure returns (DiamondStorage storage ds) {
33
+ bytes32 position = DIAMOND_STORAGE_POSITION;
34
+ assembly {
35
+ ds.slot := position
36
+ }
37
+ }
38
+ }