Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions async_substrate_interface/utils/decoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,14 @@ def concat_hash_len(key_hasher: str) -> int:
if decode_ss58:
if kts[kts.index(", ") + 2 : kts.index(")")] == "scale_info::0":
item_key = ss58_encode(bytes(item_key[0]), runtime.ss58_format)

else:
item_key = tuple(
dk[key + 1] for key in range(len(params), len(param_types) + 1, 2)
)
try:
item_key = tuple(
dk[key + 1]
for key in range(len(params), len(param_types) + 1, 2)
)
except IndexError:
item_key = dk

except Exception as _:
if not ignore_decoding_errors:
Expand Down
13 changes: 13 additions & 0 deletions tests/integration_tests/test_async_substrate_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,16 @@ async def test_reconnection():
bh = await substrate.get_chain_finalised_head()
assert isinstance(bh, str)
assert isinstance(await substrate.get_block_number(bh), int)


@pytest.mark.asyncio
async def test_query_map_with_odd_number_of_params():
async with AsyncSubstrateInterface(ARCHIVE_ENTRYPOINT, ss58_format=42) as substrate:
qm = await substrate.query_map(
"SubtensorModule",
"Alpha",
["5CoZxgtfhcJKX2HmkwnsN18KbaT9aih9eF3b6qVPTgAUbifj"],
)
first_record = qm.records[0]
assert len(first_record) == 2
assert len(first_record[0]) == 4
12 changes: 12 additions & 0 deletions tests/integration_tests/test_substrate_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,15 @@ def test_query_multiple():
storage_function="OwnedHotkeys",
block_hash=block_hash,
)


def test_query_map_with_odd_number_of_params():
with SubstrateInterface(LATENT_LITE_ENTRYPOINT, ss58_format=42) as substrate:
qm = substrate.query_map(
"SubtensorModule",
"Alpha",
["5CoZxgtfhcJKX2HmkwnsN18KbaT9aih9eF3b6qVPTgAUbifj"],
)
first_record = qm.records[0]
assert len(first_record) == 2
assert len(first_record[0]) == 4
Loading