commit 8374d830450a560430ce2c615172700c20440390
parent e39b91d433b1702070957c799544f0df3dd3e942
Author: nolash <dev@holbrook.no>
Date: Mon, 28 Jun 2021 09:10:53 +0200
Reinstate hex input in abi decode
Diffstat:
3 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/chainlib/eth/contract.py b/chainlib/eth/contract.py
@@ -77,7 +77,7 @@ class ABIMethodEncoder(ABIContract):
-class ABIContractDecoder:
+class ABIContractDecoder(ABIContract):
def typ(self, v):
@@ -137,7 +137,8 @@ class ABIContractDecoder:
m = getattr(self, self.types[i])
s = self.contents[i]
logg.debug('{} {} {} {} {}'.format(i, m, self.types[i], self.contents[i], s))
- r.append(m(s.hex()))
+ #r.append(m(s.hex()))
+ r.append(m(s))
return r
diff --git a/chainlib/eth/tx.py b/chainlib/eth/tx.py
@@ -117,7 +117,10 @@ def unpack_hex(tx_raw_bytes, chain_spec):
def __unpack_raw(tx_raw_bytes, chain_id=1):
- d = rlp_decode(tx_raw_bytes)
+ try:
+ d = rlp_decode(tx_raw_bytes)
+ except Exception as e:
+ raise ValueError('RLP deserialization failed: {}'.format(e))
logg.debug('decoding using chain id {}'.format(str(chain_id)))
diff --git a/tests/test_event.py b/tests/test_event.py
@@ -23,15 +23,15 @@ class TestContractLog(EthTesterCase):
n = 42
topics = [
s,
- n.to_bytes(32, byteorder='big'),
+ n.to_bytes(32, byteorder='big').hex(),
]
data = [
- (b'\xee' * 32),
+ (b'\xee' * 32).hex(),
]
dec.apply(topics, data)
o = dec.decode()
self.assertEqual(o[0], 42)
- self.assertEqual(o[1], data[0].hex())
+ self.assertEqual(o[1], data[0])
if __name__ == '__main__':