Skip to content

Commit

Permalink
Merge pull request #49 from axieinfinity/feature/refactor
Browse files Browse the repository at this point in the history
feat: allow backward compatible with forge ca67d15 and minor refactor
  • Loading branch information
TuDo1403 authored Dec 28, 2023
2 parents 60c6a1b + fcd8e42 commit a1c4d62
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 44 deletions.
2 changes: 1 addition & 1 deletion lib/forge-std
35 changes: 0 additions & 35 deletions script/SignUtil.s.sol

This file was deleted.

20 changes: 18 additions & 2 deletions script/configs/ContractConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,27 @@ abstract contract ContractConfig is IContractConfig {
}

function _storeDeploymentData(string memory deploymentRoot) internal virtual {
if (!vm.exists(deploymentRoot)) {
VmSafe.DirEntry[] memory deployments;
try vm.exists(deploymentRoot) returns (bool exists) {
if (!exists) {
console.log("ContractConfig:", "No deployments folder, skip loading");
return;
}
} catch {
try vm.readDir(deploymentRoot) returns (VmSafe.DirEntry[] memory res) {
deployments = res;
} catch {
console.log("ContractConfig:", "No deployments folder, skip loading");
return;
}
}

try vm.readDir(deploymentRoot) returns (VmSafe.DirEntry[] memory res) {
deployments = res;
} catch {
console.log("ContractConfig:", "No deployments folder, skip loading");
return;
}
VmSafe.DirEntry[] memory deployments = vm.readDir(deploymentRoot);

for (uint256 i; i < deployments.length;) {
VmSafe.DirEntry[] memory entries = vm.readDir(deployments[i].path);
Expand Down
8 changes: 4 additions & 4 deletions script/extensions/ScriptExtended.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ abstract contract ScriptExtended is Script, StdAssertions, IScriptExtended {
}

modifier onNetwork(TNetwork networkType) {
TNetwork currentNetwork = _before(networkType);
TNetwork currentNetwork = _switchTo(networkType);
_;
_after(currentNetwork);
_swichBack(currentNetwork);
}

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

function _before(TNetwork networkType) private returns (TNetwork currentNetwork) {
function _switchTo(TNetwork networkType) private returns (TNetwork currentNetwork) {
currentNetwork = network();
CONFIG.createFork(networkType);
CONFIG.switchTo(networkType);
}

function _after(TNetwork currentNetwork) private {
function _swichBack(TNetwork currentNetwork) private {
CONFIG.switchTo(currentNetwork);
}
}
4 changes: 3 additions & 1 deletion script/utils/DefaultContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ pragma solidity ^0.8.19;
import { LibString } from "../../lib/solady/src/utils/LibString.sol";
import { TContract } from "../types/Types.sol";

enum DefaultContract { ProxyAdmin }
enum DefaultContract {
ProxyAdmin
}

using { key, name } for DefaultContract global;

Expand Down

0 comments on commit a1c4d62

Please sign in to comment.