Skip to content

Commit

Permalink
Improve subdenomination support
Browse files Browse the repository at this point in the history
  • Loading branch information
montyly committed Jan 7, 2019
1 parent 0dc548a commit bdca730
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions slither/solc_parsing/expressions/expression_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,30 +240,31 @@ def filter_name(value):
def convert_subdenomination(value, sub):
if sub is None:
return value
value = int(value)
# to allow 0.1 ether conversion
value = float(value)
if sub == 'wei':
return value
return int(value)
if sub == 'szabo':
return value * int(1e12)
return int(value * int(1e12))
if sub == 'finney':
return value * int(1e15)
return int(value * int(1e15))
if sub == 'ether':
return value * int(1e18)
return int(value * int(1e18))
if sub == 'seconds':
return value
return int(value)
if sub == 'minutes':
return value * 60
return int(value * 60)
if sub == 'hours':
return value * 60 * 60
return int(value * 60 * 60)
if sub == 'days':
return value * 60 * 60 * 24
return int(value * 60 * 60 * 24)
if sub == 'weeks':
return value * 60 * 60 * 24 * 7
return int(value * 60 * 60 * 24 * 7)
if sub == 'years':
return value * 60 * 60 * 24 * 7 * 365
return int(value * 60 * 60 * 24 * 7 * 365)

logger.error('Subdemoniation not found {}'.format(sub))
return value
return int(value)

def parse_expression(expression, caller_context):
"""
Expand Down

0 comments on commit bdca730

Please sign in to comment.