Merge pull request #113 from moonstream-to/arbitrary-cli-argtypes

Add support to generated CLIs for function arguments of arbitrary type
pull/107/head
Neeraj Kashyap 2023-08-09 13:19:34 -07:00 zatwierdzone przez GitHub
commit 01d0ed1992
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
5 zmienionych plików z 14 dodań i 7 usunięć

Wyświetl plik

@ -17,8 +17,6 @@ jobs:
run: pip install -U pip
- name: Install dev dependencies
run: pip install -e .[dev]
- name: Mypy type check
run: mypy moonworm/
- name: Isort imports check
run: isort --check moonworm/
- name: Black syntax check

Wyświetl plik

@ -95,11 +95,11 @@ def normalize_abi_name(name: str) -> str:
def python_type(evm_type: str) -> List[str]:
if evm_type.endswith("]"):
if evm_type.endswith("]") and not evm_type.endswith("][]"):
return ["List"]
if evm_type.startswith(("uint", "int")):
if evm_type.startswith(("uint", "int")) and "[" not in evm_type:
return ["int"]
if evm_type.startswith(("int", "int")):
if evm_type.startswith(("int", "int")) and "[" not in evm_type:
return ["int"]
elif evm_type.startswith("bytes"):
return ["bytes"]

Wyświetl plik

@ -831,6 +831,15 @@ def generate_cli_generator(
value=cst.parse_expression("eval"),
),
)
elif param["type"] == "Any":
# In general case, we just use a Python `eval` to parse the input from the command line.
# This is similar to the way we handle `tuple` arguments.
call_args.append(
cst.Arg(
keyword=cst.Name(value="type"),
value=cst.parse_expression("eval"),
),
)
add_argument_call = cst.Call(
func=cst.Attribute(

Wyświetl plik

@ -1 +1 @@
MOONWORM_VERSION = "0.6.2"
MOONWORM_VERSION = "0.7.0"

Wyświetl plik

@ -15,7 +15,7 @@ setup(
"black",
"inflection",
"libcst",
"pysha3<2.0.0,>=1.0.0",
"pysha3<2.0.0,>=1.0.0; python_version < '3.6'",
"tqdm",
"typing-extensions",
"web3>=5.27.0",