From 69e5b3e9bc38426e68aafc8c9463083ce1de77c3 Mon Sep 17 00:00:00 2001 From: tserg <8017125+tserg@users.noreply.github.com> Date: Thu, 26 Sep 2024 22:27:24 +0800 Subject: [PATCH] change signatures --- vyper/semantics/types/module.py | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/vyper/semantics/types/module.py b/vyper/semantics/types/module.py index fa95cb83fa..480aecde96 100644 --- a/vyper/semantics/types/module.py +++ b/vyper/semantics/types/module.py @@ -45,11 +45,10 @@ def __init__( functions: dict, events: dict, structs: dict, - constants: Optional[dict] = None, + constants: dict, ) -> None: validate_unique_method_ids(list(functions.values())) - constants = constants or {} public_constants = { k: varinfo for k, varinfo in constants.items() if varinfo.decl_node.is_public } @@ -171,8 +170,8 @@ def _from_lists( interface_name: str, decl_node: Optional[vy_ast.VyperNode], function_list: list[tuple[str, ContractFunctionT]], - event_list: list[tuple[str, EventT]], - struct_list: list[tuple[str, StructT]], + event_list: Optional[list[tuple[str, EventT]]] = None, + struct_list: Optional[list[tuple[str, StructT]]] = None, constant_list: Optional[list[tuple[str, VarInfo]]] = None, ) -> "InterfaceT": functions = {} @@ -199,13 +198,15 @@ def _mark_seen(name, item): _mark_seen(name, function) functions[name] = function - for name, event in event_list: - _mark_seen(name, event) - events[name] = event + if event_list: + for name, event in event_list: + _mark_seen(name, event) + events[name] = event - for name, struct in struct_list: - _mark_seen(name, struct) - structs[name] = struct + if struct_list: + for name, struct in struct_list: + _mark_seen(name, struct) + structs[name] = struct if constant_list: for name, constant in constant_list: @@ -239,8 +240,7 @@ def from_json_abi(cls, name: str, abi: dict) -> "InterfaceT": for item in [i for i in abi if i.get("type") == "event"]: events.append((item["name"], EventT.from_abi(item))) - structs: list = [] # no structs in json ABI (as of yet) - return cls._from_lists(name, None, functions, events, structs) + return cls._from_lists(name, None, functions, events) @classmethod def from_ModuleT(cls, module_t: "ModuleT") -> "InterfaceT": @@ -294,11 +294,7 @@ def from_InterfaceDef(cls, node: vy_ast.InterfaceDef) -> "InterfaceT": ) functions.append((func_ast.name, ContractFunctionT.from_InterfaceDef(func_ast))) - # no structs or events in InterfaceDefs - events: list = [] - structs: list = [] - - return cls._from_lists(node.name, node, functions, events, structs) + return cls._from_lists(node.name, node, functions) # Datatype to store all module information.