From bdca73056ce6b16e10c3375b4447f47cc1dc610a Mon Sep 17 00:00:00 2001 From: Josselin Date: Mon, 7 Jan 2019 11:30:54 +0000 Subject: [PATCH] Improve subdenomination support --- .../expressions/expression_parsing.py | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/slither/solc_parsing/expressions/expression_parsing.py b/slither/solc_parsing/expressions/expression_parsing.py index c0ac0a1e28..1f79e8e758 100644 --- a/slither/solc_parsing/expressions/expression_parsing.py +++ b/slither/solc_parsing/expressions/expression_parsing.py @@ -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): """