Skip to content

Commit 64011e1

Browse files
authored
Merge pull request #124 from axieinfinity/feature/upgrade-proxy
feat: Upgrade proxy with logic constructor param
2 parents 868ea89 + a692077 commit 64011e1

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

script/BaseMigration.s.sol

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ abstract contract BaseMigration is ScriptExtended {
139139
string memory contractName = CONFIG.getContractName(contractType);
140140

141141
address logic = _deployLogic(contractType, argsLogicConstructor);
142-
string memory proxyAbsolutePath = "./out/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.json";
142+
string memory proxyAbsolutePath =
143+
"./out/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.json";
143144
uint256 proxyNonce = vm.getNonce(sender());
144145
address proxyAdmin = _getProxyAdmin();
145146
assertTrue(proxyAdmin != address(0x0), "BaseMigration: Null ProxyAdmin");
@@ -201,13 +202,17 @@ abstract contract BaseMigration is ScriptExtended {
201202
proxy = _upgradeProxy(contractType, arguments());
202203
}
203204

204-
function _upgradeProxy(TContract contractType, bytes memory args)
205+
function _upgradeProxy(TContract contractType, bytes memory args) internal virtual returns (address payable proxy) {
206+
proxy = _upgradeProxy(contractType, args, EMPTY_ARGS);
207+
}
208+
209+
function _upgradeProxy(TContract contractType, bytes memory args, bytes memory argsLogicConstructor)
205210
internal
206211
virtual
207212
logFn(string.concat("_upgradeProxy ", TContract.unwrap(contractType).unpackOne()))
208213
returns (address payable proxy)
209214
{
210-
address logic = _deployLogic(contractType);
215+
address logic = _deployLogic(contractType, argsLogicConstructor);
211216
proxy = CONFIG.getAddress(network(), contractType);
212217
_upgradeRaw(proxy.getProxyAdmin(), proxy, logic, args);
213218
}
@@ -252,7 +257,7 @@ abstract contract BaseMigration is ScriptExtended {
252257
}
253258

254259
function _upgradeRaw(address proxyAdmin, address payable proxy, address logic, bytes memory args) internal virtual {
255-
if (logic.codehash == payable(proxyAdmin).getProxyImplementation({ nullCheck: true }).codehash) {
260+
if (logic.codehash == payable(proxy).getProxyImplementation({ nullCheck: true }).codehash) {
256261
console.log("BaseMigration: Logic is already upgraded!".yellow());
257262
return;
258263
}

0 commit comments

Comments
 (0)