Skip to content

Commit 35cb98d

Browse files
authored
Merge pull request #52 from opentensor/feat/thewhaleking/handle-options
Handle options with bt-decode
2 parents 26b64ac + 68a2995 commit 35cb98d

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

async_substrate_interface/async_substrate.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -892,15 +892,12 @@ async def decode_scale(
892892
Returns:
893893
Decoded object
894894
"""
895-
if scale_bytes == b"\x00":
896-
obj = None
895+
if type_string == "scale_info::0": # Is an AccountId
896+
# Decode AccountId bytes to SS58 address
897+
return ss58_encode(scale_bytes, SS58_FORMAT)
897898
else:
898-
if type_string == "scale_info::0": # Is an AccountId
899-
# Decode AccountId bytes to SS58 address
900-
return ss58_encode(scale_bytes, SS58_FORMAT)
901-
else:
902-
await self._wait_for_registry(_attempt, _retries)
903-
obj = decode_by_type_string(type_string, self.registry, scale_bytes)
899+
await self._wait_for_registry(_attempt, _retries)
900+
obj = decode_by_type_string(type_string, self.registry, scale_bytes)
904901
if return_scale_obj:
905902
return ScaleObj(obj)
906903
else:

async_substrate_interface/sync_substrate.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -652,15 +652,11 @@ def decode_scale(
652652
Returns:
653653
Decoded object
654654
"""
655-
656-
if scale_bytes == b"\x00":
657-
obj = None
655+
if type_string == "scale_info::0": # Is an AccountId
656+
# Decode AccountId bytes to SS58 address
657+
return ss58_encode(scale_bytes, SS58_FORMAT)
658658
else:
659-
if type_string == "scale_info::0": # Is an AccountId
660-
# Decode AccountId bytes to SS58 address
661-
return ss58_encode(scale_bytes, SS58_FORMAT)
662-
else:
663-
obj = decode_by_type_string(type_string, self.registry, scale_bytes)
659+
obj = decode_by_type_string(type_string, self.registry, scale_bytes)
664660
if return_scale_obj:
665661
return ScaleObj(obj)
666662
else:

0 commit comments

Comments
 (0)