From 924b6c9534e6b562fa37f751704e18acfae11f72 Mon Sep 17 00:00:00 2001 From: Patrick Collins <54278053+PatrickAlphaC@users.noreply.github.com> Date: Sun, 2 Feb 2025 22:41:18 -0500 Subject: [PATCH] feat: more future-proof --- README.md | 3 +++ src/FoundryZkSyncChecker.sol | 39 ++++++++++++++++++++---------------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 8659165..e802940 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,9 @@ It will look through your `broadcast` folder at your most recent deployment. ## Requirements +> [!IMPORTANT] +> As of `0.3.0`, nightly builds of foundry may not work as expected. Please use `foundryup -v stable` for the stable version of foundry. + - [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) - You'll know you did it right if you can run `git --version` and you see a response like `git version x.x.x` - [foundry](https://getfoundry.sh/) diff --git a/src/FoundryZkSyncChecker.sol b/src/FoundryZkSyncChecker.sol index fe4bc09..0d2c7fe 100644 --- a/src/FoundryZkSyncChecker.sol +++ b/src/FoundryZkSyncChecker.sol @@ -5,21 +5,26 @@ import {Test, console2} from "forge-std/Test.sol"; // We have to label it a test so foundry-zksync doesn't get confused abstract contract FoundryZkSyncChecker is Test { - // cast from-utf8 "forge 0.0.2" - bytes constant FORGE_VERSION_0_0_2 = hex"666f72676520302e302e32"; - // cast from-utf8 "forge 0.0.4" - bytes constant FORGE_VERSION_0_0_4 = hex"666f72676520302e302e34"; - // cast from-utf8 "forge 0.2.0" - bytes constant FORGE_VERSION_0_2_0 = hex"666f72676520302e322e30"; - // cast from-utf8 "forge 0.3.0" - bytes constant FORGE_VERSION_0_3_0 = hex"666f72676520302e332e30"; + // Old + // // cast from-utf8 "forge 0.0.2" + // bytes constant FORGE_VERSION_0_0_2 = hex"666f72676520302e302e32"; + // // cast from-utf8 "forge 0.0.4" + // bytes constant FORGE_VERSION_0_0_4 = hex"666f72676520302e302e34"; + + // cast from-utf8 "forge 0.0." + bytes constant FORGE_VERSION_0_0_ = hex"666f72676520302e302e"; + + // cast from-utf8 "forge 0.2." + bytes constant FORGE_VERSION_0_2_ = hex"666f72676520302e322e"; + // cast from-utf8 "forge 0.3." + bytes constant FORGE_VERSION_0_3_ = hex"666f72676520302e332e"; // cast from-utf8 "forge Version: 0.3" - bytes constant POST_THREE_FORGE_VERSION = hex"666f7267652056657273696f6e3a20302e33"; // forge Version: 0.3 + bytes constant POST_THREE_FORGE_VERSION = hex"666f7267652056657273696f6e3a20302e33"; // cast from-utf8 "forge Version: 1.0" - bytes constant STABLE_ONE_VERSION = hex"666f7267652056657273696f6e3a20312e30"; // forge Version: 1.0 + bytes constant STABLE_ONE_VERSION = hex"666f7267652056657273696f6e3a20312e30"; - uint256 constant PRIOR_TO_THREE_PREFIX_LENGTH = 11; + uint256 constant PRIOR_TO_THREE_PREFIX_LENGTH = 10; uint256 constant POST_THREE_PREFIX_LENGTH = 18; error FoundryZkSyncChecker__UnknownFoundryVersion(); @@ -60,18 +65,18 @@ abstract contract FoundryZkSyncChecker is Test { string memory forgePrefixedStr = string(forgeVersionPrefixed); console2.log("Got forge version:", forgePrefixedStr); + console2.logBytes32(bytes32(forgeVersionPrefixed)); + console2.logBytes32(bytes32(FORGE_VERSION_0_3_)); + if ( - bytes32(forgeVersionPrefixed) == bytes32(FORGE_VERSION_0_2_0) - || bytes32(forgeVersionPrefixed) == bytes32(FORGE_VERSION_0_3_0) + bytes32(forgeVersionPrefixed) == bytes32(FORGE_VERSION_0_2_) + || bytes32(forgeVersionPrefixed) == bytes32(FORGE_VERSION_0_3_) || bytes32(forgeVersionPrefixed) == bytes32(POST_THREE_FORGE_VERSION) || bytes32(forgeVersionPrefixed) == bytes32(STABLE_ONE_VERSION) ) { console2.log("This is Vanilla Foundry"); return false; - } else if ( - bytes32(forgeVersionPrefixed) == bytes32(FORGE_VERSION_0_0_2) - || bytes32(forgeVersionPrefixed) == bytes32(FORGE_VERSION_0_0_4) - ) { + } else if (bytes32(forgeVersionPrefixed) == bytes32(FORGE_VERSION_0_0_)) { console2.log("This is Foundry ZkSync"); return true; }