diff --git a/lib/forge-std b/lib/forge-std index 2f11269..87a2a0a 160000 --- a/lib/forge-std +++ b/lib/forge-std @@ -1 +1 @@ -Subproject commit 2f112697506eab12d433a65fdc31a639548fe365 +Subproject commit 87a2a0afc5fafd6297538a45a52ac19e71a84562 diff --git a/lib/solady b/lib/solady index acab902..d457831 160000 --- a/lib/solady +++ b/lib/solady @@ -1 +1 @@ -Subproject commit acab9022c6472a578134d3dd7e7b38efa61df871 +Subproject commit d457831578c0714d648ef19b599f9d7172113816 diff --git a/script/SignUtil.s.sol b/script/SignUtil.s.sol deleted file mode 100644 index 1e281bd..0000000 --- a/script/SignUtil.s.sol +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.19; - -import { ECDSA } from "../lib/openzeppelin-contracts/contracts/utils/cryptography/ECDSA.sol"; -import { LibSig } from "./libraries/LibSig.sol"; -import { Script } from "../lib/forge-std/src/Script.sol"; -import { LibString } from "../lib/solady/src/utils/LibString.sol"; -import { BaseGeneralConfig } from "./BaseGeneralConfig.sol"; -import { console, BaseMigration } from "./BaseMigration.s.sol"; - -contract SignUtil is Script { - function run() external { - uint256 pk = vm.envUint("TESTNET_PK"); - console.log("sender", vm.rememberKey(vm.envUint("TESTNET_PK"))); - - string memory signData = "hello"; - bytes32 digest = ECDSA.toEthSignedMessageHash(bytes(signData)); - - (uint8 v, bytes32 r, bytes32 s) = vm.sign(pk, digest); - bytes memory vmSig = LibSig.merge(v, r, s); - - string[] memory commandInput = new string[](6); - commandInput[0] = "cast"; - commandInput[1] = "wallet"; - commandInput[2] = "sign"; - commandInput[3] = "--private-key"; - commandInput[4] = LibString.toHexString(pk); - commandInput[5] = signData; - bytes memory castSig = vm.ffi(commandInput); - - console.log("pk", LibString.toHexString(pk)); - console.log("vmSig", vm.toString(vmSig)); - console.log("castSig", vm.toString(castSig)); - } -} diff --git a/script/configs/ContractConfig.sol b/script/configs/ContractConfig.sol index 2c3a47a..b624ccb 100644 --- a/script/configs/ContractConfig.sol +++ b/script/configs/ContractConfig.sol @@ -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); diff --git a/script/extensions/ScriptExtended.s.sol b/script/extensions/ScriptExtended.s.sol index 4b9029e..09cf1c4 100644 --- a/script/extensions/ScriptExtended.s.sol +++ b/script/extensions/ScriptExtended.s.sol @@ -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 { @@ -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); } } diff --git a/script/utils/DefaultContract.sol b/script/utils/DefaultContract.sol index dcdb822..d5af465 100644 --- a/script/utils/DefaultContract.sol +++ b/script/utils/DefaultContract.sol @@ -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;