Skip to content

Commit e17e269

Browse files
authored
Merge pull request #24 from axieinfinity/release/v0.1.3
chore: merge features from 'release/v0.1.3'
2 parents 3c183cd + 08eff70 commit e17e269

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

script/BaseMigration.s.sol

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,18 @@ abstract contract BaseMigration is ScriptExtended {
4545

4646
function loadContractOrDeploy(TContract contractType) public virtual returns (address payable contractAddr) {
4747
string memory contractName = CONFIG.getContractName(contractType);
48-
try CONFIG.getAddressFromCurrentNetwork(contractType) returns (address payable addr) {
48+
try this.loadContract(contractType) returns (address payable addr) {
4949
contractAddr = addr;
5050
} catch {
5151
console.log(string.concat("Deployment for ", contractName, " not found, try fresh deploy ...").yellow());
5252
contractAddr = _deployScript[contractType].run();
5353
}
5454
}
5555

56+
function loadContract(TContract contractType) public view virtual returns (address payable contractAddr) {
57+
return CONFIG.getAddressFromCurrentNetwork(contractType);
58+
}
59+
5660
function overrideArgs(bytes memory args) public virtual returns (IMigrationScript) {
5761
_overriddenArgs = args;
5862
return IMigrationScript(address(this));
@@ -62,6 +66,10 @@ abstract contract BaseMigration is ScriptExtended {
6266
args = _overriddenArgs.length == 0 ? _defaultArguments() : _overriddenArgs;
6367
}
6468

69+
function _getProxyAdmin() internal view virtual returns (address payable proxyAdmin) {
70+
proxyAdmin = loadContract(DefaultContract.ProxyAdmin.key());
71+
}
72+
6573
function _deployImmutable(TContract contractType) internal virtual returns (address payable deployed) {
6674
deployed = _deployImmutable(contractType, arguments());
6775
}
@@ -112,7 +120,7 @@ abstract contract BaseMigration is ScriptExtended {
112120
address logic = _deployLogic(contractType);
113121
string memory proxyAbsolutePath = "TransparentUpgradeableProxy.sol:TransparentUpgradeableProxy";
114122
uint256 proxyNonce;
115-
address proxyAdmin = CONFIG.getAddressFromCurrentNetwork(DefaultContract.ProxyAdmin.key());
123+
address proxyAdmin = _getProxyAdmin();
116124
assertTrue(proxyAdmin != address(0x0), "BaseMigration: Null ProxyAdmin");
117125

118126
(deployed, proxyNonce) = _deployRaw(proxyAbsolutePath, abi.encode(logic, proxyAdmin, args));

0 commit comments

Comments
 (0)