Skip to content

Commit

Permalink
Merge pull request #129 from axieinfinity/implement-feature/misc/add-…
Browse files Browse the repository at this point in the history
…minor-enhancements

feat(misc): implement `add-minor-enhancements`
  • Loading branch information
TuDo1403 authored Mar 25, 2024
2 parents 229bd0f + 25e5d3a commit 1e2d229
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/create-PR-implement.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
toBranch: ${{ env.FEATURE_BRANCH }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
uses: peter-evans/create-pull-request@v6.0.1
with:
branch: ${{ env.HEAD_BRANCH }}
base: ${{env.FEATURE_BRANCH}}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create-PR-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
toBranch: ${{matrix.branch_name}}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
uses: peter-evans/create-pull-request@v6.0.1
with:
labels: automated PR
delete-branch: true
Expand Down
20 changes: 14 additions & 6 deletions script/BaseMigration.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ abstract contract BaseMigration is ScriptExtended {
address proxyAdmin = _getProxyAdmin();
assertTrue(proxyAdmin != address(0x0), "BaseMigration: Null ProxyAdmin");

vm.broadcast(sender());
_prankOrBroadcast(sender());
deployed = payable(address(new Proxy(logic, proxyAdmin, args)));

// validate proxy admin
Expand Down Expand Up @@ -172,7 +172,7 @@ abstract contract BaseMigration is ScriptExtended {
returns (address payable deployed, uint256 nonce)
{
nonce = vm.getNonce(sender());
vm.broadcast(sender());
_prankOrBroadcast(sender());
deployed = payable(deployCode(filename, args));
}

Expand Down Expand Up @@ -265,7 +265,7 @@ abstract contract BaseMigration is ScriptExtended {

// if proxyAdmin is External Owned Wallet
if (proxyAdmin.code.length == 0) {
vm.broadcast(proxyAdmin);
_prankOrBroadcast(proxyAdmin);
if (args.length == 0) iProxy.upgradeTo(logic);
else iProxy.upgradeToAndCall(logic, args);
} else {
Expand All @@ -278,7 +278,7 @@ abstract contract BaseMigration is ScriptExtended {
if (owner.code.length != 0) {
_cheatUpgrade(owner, wProxyAdmin, iProxy, logic);
} else {
vm.broadcast(owner);
_prankOrBroadcast(owner);
wProxyAdmin.upgrade(iProxy, logic);
}
} else {
Expand All @@ -288,15 +288,15 @@ abstract contract BaseMigration is ScriptExtended {
if (owner.code.length != 0) {
_cheatUpgradeAndCall(owner, wProxyAdmin, iProxy, logic, args);
} else {
vm.broadcast(owner);
_prankOrBroadcast(owner);
wProxyAdmin.upgradeAndCall(iProxy, logic, args);
}
}
} else {
if (owner.code.length != 0) {
_cheatUpgradeAndCall(owner, wProxyAdmin, iProxy, logic, args);
} else {
vm.broadcast(owner);
_prankOrBroadcast(owner);
wProxyAdmin.upgradeAndCall(iProxy, logic, args);
}
}
Expand Down Expand Up @@ -402,6 +402,14 @@ abstract contract BaseMigration is ScriptExtended {
wProxyAdmin.upgradeAndCall(iProxy, logic, args);
}

function _prankOrBroadcast(address to) internal virtual {
if (CONFIG.isPostChecking()) {
vm.prank(to);
} else {
vm.broadcast(to);
}
}

function _setDependencyDeployScript(TContract contractType, IScriptExtended deployScript) internal virtual {
_deployScript[contractType] = IMigrationScript(address(deployScript));
}
Expand Down
1 change: 0 additions & 1 deletion script/extensions/ScriptExtended.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ abstract contract ScriptExtended is Script, StdAssertions, IScriptExtended {

bytes public constant EMPTY_ARGS = "";
IGeneralConfig public constant CONFIG = IGeneralConfig(LibSharedAddress.CONFIG);
bool internal _isPostChecking;

modifier logFn(string memory fnName) {
_logFn(fnName);
Expand Down

0 comments on commit 1e2d229

Please sign in to comment.