Skip to content

Commit 9d8086e

Browse files
authored
Merge pull request #19 from opentensor/feat/thewhaleking/fix-decode-scale
Fix decode scale
2 parents 7203256 + 2f67746 commit 9d8086e

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

async_substrate_interface/async_substrate.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -869,12 +869,13 @@ async def decode_scale(
869869
"""
870870
if scale_bytes == b"\x00":
871871
obj = None
872-
if type_string == "scale_info::0": # Is an AccountId
873-
# Decode AccountId bytes to SS58 address
874-
return bytes.fromhex(ss58_decode(scale_bytes, SS58_FORMAT))
875872
else:
876-
await self._wait_for_registry(_attempt, _retries)
877-
obj = decode_by_type_string(type_string, self.registry, scale_bytes)
873+
if type_string == "scale_info::0": # Is an AccountId
874+
# Decode AccountId bytes to SS58 address
875+
return bytes.fromhex(ss58_decode(scale_bytes, SS58_FORMAT))
876+
else:
877+
await self._wait_for_registry(_attempt, _retries)
878+
obj = decode_by_type_string(type_string, self.registry, scale_bytes)
878879
if return_scale_obj:
879880
return ScaleObj(obj)
880881
else:

async_substrate_interface/sync_substrate.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -615,11 +615,12 @@ def decode_scale(
615615

616616
if scale_bytes == b"\x00":
617617
obj = None
618-
if type_string == "scale_info::0": # Is an AccountId
619-
# Decode AccountId bytes to SS58 address
620-
return bytes.fromhex(ss58_decode(scale_bytes, SS58_FORMAT))
621618
else:
622-
obj = decode_by_type_string(type_string, self.registry, scale_bytes)
619+
if type_string == "scale_info::0": # Is an AccountId
620+
# Decode AccountId bytes to SS58 address
621+
return bytes.fromhex(ss58_decode(scale_bytes, SS58_FORMAT))
622+
else:
623+
obj = decode_by_type_string(type_string, self.registry, scale_bytes)
623624
if return_scale_obj:
624625
return ScaleObj(obj)
625626
else:

0 commit comments

Comments
 (0)