Add `Contract.generate_interface`

pull/1730/head
webthethird 2 years ago
parent 4da0fb5110
commit 6a2250f60d
  1. 14
      slither/core/declarations/contract.py

@ -953,6 +953,20 @@ class Contract(SourceMapping): # pylint: disable=too-many-public-methods
""" """
return all((not f.is_implemented) for f in self.functions) return all((not f.is_implemented) for f in self.functions)
def generate_interface(self) -> str:
interface = f"interface I{self.name} {{\n"
for struct in self.structures:
interface += struct.interface_def_str()
for var in self.state_variables_entry_points:
interface += (
f" function {var.signature_str.replace('returns', 'external returns ')};\n"
)
for func in self.functions_entry_points:
if func.is_constructor or func.is_fallback or func.is_receive:
continue
interface += f" function {func.interface_signature_str};\n"
return interface
# endregion # endregion
################################################################################### ###################################################################################
################################################################################### ###################################################################################

Loading…
Cancel
Save