From 601ab0894787f9e344b885539481c402e1d400a7 Mon Sep 17 00:00:00 2001
From: angdmz <agustindorda@gmail.com>
Date: Fri, 19 Jul 2019 19:23:05 -0300
Subject: [PATCH] hexbyte dict decoder

---
 gateway/utils.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/gateway/utils.py b/gateway/utils.py
index f81b8a6..c3d2d22 100644
--- a/gateway/utils.py
+++ b/gateway/utils.py
@@ -36,3 +36,20 @@ def hex32bytes_string(some_hex32bytes):
         return Web3.toText(some_hex32bytes.decode().strip('\\\u0000'))
     except UnicodeDecodeError as ude:
         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
-- 
GitLab