diff --git a/chainlib/eth/contract.py b/chainlib/eth/contract.py index a609334..87466c4 100644 --- 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 index 085c25a..f89d431 100644 --- 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 index 9c749fa..2e4c373 100644 --- 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__':