Skip to content

Commit be318fd

Browse files
committed
More backwards compat
1 parent 7de0b38 commit be318fd

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

async_substrate_interface/async_substrate.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,16 +281,17 @@ async def process_events(self):
281281
self.__weight = dispatch_info["weight"]
282282

283283
if "Module" in dispatch_error:
284-
module_index = dispatch_error["Module"]["index"]
285-
error_index = int.from_bytes(
286-
bytes(dispatch_error["Module"]["error"]),
287-
byteorder="little",
288-
signed=False,
289-
)
284+
if isinstance(dispatch_error["Module"], tuple):
285+
module_index = dispatch_error["Module"][0]
286+
error_index = dispatch_error["Module"][1]
287+
else:
288+
module_index = dispatch_error["Module"]["index"]
289+
error_index = dispatch_error["Module"]["error"]
290290

291291
if isinstance(error_index, str):
292292
# Actual error index is first u8 in new [u8; 4] format
293293
error_index = int(error_index[2:4], 16)
294+
294295
if self.block_hash:
295296
runtime = await self.substrate.init_runtime(
296297
block_hash=self.block_hash

async_substrate_interface/sync_substrate.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,16 +256,17 @@ def process_events(self):
256256
self.__weight = dispatch_info["weight"]
257257

258258
if "Module" in dispatch_error:
259-
module_index = dispatch_error["Module"]["index"]
260-
error_index = int.from_bytes(
261-
bytes(dispatch_error["Module"]["error"]),
262-
byteorder="little",
263-
signed=False,
264-
)
259+
if isinstance(dispatch_error["Module"], tuple):
260+
module_index = dispatch_error["Module"][0]
261+
error_index = dispatch_error["Module"][1]
262+
else:
263+
module_index = dispatch_error["Module"]["index"]
264+
error_index = dispatch_error["Module"]["error"]
265265

266266
if isinstance(error_index, str):
267267
# Actual error index is first u8 in new [u8; 4] format
268268
error_index = int(error_index[2:4], 16)
269+
269270
module_error = self.substrate.metadata.get_module_error(
270271
module_index=module_index, error_index=error_index
271272
)

0 commit comments

Comments
 (0)