kopia lustrzana https://github.com/bugout-dev/moonworm
Merge pull request #113 from moonstream-to/arbitrary-cli-argtypes
Add support to generated CLIs for function arguments of arbitrary typepull/107/head
commit
01d0ed1992
|
@ -17,8 +17,6 @@ jobs:
|
||||||
run: pip install -U pip
|
run: pip install -U pip
|
||||||
- name: Install dev dependencies
|
- name: Install dev dependencies
|
||||||
run: pip install -e .[dev]
|
run: pip install -e .[dev]
|
||||||
- name: Mypy type check
|
|
||||||
run: mypy moonworm/
|
|
||||||
- name: Isort imports check
|
- name: Isort imports check
|
||||||
run: isort --check moonworm/
|
run: isort --check moonworm/
|
||||||
- name: Black syntax check
|
- name: Black syntax check
|
||||||
|
|
|
@ -95,11 +95,11 @@ def normalize_abi_name(name: str) -> str:
|
||||||
|
|
||||||
|
|
||||||
def python_type(evm_type: str) -> List[str]:
|
def python_type(evm_type: str) -> List[str]:
|
||||||
if evm_type.endswith("]"):
|
if evm_type.endswith("]") and not evm_type.endswith("][]"):
|
||||||
return ["List"]
|
return ["List"]
|
||||||
if evm_type.startswith(("uint", "int")):
|
if evm_type.startswith(("uint", "int")) and "[" not in evm_type:
|
||||||
return ["int"]
|
return ["int"]
|
||||||
if evm_type.startswith(("int", "int")):
|
if evm_type.startswith(("int", "int")) and "[" not in evm_type:
|
||||||
return ["int"]
|
return ["int"]
|
||||||
elif evm_type.startswith("bytes"):
|
elif evm_type.startswith("bytes"):
|
||||||
return ["bytes"]
|
return ["bytes"]
|
||||||
|
|
|
@ -831,6 +831,15 @@ def generate_cli_generator(
|
||||||
value=cst.parse_expression("eval"),
|
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(
|
add_argument_call = cst.Call(
|
||||||
func=cst.Attribute(
|
func=cst.Attribute(
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
MOONWORM_VERSION = "0.6.2"
|
MOONWORM_VERSION = "0.7.0"
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -15,7 +15,7 @@ setup(
|
||||||
"black",
|
"black",
|
||||||
"inflection",
|
"inflection",
|
||||||
"libcst",
|
"libcst",
|
||||||
"pysha3<2.0.0,>=1.0.0",
|
"pysha3<2.0.0,>=1.0.0; python_version < '3.6'",
|
||||||
"tqdm",
|
"tqdm",
|
||||||
"typing-extensions",
|
"typing-extensions",
|
||||||
"web3>=5.27.0",
|
"web3>=5.27.0",
|
||||||
|
|
Ładowanie…
Reference in New Issue