Skip to content
Snippets Groups Projects
Commit 601ab089 authored by angdmz's avatar angdmz
Browse files

hexbyte dict decoder

parent d583c394
No related branches found
No related tags found
No related merge requests found
...@@ -36,3 +36,20 @@ def hex32bytes_string(some_hex32bytes): ...@@ -36,3 +36,20 @@ def hex32bytes_string(some_hex32bytes):
return Web3.toText(some_hex32bytes.decode().strip('\\\u0000')) return Web3.toText(some_hex32bytes.decode().strip('\\\u0000'))
except UnicodeDecodeError as ude: except UnicodeDecodeError as ude:
return some_hex32bytes return some_hex32bytes
class HexBytesToDict:
def dehex_dict(self, dictionary):
for k, v in dictionary.items():
if isinstance(v, dict):
self.dehex_dict(dictionary[k])
elif isinstance(v, list):
self.dehex_list(dictionary[k])
elif isinstance(v, HexBytes):
dictionary[k] = v.hex()
def dehex_list(self, sequence):
i = 0
while i < len(sequence):
sequence[i] = sequence[i].decode()
i = i + 1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment