kopia lustrzana https://github.com/bugout-dev/moonworm
fix no constructor
rodzic
c4758f2eac
commit
d8322c2a39
|
|
@ -23,7 +23,8 @@ for abi_item in CONTRACT_ABI:
|
||||||
CONTRACT_FUNCTIONS[abi_item["name"]] = abi_item
|
CONTRACT_FUNCTIONS[abi_item["name"]] = abi_item
|
||||||
if abi_item["type"] == "constructor":
|
if abi_item["type"] == "constructor":
|
||||||
CONTRACT_FUNCTIONS["constructor"] = abi_item
|
CONTRACT_FUNCTIONS["constructor"] = abi_item
|
||||||
|
if CONTRACT_FUNCTIONS["constructor"] is None:
|
||||||
|
CONTRACT_FUNCTIONS["constructor"] = {{"inputs" : []}}
|
||||||
|
|
||||||
def init_web3(ipc_path: str) -> Web3:
|
def init_web3(ipc_path: str) -> Web3:
|
||||||
return Web3(web3.HTTPProvider(ipc_path))
|
return Web3(web3.HTTPProvider(ipc_path))
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,14 @@ def generate_contract_class(
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
contract_constructor = [c for c in abi if c["type"] == "constructor"][0]
|
contract_constructor = [c for c in abi if c["type"] == "constructor"]
|
||||||
|
if len(contract_constructor) == 1:
|
||||||
|
contract_constructor = contract_constructor[0]
|
||||||
|
elif len(contract_constructor) == 0:
|
||||||
|
contract_constructor = {"inputs": []}
|
||||||
|
else:
|
||||||
|
raise ValueError("Multiple constructors found in ABI")
|
||||||
|
|
||||||
contract_constructor["name"] = "constructor"
|
contract_constructor["name"] = "constructor"
|
||||||
class_functions = (
|
class_functions = (
|
||||||
[class_constructor]
|
[class_constructor]
|
||||||
|
|
@ -261,7 +268,14 @@ def generate_argument_parser_function(abi: List[Dict[str, Any]]) -> cst.Function
|
||||||
subparsers.extend(generate_function_subparser(function_abi, "description"))
|
subparsers.extend(generate_function_subparser(function_abi, "description"))
|
||||||
|
|
||||||
# Deploy argparser:
|
# Deploy argparser:
|
||||||
contract_constructor = [item for item in abi if item["type"] == "constructor"][0]
|
contract_constructor = [item for item in abi if item["type"] == "constructor"]
|
||||||
|
if len(contract_constructor) == 1:
|
||||||
|
contract_constructor = contract_constructor[0]
|
||||||
|
elif len(contract_constructor) == 0:
|
||||||
|
contract_constructor = {"inputs": []}
|
||||||
|
else:
|
||||||
|
raise Exception("Multiple constructors found")
|
||||||
|
|
||||||
deploy_argument_parsers = []
|
deploy_argument_parsers = []
|
||||||
default_arg_counter = 1
|
default_arg_counter = 1
|
||||||
for arg in contract_constructor["inputs"]:
|
for arg in contract_constructor["inputs"]:
|
||||||
|
|
|
||||||
Ładowanie…
Reference in New Issue