From 7c11c84cf5744324ce8e3f710ac4980a7804868d Mon Sep 17 00:00:00 2001 From: Yotam Bar-On Date: Fri, 4 Oct 2024 22:23:48 +0300 Subject: [PATCH] Add `--from` option to vm.py, to generate Vm.sol from a local json file --- scripts/vm.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/vm.py b/scripts/vm.py index f0537db9..3cd047d3 100755 --- a/scripts/vm.py +++ b/scripts/vm.py @@ -1,10 +1,12 @@ #!/usr/bin/env python3 +import argparse import copy import json import re import subprocess from enum import Enum as PyEnum +from pathlib import Path from typing import Callable from urllib import request @@ -26,7 +28,16 @@ def main(): - json_str = request.urlopen(CHEATCODES_JSON_URL).read().decode("utf-8") + parser = argparse.ArgumentParser( + description="Generate Vm.sol based on the cheatcodes json created by Foundry") + parser.add_argument( + "--from", + metavar="PATH", + dest="path", + required=False, + help="path to a json file containing the Vm interface, as generated by Foundry") + args = parser.parse_args() + json_str = request.urlopen(CHEATCODES_JSON_URL).read().decode("utf-8") if args.path is None else Path(args.path).read_text() contract = Cheatcodes.from_json(json_str) ccs = contract.cheatcodes