Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Commit

Permalink
Update to Slither 0.6.7
Browse files Browse the repository at this point in the history
  • Loading branch information
tinchoabbate committed Oct 20, 2019
1 parent e03dbdf commit 97a7e13
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
27 changes: 24 additions & 3 deletions erc20/erc20.py
Expand Up @@ -38,6 +38,10 @@ def is_public(element):
"""Check if element's (Function or Event) visibility is public"""
return element.visibility == "public"

def is_interface(contract):
"""Check if contract is interface"""
return contract.contract_kind == "interface"


def verify_signatures(elements, expected_signatures):
"""
Expand Down Expand Up @@ -148,11 +152,26 @@ def get_visible_functions(functions):
Returns
-------
list
list(slither.core.declarations.Function)
"""
return [f for f in functions if is_visible(f)]


def get_implemented_functions(functions):
"""
Filters a list of functions, keeping those whose declaring contract is NOT an interface
Parameters
----------
functions : list(slither.core.declarations.Function)
Returns
-------
list(slither.core.declarations.Function)
"""
return [f for f in functions if not is_interface(f.contract_declarer)]


def is_event_call(obj):
"""Returns True if given object is an instance of Slither's EventCall class. False otherwise."""
return isinstance(obj, EventCall)
Expand Down Expand Up @@ -276,8 +295,10 @@ def run(filename, contract_name):
print("Either you mispelled the contract's name or solc cannot compile the contract.")
exit(-1)

# Obtain visible functions
visible_functions = get_visible_functions(contract.functions)
# Obtain all visible functions, filtering out any that comes from an interface contract
visible_functions = get_visible_functions(
get_implemented_functions(contract.functions)
)

erc20_fx_matches = verify_signatures(visible_functions, ERC20_FX_SIGNATURES)

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Expand Up @@ -2,4 +2,4 @@ crytic-compile==0.1.4
pkg-resources==0.0.0
prettytable==0.7.2
pysha3==1.0.2
slither-analyzer==0.6.4
slither-analyzer==0.6.7

0 comments on commit 97a7e13

Please sign in to comment.