Reinstate hex input in abi decode

This commit is contained in:
nolash 2021-06-28 09:10:53 +02:00
parent e39b91d433
commit 8374d83045
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
3 changed files with 10 additions and 6 deletions

View File

@ -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

View File

@ -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)))

View File

@ -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__':