Skip to content

Commit

Permalink
Merge pull request #24 from axieinfinity/release/v0.1.3
Browse files Browse the repository at this point in the history
chore: merge features from 'release/v0.1.3'
  • Loading branch information
TuDo1403 authored Dec 19, 2023
2 parents 3c183cd + 08eff70 commit e17e269
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions script/BaseMigration.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,18 @@ abstract contract BaseMigration is ScriptExtended {

function loadContractOrDeploy(TContract contractType) public virtual returns (address payable contractAddr) {
string memory contractName = CONFIG.getContractName(contractType);
try CONFIG.getAddressFromCurrentNetwork(contractType) returns (address payable addr) {
try this.loadContract(contractType) returns (address payable addr) {
contractAddr = addr;
} catch {
console.log(string.concat("Deployment for ", contractName, " not found, try fresh deploy ...").yellow());
contractAddr = _deployScript[contractType].run();
}
}

function loadContract(TContract contractType) public view virtual returns (address payable contractAddr) {
return CONFIG.getAddressFromCurrentNetwork(contractType);
}

function overrideArgs(bytes memory args) public virtual returns (IMigrationScript) {
_overriddenArgs = args;
return IMigrationScript(address(this));
Expand All @@ -62,6 +66,10 @@ abstract contract BaseMigration is ScriptExtended {
args = _overriddenArgs.length == 0 ? _defaultArguments() : _overriddenArgs;
}

function _getProxyAdmin() internal view virtual returns (address payable proxyAdmin) {
proxyAdmin = loadContract(DefaultContract.ProxyAdmin.key());
}

function _deployImmutable(TContract contractType) internal virtual returns (address payable deployed) {
deployed = _deployImmutable(contractType, arguments());
}
Expand Down Expand Up @@ -112,7 +120,7 @@ abstract contract BaseMigration is ScriptExtended {
address logic = _deployLogic(contractType);
string memory proxyAbsolutePath = "TransparentUpgradeableProxy.sol:TransparentUpgradeableProxy";
uint256 proxyNonce;
address proxyAdmin = CONFIG.getAddressFromCurrentNetwork(DefaultContract.ProxyAdmin.key());
address proxyAdmin = _getProxyAdmin();
assertTrue(proxyAdmin != address(0x0), "BaseMigration: Null ProxyAdmin");

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

0 comments on commit e17e269

Please sign in to comment.