Skip to content

Commit aab122e

Browse files
authored
Merge pull request #456 from sfsf9797/fix-datatype
Fix datatype
2 parents 8410140 + 438c9af commit aab122e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

ethereumetl/mappers/receipt_mapper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
from ethereumetl.domain.receipt import EthReceipt
2525
from ethereumetl.mappers.receipt_log_mapper import EthReceiptLogMapper
26-
from ethereumetl.utils import hex_to_dec, to_normalized_address
26+
from ethereumetl.utils import hex_to_dec, to_normalized_address, to_float_or_none
2727

2828

2929
class EthReceiptMapper(object):
@@ -53,7 +53,7 @@ def json_dict_to_receipt(self, json_dict):
5353
receipt.l1_fee = hex_to_dec(json_dict.get('l1Fee'))
5454
receipt.l1_gas_used = hex_to_dec(json_dict.get('l1GasUsed'))
5555
receipt.l1_gas_price = hex_to_dec(json_dict.get('l1GasPrice'))
56-
receipt.l1_fee_scalar = hex_to_dec(json_dict.get('l1FeeScalar'))
56+
receipt.l1_fee_scalar = to_float_or_none(json_dict.get('l1FeeScalar'))
5757

5858

5959
if 'logs' in json_dict:

ethereumetl/utils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ def to_int_or_none(val):
4747
except ValueError:
4848
return None
4949

50+
def to_float_or_none(val):
51+
if isinstance(val, float):
52+
return val
53+
if val is None or val == "":
54+
return None
55+
try:
56+
return float(val)
57+
except ValueError:
58+
print("can't cast %s to float" % val)
59+
return val
5060

5161
def chunk_string(string, length):
5262
return (string[0 + i:length + i] for i in range(0, len(string), length))

0 commit comments

Comments
 (0)