Merge pull request #211 from crytic/dev-functionid-fix

Fix functionid printer to account for some getters taking input
pull/216/head
Feist Josselin 6 years ago committed by GitHub
commit 04c147f7e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      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,18 @@ 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:
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
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)

Loading…
Cancel
Save