@rocketh/proxy 0.19.5 → 0.19.6
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/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +55 -12
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/solc_0_6/ERC1967/Proxied.sol +129 -37
- package/solc_0_7/ERC1967/Proxied.sol +129 -37
- package/solc_0_8/ERC1967/Proxied.sol +129 -37
- package/src/index.ts +73 -15
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,16 @@ export type ProxyDeployOptions = Omit<DeployOptions, 'skipIfAlreadyDeployed' | '
|
|
|
9
9
|
owner?: EIP1193Account;
|
|
10
10
|
execute?: string | {
|
|
11
11
|
methodName: string;
|
|
12
|
-
args
|
|
12
|
+
args?: any[];
|
|
13
|
+
} | {
|
|
14
|
+
init: string | {
|
|
15
|
+
methodName: string;
|
|
16
|
+
args?: any[];
|
|
17
|
+
};
|
|
18
|
+
onUpgrade?: string | {
|
|
19
|
+
methodName: string;
|
|
20
|
+
args?: any[];
|
|
21
|
+
};
|
|
13
22
|
};
|
|
14
23
|
upgradeIndex?: number;
|
|
15
24
|
checkProxyAdmin?: boolean;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,WAAW,EAAC,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,EAAC,QAAQ,EAAE,sBAAsB,EAAE,UAAU,EAAE,WAAW,EAAC,MAAM,qBAAqB,CAAC;AACnG,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,UAAU,CAAC;AAG7C,OAAO,EAAS,aAAa,EAAC,MAAM,iBAAiB,CAAC;AActD,YAAY,EAAC,GAAG,EAAE,WAAW,EAAE,QAAQ,EAAE,sBAAsB,EAAE,UA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,IAAI,CAAC,EAC5B,UAAU,CACV,GAAG;IACH,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,CAAC,IAAI,SAAS,GAAG,EACrD,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,mCAAmC,CAAC,IAAI,CAAC,EACjD,OAAO,CAAC,EAAE,kBAAkB,KACxB,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;AAE/B,wBAAgB,cAAc,CAC7B,GAAG,EAAE,WAAW,GACd,CAAC,IAAI,SAAS,GAAG,EACnB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,mCAAmC,CAAC,IAAI,CAAC,EACjD,OAAO,CAAC,EAAE,kBAAkB,KACxB,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAib7B"}
|
package/dist/index.js
CHANGED
|
@@ -161,20 +161,63 @@ export function deployViaProxy(env) {
|
|
|
161
161
|
}
|
|
162
162
|
let postUpgradeCalldata;
|
|
163
163
|
if (options?.execute) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
164
|
+
let execution;
|
|
165
|
+
if (typeof options.execute == 'string') {
|
|
166
|
+
execution = {
|
|
167
|
+
methodName: options.execute,
|
|
168
|
+
args: args,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
else if ('methodName' in options.execute) {
|
|
172
|
+
execution = {
|
|
173
|
+
methodName: options.execute.methodName,
|
|
174
|
+
args: options.execute.args || args,
|
|
175
|
+
};
|
|
175
176
|
}
|
|
176
177
|
else {
|
|
177
|
-
|
|
178
|
+
if (existingDeployment) {
|
|
179
|
+
if (typeof options.execute.onUpgrade === 'string') {
|
|
180
|
+
execution = {
|
|
181
|
+
methodName: options.execute.onUpgrade,
|
|
182
|
+
args: args,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
else if (typeof options.execute.onUpgrade === 'object') {
|
|
186
|
+
execution = {
|
|
187
|
+
methodName: options.execute.onUpgrade.methodName,
|
|
188
|
+
args: options.execute.onUpgrade.args || args,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
if (typeof options.execute.init === 'string') {
|
|
194
|
+
execution = {
|
|
195
|
+
methodName: options.execute.init,
|
|
196
|
+
args: args,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
else if (typeof options.execute.init === 'object') {
|
|
200
|
+
execution = {
|
|
201
|
+
methodName: options.execute.init.methodName,
|
|
202
|
+
args: options.execute.init.args || args,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (execution) {
|
|
208
|
+
const method = artifactToUse.abi.find((v) => v.type === 'function' && v.name === execution.methodName);
|
|
209
|
+
if (method) {
|
|
210
|
+
postUpgradeCalldata = encodeFunctionData({
|
|
211
|
+
...viemArgs,
|
|
212
|
+
args: execution.args,
|
|
213
|
+
account: address,
|
|
214
|
+
abi: [method],
|
|
215
|
+
functionName: method.name,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
throw new Error(`Method ${execution.methodName} not found in artifact provided for ${name}`);
|
|
220
|
+
}
|
|
178
221
|
}
|
|
179
222
|
}
|
|
180
223
|
// let preUpgradeCalldata: `0x${string}` | undefined;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,kBAAkB,EAAE,WAAW,EAAC,MAAM,MAAM,CAAC;AACrD,OAAO,EAAC,IAAI,EAAC,MAAM,YAAY,CAAC;AAChC,OAAO,EAAC,MAAM,EAAgB,MAAM,iBAAiB,CAAC;AACtD,OAAO,E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GAAG,CAAC,IAAI,CAAO,IAAI,EAAE;oBAC/C,GAAG,eAAe;oBAClB,GAAG,aAAa;oBAChB,GAAG,EAAE,SAA4B;oBACjC,UAAU,EAAE,0BAA0B,CAAC,OAAO,EAAE,UAAU,CAAC;iBAC3D,CAAC,CAAC;gBACH,MAAM,CAAC,IAAI,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC;YAClC,CAAC;QACF,CAAC;QACD,OAAO,kBAAkB,CAAC;IAC3B,CAAC,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rocketh/proxy",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.6",
|
|
4
4
|
"description": "provide proxy-enabled deploy function for rocketh",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rocketh",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"eip-1193": "^0.6.5",
|
|
52
52
|
"named-logs": "^0.4.1",
|
|
53
53
|
"viem": "^2.45.1",
|
|
54
|
-
"@rocketh/deploy": "0.19.1",
|
|
55
54
|
"@rocketh/core": "0.19.0",
|
|
55
|
+
"@rocketh/deploy": "0.19.1",
|
|
56
56
|
"@rocketh/read-execute": "0.19.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
@@ -1,42 +1,134 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.6.0;
|
|
3
3
|
|
|
4
|
+
/// @title Proxied
|
|
5
|
+
/// @notice Abstract contract providing proxy-aware initialization and access control utilities
|
|
6
|
+
/// @dev This contract is designed to be inherited by implementation contracts used behind ERC1967 proxies.
|
|
7
|
+
/// It provides modifiers for proxy-only execution and initialization patterns.
|
|
8
|
+
/// Storage slots follow the ERC1967 standard where applicable.
|
|
4
9
|
abstract contract Proxied {
|
|
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
|
-
|
|
10
|
+
/// @notice Restricts function access to the proxy admin only
|
|
11
|
+
/// @dev Uses the ERC1967 admin slot to determine the admin address
|
|
12
|
+
modifier onlyProxyAdmin() {
|
|
13
|
+
require(msg.sender == _proxyAdmin(), "PROXY_ONLY_ADMIN");
|
|
14
|
+
_;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/// @notice Modifier for functions that should only be called once during proxy initialization
|
|
18
|
+
/// @dev This modifier ensures the function can only be called once and only through a proxy.
|
|
19
|
+
///
|
|
20
|
+
/// =====================================================================================
|
|
21
|
+
/// ⚠️ CRITICAL SECURITY WARNING ⚠️
|
|
22
|
+
/// =====================================================================================
|
|
23
|
+
/// Functions using this modifier MUST be called during the proxy deployment transaction
|
|
24
|
+
/// (typically via the proxy constructor's initialization calldata).
|
|
25
|
+
///
|
|
26
|
+
/// If the initializer function is NOT called at deployment time, the contract will be
|
|
27
|
+
/// left in an uninitialized state, and ANYONE can call the initializer function to
|
|
28
|
+
/// take control of the contract. This could lead to:
|
|
29
|
+
/// - Unauthorized ownership of the contract
|
|
30
|
+
/// - Theft of funds
|
|
31
|
+
/// - Manipulation of contract state
|
|
32
|
+
///
|
|
33
|
+
/// NEVER deploy a proxy without immediately calling such initializer in the same transaction.
|
|
34
|
+
/// =====================================================================================
|
|
35
|
+
modifier asProxyOneTimeInitialiser() {
|
|
36
|
+
bool initialised = _ensureProxyOnly();
|
|
37
|
+
|
|
38
|
+
// only allowed to be called once
|
|
39
|
+
require(!initialised, "PROXY_ALREADY_INITIALISED");
|
|
40
|
+
|
|
41
|
+
_markAsInitialised();
|
|
42
|
+
|
|
43
|
+
_;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/// @notice Modifier for functions that can be re-initialized by the proxy admin after first initialization
|
|
47
|
+
/// @dev On first call, marks the contract as initialized. On subsequent calls, requires proxy admin.
|
|
48
|
+
///
|
|
49
|
+
/// =====================================================================================
|
|
50
|
+
/// ⚠️ CRITICAL SECURITY WARNING ⚠️
|
|
51
|
+
/// =====================================================================================
|
|
52
|
+
/// Functions using this modifier MUST be called during the proxy deployment transaction
|
|
53
|
+
/// (typically via the proxy constructor's initialization calldata).
|
|
54
|
+
///
|
|
55
|
+
/// If the initializer function is NOT called at deployment time, the contract will be
|
|
56
|
+
/// left in an uninitialized state, and ANYONE can call the initializer function to
|
|
57
|
+
/// take control of the contract. This could lead to:
|
|
58
|
+
/// - Unauthorized ownership of the contract
|
|
59
|
+
/// - Theft of funds
|
|
60
|
+
/// - Manipulation of contract state
|
|
61
|
+
///
|
|
62
|
+
/// NEVER deploy a proxy without immediately calling such initializer in the same transaction.
|
|
63
|
+
///
|
|
64
|
+
/// After initialization, only the proxy admin can call functions with this modifier,
|
|
65
|
+
/// which is useful for upgrade scenarios where re-initialization may be needed.
|
|
66
|
+
/// =====================================================================================
|
|
67
|
+
modifier asProxyInitialiser() {
|
|
68
|
+
bool initialised = _ensureProxyOnly();
|
|
69
|
+
|
|
70
|
+
if (initialised) {
|
|
71
|
+
// if initialised, can be called only by proxy admin
|
|
72
|
+
require(msg.sender == _proxyAdmin(), "PROXY_INIT_ONLY_ADMIN");
|
|
73
|
+
} else {
|
|
74
|
+
_markAsInitialised();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
_;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/// @notice Ensures the function is being called through a proxy and returns initialization status
|
|
81
|
+
/// @dev Reverts if not called through a proxy (i.e., if implementation address is zero)
|
|
82
|
+
/// @return initialised Whether the proxy has already been initialized
|
|
83
|
+
function _ensureProxyOnly() internal view returns (bool initialised) {
|
|
84
|
+
address implementationAddress = _proxyImplementation();
|
|
85
|
+
|
|
86
|
+
// only allowed if proxy
|
|
87
|
+
require(implementationAddress != address(0), "PROXY_ONLY");
|
|
88
|
+
|
|
89
|
+
initialised = _proxyInitialised();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/// @notice Marks the proxy as initialized
|
|
93
|
+
/// @dev Writes `true` to the custom initialization storage slot.
|
|
94
|
+
/// Slot: bytes32(uint256(keccak256('eip1967.proxy.initialised')) - 1)
|
|
95
|
+
function _markAsInitialised() internal {
|
|
96
|
+
// solhint-disable-next-line security/no-inline-assembly
|
|
97
|
+
assembly {
|
|
98
|
+
sstore(0x0037d21023b0b946d199d157363fe66c4e723e916e3bab3dac56c11d3acca3b4, true)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/// @notice Returns the current proxy admin address
|
|
103
|
+
/// @dev Reads from the ERC1967 admin slot.
|
|
104
|
+
/// Slot: bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)
|
|
105
|
+
/// @return ownerAddress The address of the proxy admin
|
|
106
|
+
function _proxyAdmin() internal view returns (address ownerAddress) {
|
|
107
|
+
// solhint-disable-next-line security/no-inline-assembly
|
|
108
|
+
assembly {
|
|
109
|
+
ownerAddress := sload(0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/// @notice Returns the current implementation address
|
|
114
|
+
/// @dev Reads from the ERC1967 implementation slot.
|
|
115
|
+
/// Slot: bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)
|
|
116
|
+
/// @return implementationAddress The address of the current implementation contract
|
|
117
|
+
function _proxyImplementation() internal view returns (address implementationAddress) {
|
|
118
|
+
// solhint-disable-next-line security/no-inline-assembly
|
|
119
|
+
assembly {
|
|
120
|
+
implementationAddress := sload(0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/// @notice Checks whether the proxy has been initialized
|
|
125
|
+
/// @dev Reads from the custom initialization storage slot.
|
|
126
|
+
/// Slot: bytes32(uint256(keccak256('eip1967.proxy.initialised')) - 1)
|
|
127
|
+
/// @return initialised Whether the proxy has been initialized
|
|
128
|
+
function _proxyInitialised() internal view returns (bool initialised) {
|
|
129
|
+
// solhint-disable-next-line security/no-inline-assembly
|
|
130
|
+
assembly {
|
|
131
|
+
initialised := sload(0x0037d21023b0b946d199d157363fe66c4e723e916e3bab3dac56c11d3acca3b4)
|
|
132
|
+
}
|
|
133
|
+
}
|
|
42
134
|
}
|
|
@@ -1,42 +1,134 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.7.0;
|
|
3
3
|
|
|
4
|
+
/// @title Proxied
|
|
5
|
+
/// @notice Abstract contract providing proxy-aware initialization and access control utilities
|
|
6
|
+
/// @dev This contract is designed to be inherited by implementation contracts used behind ERC1967 proxies.
|
|
7
|
+
/// It provides modifiers for proxy-only execution and initialization patterns.
|
|
8
|
+
/// Storage slots follow the ERC1967 standard where applicable.
|
|
4
9
|
abstract contract Proxied {
|
|
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
|
-
|
|
10
|
+
/// @notice Restricts function access to the proxy admin only
|
|
11
|
+
/// @dev Uses the ERC1967 admin slot to determine the admin address
|
|
12
|
+
modifier onlyProxyAdmin() {
|
|
13
|
+
require(msg.sender == _proxyAdmin(), "PROXY_ONLY_ADMIN");
|
|
14
|
+
_;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/// @notice Modifier for functions that should only be called once during proxy initialization
|
|
18
|
+
/// @dev This modifier ensures the function can only be called once and only through a proxy.
|
|
19
|
+
///
|
|
20
|
+
/// =====================================================================================
|
|
21
|
+
/// ⚠️ CRITICAL SECURITY WARNING ⚠️
|
|
22
|
+
/// =====================================================================================
|
|
23
|
+
/// Functions using this modifier MUST be called during the proxy deployment transaction
|
|
24
|
+
/// (typically via the proxy constructor's initialization calldata).
|
|
25
|
+
///
|
|
26
|
+
/// If the initializer function is NOT called at deployment time, the contract will be
|
|
27
|
+
/// left in an uninitialized state, and ANYONE can call the initializer function to
|
|
28
|
+
/// take control of the contract. This could lead to:
|
|
29
|
+
/// - Unauthorized ownership of the contract
|
|
30
|
+
/// - Theft of funds
|
|
31
|
+
/// - Manipulation of contract state
|
|
32
|
+
///
|
|
33
|
+
/// NEVER deploy a proxy without immediately calling such initializer in the same transaction.
|
|
34
|
+
/// =====================================================================================
|
|
35
|
+
modifier asProxyOneTimeInitialiser() {
|
|
36
|
+
bool initialised = _ensureProxyOnly();
|
|
37
|
+
|
|
38
|
+
// only allowed to be called once
|
|
39
|
+
require(!initialised, "PROXY_ALREADY_INITIALISED");
|
|
40
|
+
|
|
41
|
+
_markAsInitialised();
|
|
42
|
+
|
|
43
|
+
_;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/// @notice Modifier for functions that can be re-initialized by the proxy admin after first initialization
|
|
47
|
+
/// @dev On first call, marks the contract as initialized. On subsequent calls, requires proxy admin.
|
|
48
|
+
///
|
|
49
|
+
/// =====================================================================================
|
|
50
|
+
/// ⚠️ CRITICAL SECURITY WARNING ⚠️
|
|
51
|
+
/// =====================================================================================
|
|
52
|
+
/// Functions using this modifier MUST be called during the proxy deployment transaction
|
|
53
|
+
/// (typically via the proxy constructor's initialization calldata).
|
|
54
|
+
///
|
|
55
|
+
/// If the initializer function is NOT called at deployment time, the contract will be
|
|
56
|
+
/// left in an uninitialized state, and ANYONE can call the initializer function to
|
|
57
|
+
/// take control of the contract. This could lead to:
|
|
58
|
+
/// - Unauthorized ownership of the contract
|
|
59
|
+
/// - Theft of funds
|
|
60
|
+
/// - Manipulation of contract state
|
|
61
|
+
///
|
|
62
|
+
/// NEVER deploy a proxy without immediately calling such initializer in the same transaction.
|
|
63
|
+
///
|
|
64
|
+
/// After initialization, only the proxy admin can call functions with this modifier,
|
|
65
|
+
/// which is useful for upgrade scenarios where re-initialization may be needed.
|
|
66
|
+
/// =====================================================================================
|
|
67
|
+
modifier asProxyInitialiser() {
|
|
68
|
+
bool initialised = _ensureProxyOnly();
|
|
69
|
+
|
|
70
|
+
if (initialised) {
|
|
71
|
+
// if initialised, can be called only by proxy admin
|
|
72
|
+
require(msg.sender == _proxyAdmin(), "PROXY_INIT_ONLY_ADMIN");
|
|
73
|
+
} else {
|
|
74
|
+
_markAsInitialised();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
_;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/// @notice Ensures the function is being called through a proxy and returns initialization status
|
|
81
|
+
/// @dev Reverts if not called through a proxy (i.e., if implementation address is zero)
|
|
82
|
+
/// @return initialised Whether the proxy has already been initialized
|
|
83
|
+
function _ensureProxyOnly() internal view returns (bool initialised) {
|
|
84
|
+
address implementationAddress = _proxyImplementation();
|
|
85
|
+
|
|
86
|
+
// only allowed if proxy
|
|
87
|
+
require(implementationAddress != address(0), "PROXY_ONLY");
|
|
88
|
+
|
|
89
|
+
initialised = _proxyInitialised();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/// @notice Marks the proxy as initialized
|
|
93
|
+
/// @dev Writes `true` to the custom initialization storage slot.
|
|
94
|
+
/// Slot: bytes32(uint256(keccak256('eip1967.proxy.initialised')) - 1)
|
|
95
|
+
function _markAsInitialised() internal {
|
|
96
|
+
// solhint-disable-next-line security/no-inline-assembly
|
|
97
|
+
assembly {
|
|
98
|
+
sstore(0x0037d21023b0b946d199d157363fe66c4e723e916e3bab3dac56c11d3acca3b4, true)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/// @notice Returns the current proxy admin address
|
|
103
|
+
/// @dev Reads from the ERC1967 admin slot.
|
|
104
|
+
/// Slot: bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)
|
|
105
|
+
/// @return ownerAddress The address of the proxy admin
|
|
106
|
+
function _proxyAdmin() internal view returns (address ownerAddress) {
|
|
107
|
+
// solhint-disable-next-line security/no-inline-assembly
|
|
108
|
+
assembly {
|
|
109
|
+
ownerAddress := sload(0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/// @notice Returns the current implementation address
|
|
114
|
+
/// @dev Reads from the ERC1967 implementation slot.
|
|
115
|
+
/// Slot: bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)
|
|
116
|
+
/// @return implementationAddress The address of the current implementation contract
|
|
117
|
+
function _proxyImplementation() internal view returns (address implementationAddress) {
|
|
118
|
+
// solhint-disable-next-line security/no-inline-assembly
|
|
119
|
+
assembly {
|
|
120
|
+
implementationAddress := sload(0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/// @notice Checks whether the proxy has been initialized
|
|
125
|
+
/// @dev Reads from the custom initialization storage slot.
|
|
126
|
+
/// Slot: bytes32(uint256(keccak256('eip1967.proxy.initialised')) - 1)
|
|
127
|
+
/// @return initialised Whether the proxy has been initialized
|
|
128
|
+
function _proxyInitialised() internal view returns (bool initialised) {
|
|
129
|
+
// solhint-disable-next-line security/no-inline-assembly
|
|
130
|
+
assembly {
|
|
131
|
+
initialised := sload(0x0037d21023b0b946d199d157363fe66c4e723e916e3bab3dac56c11d3acca3b4)
|
|
132
|
+
}
|
|
133
|
+
}
|
|
42
134
|
}
|
|
@@ -1,42 +1,134 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
|
+
/// @title Proxied
|
|
5
|
+
/// @notice Abstract contract providing proxy-aware initialization and access control utilities
|
|
6
|
+
/// @dev This contract is designed to be inherited by implementation contracts used behind ERC1967 proxies.
|
|
7
|
+
/// It provides modifiers for proxy-only execution and initialization patterns.
|
|
8
|
+
/// Storage slots follow the ERC1967 standard where applicable.
|
|
4
9
|
abstract contract Proxied {
|
|
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
|
-
|
|
10
|
+
/// @notice Restricts function access to the proxy admin only
|
|
11
|
+
/// @dev Uses the ERC1967 admin slot to determine the admin address
|
|
12
|
+
modifier onlyProxyAdmin() {
|
|
13
|
+
require(msg.sender == _proxyAdmin(), "PROXY_ONLY_ADMIN");
|
|
14
|
+
_;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/// @notice Modifier for functions that should only be called once during proxy initialization
|
|
18
|
+
/// @dev This modifier ensures the function can only be called once and only through a proxy.
|
|
19
|
+
///
|
|
20
|
+
/// =====================================================================================
|
|
21
|
+
/// ⚠️ CRITICAL SECURITY WARNING ⚠️
|
|
22
|
+
/// =====================================================================================
|
|
23
|
+
/// Functions using this modifier MUST be called during the proxy deployment transaction
|
|
24
|
+
/// (typically via the proxy constructor's initialization calldata).
|
|
25
|
+
///
|
|
26
|
+
/// If the initializer function is NOT called at deployment time, the contract will be
|
|
27
|
+
/// left in an uninitialized state, and ANYONE can call the initializer function to
|
|
28
|
+
/// take control of the contract. This could lead to:
|
|
29
|
+
/// - Unauthorized ownership of the contract
|
|
30
|
+
/// - Theft of funds
|
|
31
|
+
/// - Manipulation of contract state
|
|
32
|
+
///
|
|
33
|
+
/// NEVER deploy a proxy without immediately calling such initializer in the same transaction.
|
|
34
|
+
/// =====================================================================================
|
|
35
|
+
modifier asProxyOneTimeInitialiser() {
|
|
36
|
+
bool initialised = _ensureProxyOnly();
|
|
37
|
+
|
|
38
|
+
// only allowed to be called once
|
|
39
|
+
require(!initialised, "PROXY_ALREADY_INITIALISED");
|
|
40
|
+
|
|
41
|
+
_markAsInitialised();
|
|
42
|
+
|
|
43
|
+
_;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/// @notice Modifier for functions that can be re-initialized by the proxy admin after first initialization
|
|
47
|
+
/// @dev On first call, marks the contract as initialized. On subsequent calls, requires proxy admin.
|
|
48
|
+
///
|
|
49
|
+
/// =====================================================================================
|
|
50
|
+
/// ⚠️ CRITICAL SECURITY WARNING ⚠️
|
|
51
|
+
/// =====================================================================================
|
|
52
|
+
/// Functions using this modifier MUST be called during the proxy deployment transaction
|
|
53
|
+
/// (typically via the proxy constructor's initialization calldata).
|
|
54
|
+
///
|
|
55
|
+
/// If the initializer function is NOT called at deployment time, the contract will be
|
|
56
|
+
/// left in an uninitialized state, and ANYONE can call the initializer function to
|
|
57
|
+
/// take control of the contract. This could lead to:
|
|
58
|
+
/// - Unauthorized ownership of the contract
|
|
59
|
+
/// - Theft of funds
|
|
60
|
+
/// - Manipulation of contract state
|
|
61
|
+
///
|
|
62
|
+
/// NEVER deploy a proxy without immediately calling such initializer in the same transaction.
|
|
63
|
+
///
|
|
64
|
+
/// After initialization, only the proxy admin can call functions with this modifier,
|
|
65
|
+
/// which is useful for upgrade scenarios where re-initialization may be needed.
|
|
66
|
+
/// =====================================================================================
|
|
67
|
+
modifier asProxyInitialiser() {
|
|
68
|
+
bool initialised = _ensureProxyOnly();
|
|
69
|
+
|
|
70
|
+
if (initialised) {
|
|
71
|
+
// if initialised, can be called only by proxy admin
|
|
72
|
+
require(msg.sender == _proxyAdmin(), "PROXY_INIT_ONLY_ADMIN");
|
|
73
|
+
} else {
|
|
74
|
+
_markAsInitialised();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
_;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/// @notice Ensures the function is being called through a proxy and returns initialization status
|
|
81
|
+
/// @dev Reverts if not called through a proxy (i.e., if implementation address is zero)
|
|
82
|
+
/// @return initialised Whether the proxy has already been initialized
|
|
83
|
+
function _ensureProxyOnly() internal view returns (bool initialised) {
|
|
84
|
+
address implementationAddress = _proxyImplementation();
|
|
85
|
+
|
|
86
|
+
// only allowed if proxy
|
|
87
|
+
require(implementationAddress != address(0), "PROXY_ONLY");
|
|
88
|
+
|
|
89
|
+
initialised = _proxyInitialised();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/// @notice Marks the proxy as initialized
|
|
93
|
+
/// @dev Writes `true` to the custom initialization storage slot.
|
|
94
|
+
/// Slot: bytes32(uint256(keccak256('eip1967.proxy.initialised')) - 1)
|
|
95
|
+
function _markAsInitialised() internal {
|
|
96
|
+
// solhint-disable-next-line security/no-inline-assembly
|
|
97
|
+
assembly {
|
|
98
|
+
sstore(0x0037d21023b0b946d199d157363fe66c4e723e916e3bab3dac56c11d3acca3b4, true)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/// @notice Returns the current proxy admin address
|
|
103
|
+
/// @dev Reads from the ERC1967 admin slot.
|
|
104
|
+
/// Slot: bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)
|
|
105
|
+
/// @return ownerAddress The address of the proxy admin
|
|
106
|
+
function _proxyAdmin() internal view returns (address ownerAddress) {
|
|
107
|
+
// solhint-disable-next-line security/no-inline-assembly
|
|
108
|
+
assembly {
|
|
109
|
+
ownerAddress := sload(0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/// @notice Returns the current implementation address
|
|
114
|
+
/// @dev Reads from the ERC1967 implementation slot.
|
|
115
|
+
/// Slot: bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)
|
|
116
|
+
/// @return implementationAddress The address of the current implementation contract
|
|
117
|
+
function _proxyImplementation() internal view returns (address implementationAddress) {
|
|
118
|
+
// solhint-disable-next-line security/no-inline-assembly
|
|
119
|
+
assembly {
|
|
120
|
+
implementationAddress := sload(0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/// @notice Checks whether the proxy has been initialized
|
|
125
|
+
/// @dev Reads from the custom initialization storage slot.
|
|
126
|
+
/// Slot: bytes32(uint256(keccak256('eip1967.proxy.initialised')) - 1)
|
|
127
|
+
/// @return initialised Whether the proxy has been initialized
|
|
128
|
+
function _proxyInitialised() internal view returns (bool initialised) {
|
|
129
|
+
// solhint-disable-next-line security/no-inline-assembly
|
|
130
|
+
assembly {
|
|
131
|
+
initialised := sload(0x0037d21023b0b946d199d157363fe66c4e723e916e3bab3dac56c11d3acca3b4)
|
|
132
|
+
}
|
|
133
|
+
}
|
|
42
134
|
}
|
package/src/index.ts
CHANGED
|
@@ -33,7 +33,21 @@ export type ProxyDeployOptions = Omit<DeployOptions, 'skipIfAlreadyDeployed' | '
|
|
|
33
33
|
| string
|
|
34
34
|
| {
|
|
35
35
|
methodName: string;
|
|
36
|
-
args
|
|
36
|
+
args?: any[];
|
|
37
|
+
}
|
|
38
|
+
| {
|
|
39
|
+
init:
|
|
40
|
+
| string
|
|
41
|
+
| {
|
|
42
|
+
methodName: string;
|
|
43
|
+
args?: any[];
|
|
44
|
+
};
|
|
45
|
+
onUpgrade?:
|
|
46
|
+
| string
|
|
47
|
+
| {
|
|
48
|
+
methodName: string;
|
|
49
|
+
args?: any[];
|
|
50
|
+
};
|
|
37
51
|
};
|
|
38
52
|
upgradeIndex?: number;
|
|
39
53
|
checkProxyAdmin?: boolean;
|
|
@@ -306,21 +320,65 @@ export function deployViaProxy(
|
|
|
306
320
|
|
|
307
321
|
let postUpgradeCalldata: `0x${string}` | undefined;
|
|
308
322
|
if (options?.execute) {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
323
|
+
let execution:
|
|
324
|
+
| {
|
|
325
|
+
methodName: string;
|
|
326
|
+
args: any[];
|
|
327
|
+
}
|
|
328
|
+
| undefined;
|
|
329
|
+
if (typeof options.execute == 'string') {
|
|
330
|
+
execution = {
|
|
331
|
+
methodName: options.execute,
|
|
332
|
+
args: args as any[],
|
|
333
|
+
};
|
|
334
|
+
} else if ('methodName' in options.execute) {
|
|
335
|
+
execution = {
|
|
336
|
+
methodName: options.execute.methodName,
|
|
337
|
+
args: options.execute.args || (args as any[]),
|
|
338
|
+
};
|
|
322
339
|
} else {
|
|
323
|
-
|
|
340
|
+
if (existingDeployment) {
|
|
341
|
+
if (typeof options.execute.onUpgrade === 'string') {
|
|
342
|
+
execution = {
|
|
343
|
+
methodName: options.execute.onUpgrade,
|
|
344
|
+
args: args as any[],
|
|
345
|
+
};
|
|
346
|
+
} else if (typeof options.execute.onUpgrade === 'object') {
|
|
347
|
+
execution = {
|
|
348
|
+
methodName: options.execute.onUpgrade.methodName,
|
|
349
|
+
args: options.execute.onUpgrade.args || (args as any[]),
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
} else {
|
|
353
|
+
if (typeof options.execute.init === 'string') {
|
|
354
|
+
execution = {
|
|
355
|
+
methodName: options.execute.init,
|
|
356
|
+
args: args as any[],
|
|
357
|
+
};
|
|
358
|
+
} else if (typeof options.execute.init === 'object') {
|
|
359
|
+
execution = {
|
|
360
|
+
methodName: options.execute.init.methodName,
|
|
361
|
+
args: options.execute.init.args || (args as any[]),
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
if (execution) {
|
|
368
|
+
const method: AbiFunction | undefined = artifactToUse.abi.find(
|
|
369
|
+
(v) => v.type === 'function' && v.name === execution.methodName,
|
|
370
|
+
) as AbiFunction;
|
|
371
|
+
if (method) {
|
|
372
|
+
postUpgradeCalldata = encodeFunctionData({
|
|
373
|
+
...viemArgs,
|
|
374
|
+
args: execution.args,
|
|
375
|
+
account: address,
|
|
376
|
+
abi: [method],
|
|
377
|
+
functionName: method.name,
|
|
378
|
+
});
|
|
379
|
+
} else {
|
|
380
|
+
throw new Error(`Method ${execution.methodName} not found in artifact provided for ${name}`);
|
|
381
|
+
}
|
|
324
382
|
}
|
|
325
383
|
}
|
|
326
384
|
// let preUpgradeCalldata: `0x${string}` | undefined;
|