@rocketh/proxy 0.19.1 → 0.19.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rocketh/proxy",
3
- "version": "0.19.1",
3
+ "version": "0.19.2",
4
4
  "description": "provide proxy-enabled deploy function for rocketh",
5
5
  "keywords": [
6
6
  "rocketh",
@@ -38,6 +38,8 @@
38
38
  "files": [
39
39
  "dist",
40
40
  "src",
41
+ "solc_0_6",
42
+ "solc_0_7",
41
43
  "solc_0_8"
42
44
  ],
43
45
  "dependencies": {
@@ -45,9 +47,9 @@
45
47
  "eip-1193": "^0.6.5",
46
48
  "named-logs": "^0.4.1",
47
49
  "viem": "^2.45.1",
50
+ "@rocketh/core": "0.19.0",
48
51
  "@rocketh/deploy": "0.19.1",
49
- "@rocketh/read-execute": "0.19.0",
50
- "@rocketh/core": "0.19.0"
52
+ "@rocketh/read-execute": "0.19.0"
51
53
  },
52
54
  "devDependencies": {
53
55
  "as-soon": "^0.1.5",
@@ -0,0 +1,42 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.6.0;
3
+
4
+ abstract contract Proxied {
5
+ /// @notice to be used by initialisation / postUpgrade function so that only the proxy's admin can execute them
6
+ /// It also allows these functions to be called inside a contructor
7
+ /// even if the contract is meant to be used without proxy
8
+ modifier proxied() {
9
+ address proxyAdminAddress = _proxyAdmin();
10
+ // With hardhat-deploy proxies
11
+ // the proxyAdminAddress is zero only for the implementation contract
12
+ // if the implementation contract want to be used as a standalone/immutable contract
13
+ // it simply has to execute the `proxied` function
14
+ // This ensure the proxyAdminAddress is never zero post deployment
15
+ // And allow you to keep the same code for both proxied contract and immutable contract
16
+ if (proxyAdminAddress == address(0)) {
17
+ // ensure can not be called twice when used outside of proxy : no admin
18
+ // solhint-disable-next-line security/no-inline-assembly
19
+ assembly {
20
+ sstore(
21
+ 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103,
22
+ 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
23
+ )
24
+ }
25
+ } else {
26
+ require(msg.sender == proxyAdminAddress);
27
+ }
28
+ _;
29
+ }
30
+
31
+ modifier onlyProxyAdmin() {
32
+ require(msg.sender == _proxyAdmin(), "NOT_AUTHORIZED");
33
+ _;
34
+ }
35
+
36
+ function _proxyAdmin() internal view returns (address ownerAddress) {
37
+ // solhint-disable-next-line security/no-inline-assembly
38
+ assembly {
39
+ ownerAddress := sload(0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103)
40
+ }
41
+ }
42
+ }
@@ -0,0 +1,42 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.7.0;
3
+
4
+ abstract contract Proxied {
5
+ /// @notice to be used by initialisation / postUpgrade function so that only the proxy's admin can execute them
6
+ /// It also allows these functions to be called inside a contructor
7
+ /// even if the contract is meant to be used without proxy
8
+ modifier proxied() {
9
+ address proxyAdminAddress = _proxyAdmin();
10
+ // With hardhat-deploy proxies
11
+ // the proxyAdminAddress is zero only for the implementation contract
12
+ // if the implementation contract want to be used as a standalone/immutable contract
13
+ // it simply has to execute the `proxied` function
14
+ // This ensure the proxyAdminAddress is never zero post deployment
15
+ // And allow you to keep the same code for both proxied contract and immutable contract
16
+ if (proxyAdminAddress == address(0)) {
17
+ // ensure can not be called twice when used outside of proxy : no admin
18
+ // solhint-disable-next-line security/no-inline-assembly
19
+ assembly {
20
+ sstore(
21
+ 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103,
22
+ 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
23
+ )
24
+ }
25
+ } else {
26
+ require(msg.sender == proxyAdminAddress);
27
+ }
28
+ _;
29
+ }
30
+
31
+ modifier onlyProxyAdmin() {
32
+ require(msg.sender == _proxyAdmin(), "NOT_AUTHORIZED");
33
+ _;
34
+ }
35
+
36
+ function _proxyAdmin() internal view returns (address ownerAddress) {
37
+ // solhint-disable-next-line security/no-inline-assembly
38
+ assembly {
39
+ ownerAddress := sload(0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103)
40
+ }
41
+ }
42
+ }