Skip to content

Commit

Permalink
Add [user] and [branch] args to vm.py, default to "foundry-rs" and "m…
Browse files Browse the repository at this point in the history
…aster" respectively
  • Loading branch information
Tudmotu committed Oct 4, 2024
1 parent 4e5f46a commit e427848
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions scripts/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import json
import re
import subprocess
import argparse
from enum import Enum as PyEnum
from typing import Callable
from urllib import request

VoidFn = Callable[[], None]

CHEATCODES_JSON_URL = "https://raw.githubusercontent.com/foundry-rs/foundry/master/crates/cheatcodes/assets/cheatcodes.json"

CHEATCODES_JSON_URL = "https://raw.githubusercontent.com/{user}/foundry/{branch}/crates/cheatcodes/assets/cheatcodes.json"
OUT_PATH = "src/Vm.sol"

VM_SAFE_DOC = """\
Expand All @@ -26,7 +28,14 @@


def main():
json_str = request.urlopen(CHEATCODES_JSON_URL).read().decode("utf-8")
parser = argparse.ArgumentParser(
prog="vm.py",
description="This script generates the Vm interface based on the cheatcodes json generated in Foundry")
parser.add_argument("user", default="foundry-rs", nargs="?", help="the Github user")
parser.add_argument("branch", default="master", nargs="?", help="the branch to use for reference")
args = parser.parse_args()
json_url = CHEATCODES_JSON_URL.format(user=args.user, branch=args.branch)
json_str = request.urlopen(json_url).read().decode("utf-8")
contract = Cheatcodes.from_json(json_str)

ccs = contract.cheatcodes
Expand Down

0 comments on commit e427848

Please sign in to comment.