From d9d960fa9cb1a43ac1e5672b0443cac8a79ac441 Mon Sep 17 00:00:00 2001 From: David Pokora Date: Thu, 25 Apr 2019 15:27:18 -0400 Subject: [PATCH 1/2] Fix functionid printer to account for getters having parameters (key is input in mappings, uint256 index is input for arrays). --- slither/printers/summary/function_ids.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/slither/printers/summary/function_ids.py b/slither/printers/summary/function_ids.py index d8f71f08f..1c093d7c4 100644 --- a/slither/printers/summary/function_ids.py +++ b/slither/printers/summary/function_ids.py @@ -3,6 +3,8 @@ """ import collections from prettytable import PrettyTable + +from slither.core.solidity_types import ArrayType, MappingType from slither.printers.abstract_printer import AbstractPrinter from slither.utils.colors import blue, green, magenta from slither.utils.function import get_function_id @@ -30,7 +32,13 @@ class FunctionIds(AbstractPrinter): table.add_row([function.full_name, hex(get_function_id(function.full_name))]) for variable in contract.state_variables: if variable.visibility in ['public']: - table.add_row([variable.name+'()', hex(get_function_id(variable.name+'()'))]) + variable_getter_args = "" + if type(variable.type) is ArrayType: + variable_getter_args = "uint256" + elif type(variable.type) is MappingType: + variable_getter_args = variable.type.type_from + + table.add_row([f"{variable.name}({variable_getter_args})", hex(get_function_id(f"{variable.name}({variable_getter_args})"))]) txt += str(table) + '\n' self.info(txt) From e66db801a29962ee556982592b3f63f8ed86202e Mon Sep 17 00:00:00 2001 From: Josselin Date: Fri, 26 Apr 2019 19:16:42 +0100 Subject: [PATCH 2/2] function-ids printer: fix incorrect type in case of multi-dim arrays --- slither/printers/summary/function_ids.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/slither/printers/summary/function_ids.py b/slither/printers/summary/function_ids.py index 1c093d7c4..169a2a318 100644 --- a/slither/printers/summary/function_ids.py +++ b/slither/printers/summary/function_ids.py @@ -34,7 +34,12 @@ class FunctionIds(AbstractPrinter): if variable.visibility in ['public']: variable_getter_args = "" if type(variable.type) is ArrayType: - variable_getter_args = "uint256" + length = 0 + v = variable + while type(v.type) is ArrayType: + length += 1 + v = v.type + variable_getter_args = ','.join(["uint256"]*length) elif type(variable.type) is MappingType: variable_getter_args = variable.type.type_from