|
|
@ -1,7 +1,7 @@ |
|
|
|
""" |
|
|
|
""" |
|
|
|
Module printing summary of the contract |
|
|
|
Module printing summary of the contract |
|
|
|
""" |
|
|
|
""" |
|
|
|
|
|
|
|
import collections |
|
|
|
from slither.printers.abstract_printer import AbstractPrinter |
|
|
|
from slither.printers.abstract_printer import AbstractPrinter |
|
|
|
from slither.utils.colors import blue, green, magenta |
|
|
|
from slither.utils.colors import blue, green, magenta |
|
|
|
|
|
|
|
|
|
|
@ -21,12 +21,29 @@ class ContractSummary(AbstractPrinter): |
|
|
|
for c in self.contracts: |
|
|
|
for c in self.contracts: |
|
|
|
(name, _inheritance, _var, func_summaries, _modif_summaries) = c.get_summary() |
|
|
|
(name, _inheritance, _var, func_summaries, _modif_summaries) = c.get_summary() |
|
|
|
txt += blue("\n+ Contract %s\n"%name) |
|
|
|
txt += blue("\n+ Contract %s\n"%name) |
|
|
|
for (f_name, visi, _, _, _, _, _) in func_summaries: |
|
|
|
# (c_name, f_name, visi, _, _, _, _, _) in func_summaries |
|
|
|
txt += " - " |
|
|
|
public = [(elem[0], (elem[1], elem[2]) ) for elem in func_summaries] |
|
|
|
if visi in ['external', 'public']: |
|
|
|
# private = [(elem[0], (elem[1], elem[2])) for elem in func_summaries if elem[2] in ['internal', 'private']] |
|
|
|
txt += green("%s (%s)\n"%(f_name, visi)) |
|
|
|
# should never happen |
|
|
|
elif visi in ['internal', 'private']: |
|
|
|
# other = [(elem[0], (elem[1], elem[2])) for elem in func_summaries if elem[2] not in ['external', 'public', 'internal', 'private']] |
|
|
|
txt += magenta("%s (%s)\n"%(f_name, visi)) |
|
|
|
# assert not other |
|
|
|
else: |
|
|
|
|
|
|
|
txt += "%s (%s)\n"%(f_name, visi) |
|
|
|
collect = collections.defaultdict(list) |
|
|
|
|
|
|
|
for a,b in public: |
|
|
|
|
|
|
|
collect[a].append(b) |
|
|
|
|
|
|
|
public = list(collect.items()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for contract, functions in public: |
|
|
|
|
|
|
|
txt += blue(" - From {}\n".format(contract)) |
|
|
|
|
|
|
|
functions = sorted(functions) |
|
|
|
|
|
|
|
for (function, visi) in functions: |
|
|
|
|
|
|
|
if visi in ['external', 'public']: |
|
|
|
|
|
|
|
txt += green(" - {} ({})\n".format(function, visi)) |
|
|
|
|
|
|
|
for (function, visi) in functions: |
|
|
|
|
|
|
|
if visi in ['internal', 'private']: |
|
|
|
|
|
|
|
txt += magenta(" - {} ({})\n".format(function, visi)) |
|
|
|
|
|
|
|
for (function, visi) in functions: |
|
|
|
|
|
|
|
if visi not in ['external', 'public', 'internal', 'private']: |
|
|
|
|
|
|
|
txt += " - {} ({})\n".format(function, visi) |
|
|
|
|
|
|
|
|
|
|
|
self.info(txt) |
|
|
|
self.info(txt) |
|
|
|