Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --from option to vm.py, to generate Vm.sol from json file #619

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion scripts/vm.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down