|
36 | 36 | ScaleObj, |
37 | 37 | ) |
38 | 38 | from async_substrate_interface.utils import hex_to_bytes, json |
| 39 | +from async_substrate_interface.utils.decoding import _determine_if_old_runtime_call |
39 | 40 | from async_substrate_interface.utils.storage import StorageKey |
40 | 41 | from async_substrate_interface.type_registry import _TYPE_REGISTRY |
41 | 42 |
|
@@ -2351,37 +2352,10 @@ def runtime_call( |
2351 | 2352 | except KeyError: |
2352 | 2353 | raise ValueError(f"Runtime API Call '{api}.{method}' not found in registry") |
2353 | 2354 |
|
2354 | | - # Check if the output type is a Vec<u8> |
2355 | | - # If so, call the API using the old method |
2356 | | - output_type_def = [ |
2357 | | - x |
2358 | | - for x in metadata_v15_value["types"]["types"] |
2359 | | - if x["id"] == runtime_call_def["output"] |
2360 | | - ] |
2361 | | - if output_type_def: |
2362 | | - output_type_def = output_type_def[0] |
2363 | | - |
2364 | | - if "sequence" in output_type_def["type"]["def"]: |
2365 | | - output_type_seq_def_id = output_type_def["type"]["def"]["sequence"][ |
2366 | | - "type" |
2367 | | - ] |
2368 | | - output_type_seq_def = [ |
2369 | | - x |
2370 | | - for x in metadata_v15_value["types"]["types"] |
2371 | | - if x["id"] == output_type_seq_def_id |
2372 | | - ] |
2373 | | - if output_type_seq_def: |
2374 | | - output_type_seq_def = output_type_seq_def[0] |
2375 | | - if ( |
2376 | | - "primitive" in output_type_seq_def["type"]["def"] |
2377 | | - and output_type_seq_def["type"]["def"]["primitive"] == "u8" |
2378 | | - ): |
2379 | | - # This is Vec<u8> |
2380 | | - result = self._do_runtime_call_old( |
2381 | | - api, method, params, block_hash |
2382 | | - ) |
| 2355 | + if _determine_if_old_runtime_call(runtime_call_def, metadata_v15_value): |
| 2356 | + result = self._do_runtime_call_old(api, method, params, block_hash) |
2383 | 2357 |
|
2384 | | - return result |
| 2358 | + return result |
2385 | 2359 |
|
2386 | 2360 | if isinstance(params, list) and len(params) != len(runtime_call_def["inputs"]): |
2387 | 2361 | raise ValueError( |
|
0 commit comments