Skip to content

Commit

Permalink
feat: more future-proof
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickAlphaC committed Feb 3, 2025
1 parent 0486847 commit 924b6c9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
Expand Down
39 changes: 22 additions & 17 deletions src/FoundryZkSyncChecker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 924b6c9

Please sign in to comment.