Skip to content

Commit a1c4d62

Browse files
authored
Merge pull request #49 from axieinfinity/feature/refactor
feat: allow backward compatible with forge ca67d15 and minor refactor
2 parents 60c6a1b + fcd8e42 commit a1c4d62

File tree

6 files changed

+27
-44
lines changed

6 files changed

+27
-44
lines changed

script/SignUtil.s.sol

Lines changed: 0 additions & 35 deletions
This file was deleted.

script/configs/ContractConfig.sol

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,27 @@ abstract contract ContractConfig is IContractConfig {
125125
}
126126

127127
function _storeDeploymentData(string memory deploymentRoot) internal virtual {
128-
if (!vm.exists(deploymentRoot)) {
128+
VmSafe.DirEntry[] memory deployments;
129+
try vm.exists(deploymentRoot) returns (bool exists) {
130+
if (!exists) {
131+
console.log("ContractConfig:", "No deployments folder, skip loading");
132+
return;
133+
}
134+
} catch {
135+
try vm.readDir(deploymentRoot) returns (VmSafe.DirEntry[] memory res) {
136+
deployments = res;
137+
} catch {
138+
console.log("ContractConfig:", "No deployments folder, skip loading");
139+
return;
140+
}
141+
}
142+
143+
try vm.readDir(deploymentRoot) returns (VmSafe.DirEntry[] memory res) {
144+
deployments = res;
145+
} catch {
129146
console.log("ContractConfig:", "No deployments folder, skip loading");
130147
return;
131148
}
132-
VmSafe.DirEntry[] memory deployments = vm.readDir(deploymentRoot);
133149

134150
for (uint256 i; i < deployments.length;) {
135151
VmSafe.DirEntry[] memory entries = vm.readDir(deployments[i].path);

script/extensions/ScriptExtended.s.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ abstract contract ScriptExtended is Script, StdAssertions, IScriptExtended {
2727
}
2828

2929
modifier onNetwork(TNetwork networkType) {
30-
TNetwork currentNetwork = _before(networkType);
30+
TNetwork currentNetwork = _switchTo(networkType);
3131
_;
32-
_after(currentNetwork);
32+
_swichBack(currentNetwork);
3333
}
3434

3535
function setUp() public virtual {
@@ -101,13 +101,13 @@ abstract contract ScriptExtended is Script, StdAssertions, IScriptExtended {
101101
require(network() == networkType, string.concat("ScriptExtended: Only allowed on ", CONFIG.getAlias(networkType)));
102102
}
103103

104-
function _before(TNetwork networkType) private returns (TNetwork currentNetwork) {
104+
function _switchTo(TNetwork networkType) private returns (TNetwork currentNetwork) {
105105
currentNetwork = network();
106106
CONFIG.createFork(networkType);
107107
CONFIG.switchTo(networkType);
108108
}
109109

110-
function _after(TNetwork currentNetwork) private {
110+
function _swichBack(TNetwork currentNetwork) private {
111111
CONFIG.switchTo(currentNetwork);
112112
}
113113
}

script/utils/DefaultContract.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ pragma solidity ^0.8.19;
44
import { LibString } from "../../lib/solady/src/utils/LibString.sol";
55
import { TContract } from "../types/Types.sol";
66

7-
enum DefaultContract { ProxyAdmin }
7+
enum DefaultContract {
8+
ProxyAdmin
9+
}
810

911
using { key, name } for DefaultContract global;
1012

0 commit comments

Comments
 (0)