@@ -2547,6 +2547,7 @@ async def generate_signature_payload(
25472547 ) -> ScaleBytes :
25482548 # Retrieve genesis hash
25492549 genesis_hash = await self .get_block_hash (0 )
2550+ runtime = await self .init_runtime (block_hash = None )
25502551
25512552 if not era :
25522553 era = "00"
@@ -2556,7 +2557,7 @@ async def generate_signature_payload(
25562557 block_hash = genesis_hash
25572558 else :
25582559 # Determine mortality of extrinsic
2559- era_obj = self .runtime_config .create_scale_object ("Era" )
2560+ era_obj = runtime .runtime_config .create_scale_object ("Era" )
25602561
25612562 if isinstance (era , dict ) and "current" not in era and "phase" not in era :
25622563 raise ValueError (
@@ -2569,17 +2570,17 @@ async def generate_signature_payload(
25692570 )
25702571
25712572 # Create signature payload
2572- signature_payload = self .runtime_config .create_scale_object (
2573+ signature_payload = runtime .runtime_config .create_scale_object (
25732574 "ExtrinsicPayloadValue"
25742575 )
25752576
25762577 # Process signed extensions in metadata
2577- if "signed_extensions" in self . runtime .metadata [1 ][1 ]["extrinsic" ]:
2578+ if "signed_extensions" in runtime .metadata [1 ][1 ]["extrinsic" ]:
25782579 # Base signature payload
25792580 signature_payload .type_mapping = [["call" , "CallBytes" ]]
25802581
25812582 # Add signed extensions to payload
2582- signed_extensions = self . runtime .metadata .get_signed_extensions ()
2583+ signed_extensions = runtime .metadata .get_signed_extensions ()
25832584
25842585 if "CheckMortality" in signed_extensions :
25852586 signature_payload .type_mapping .append (
@@ -2668,10 +2669,10 @@ async def generate_signature_payload(
26682669 "era" : era ,
26692670 "nonce" : nonce ,
26702671 "tip" : tip ,
2671- "spec_version" : self . runtime .runtime_version ,
2672+ "spec_version" : runtime .runtime_version ,
26722673 "genesis_hash" : genesis_hash ,
26732674 "block_hash" : block_hash ,
2674- "transaction_version" : self . runtime .transaction_version ,
2675+ "transaction_version" : runtime .transaction_version ,
26752676 "asset_id" : {"tip" : tip , "asset_id" : tip_asset_id },
26762677 "metadata_hash" : None ,
26772678 "mode" : "Disabled" ,
@@ -2713,16 +2714,16 @@ async def create_signed_extrinsic(
27132714 The signed Extrinsic
27142715 """
27152716 # only support creating extrinsics for current block
2716- await self . init_runtime ( block_id = await self .get_block_number () )
2717+ runtime = await self .init_runtime ( )
27172718
27182719 # Check requirements
27192720 if not isinstance (call , GenericCall ):
27202721 raise TypeError ("'call' must be of type Call" )
27212722
27222723 # Check if extrinsic version is supported
2723- if self . runtime .metadata [1 ][1 ]["extrinsic" ]["version" ] != 4 : # type: ignore
2724+ if runtime .metadata [1 ][1 ]["extrinsic" ]["version" ] != 4 : # type: ignore
27242725 raise NotImplementedError (
2725- f"Extrinsic version { self . runtime .metadata [1 ][1 ]['extrinsic' ]['version' ]} not supported" # type: ignore
2726+ f"Extrinsic version { runtime .metadata [1 ][1 ]['extrinsic' ]['version' ]} not supported" # type: ignore
27262727 )
27272728
27282729 # Retrieve nonce
@@ -2766,7 +2767,7 @@ async def create_signed_extrinsic(
27662767
27672768 # Create extrinsic
27682769 extrinsic = self .runtime_config .create_scale_object (
2769- type_string = "Extrinsic" , metadata = self . runtime .metadata
2770+ type_string = "Extrinsic" , metadata = runtime .metadata
27702771 )
27712772
27722773 value = {
@@ -2783,8 +2784,8 @@ async def create_signed_extrinsic(
27832784 }
27842785
27852786 # Check if ExtrinsicSignature is MultiSignature, otherwise omit signature_version
2786- signature_cls = self .runtime_config .get_decoder_class ("ExtrinsicSignature" )
2787- if issubclass (signature_cls , self .runtime_config .get_decoder_class ("Enum" )):
2787+ signature_cls = runtime .runtime_config .get_decoder_class ("ExtrinsicSignature" )
2788+ if issubclass (signature_cls , runtime .runtime_config .get_decoder_class ("Enum" )):
27882789 value ["signature_version" ] = signature_version
27892790
27902791 extrinsic .encode (value )
@@ -3029,7 +3030,7 @@ async def get_metadata_constants(self, block_hash=None) -> list[dict]:
30293030
30303031 constant_list = []
30313032
3032- for module_idx , module in enumerate (self .metadata .pallets ):
3033+ for module_idx , module in enumerate (runtime .metadata .pallets ):
30333034 for constant in module .constants or []:
30343035 constant_list .append (
30353036 self .serialize_constant (constant , module , runtime .runtime_version )
@@ -3158,14 +3159,14 @@ async def get_type_registry(
31583159 Returns:
31593160 dict mapping the type strings to the type decompositions
31603161 """
3161- await self .init_runtime (block_hash = block_hash )
3162+ runtime = await self .init_runtime (block_hash = block_hash )
31623163
3163- if not self .implements_scaleinfo :
3164+ if not runtime .implements_scaleinfo :
31643165 raise NotImplementedError ("MetadataV14 or higher runtimes is required" )
31653166
31663167 type_registry = {}
31673168
3168- for scale_info_type in self .metadata .portable_registry ["types" ]:
3169+ for scale_info_type in runtime .metadata .portable_registry ["types" ]:
31693170 if (
31703171 "path" in scale_info_type .value ["type" ]
31713172 and len (scale_info_type .value ["type" ]["path" ]) > 0
@@ -3207,21 +3208,21 @@ async def get_metadata_modules(self, block_hash=None) -> list[dict[str, Any]]:
32073208 Returns:
32083209 List of metadata modules
32093210 """
3210- await self .init_runtime (block_hash = block_hash )
3211+ runtime = await self .init_runtime (block_hash = block_hash )
32113212
32123213 return [
32133214 {
32143215 "metadata_index" : idx ,
32153216 "module_id" : module .get_identifier (),
32163217 "name" : module .name ,
3217- "spec_version" : self . runtime .runtime_version ,
3218+ "spec_version" : runtime .runtime_version ,
32183219 "count_call_functions" : len (module .calls or []),
32193220 "count_storage_functions" : len (module .storage or []),
32203221 "count_events" : len (module .events or []),
32213222 "count_constants" : len (module .constants or []),
32223223 "count_errors" : len (module .errors or []),
32233224 }
3224- for idx , module in enumerate (self .metadata .pallets )
3225+ for idx , module in enumerate (runtime .metadata .pallets )
32253226 ]
32263227
32273228 async def get_metadata_module (self , name , block_hash = None ) -> ScaleType :
@@ -3235,9 +3236,9 @@ async def get_metadata_module(self, name, block_hash=None) -> ScaleType:
32353236 Returns:
32363237 MetadataModule
32373238 """
3238- await self .init_runtime (block_hash = block_hash )
3239+ runtime = await self .init_runtime (block_hash = block_hash )
32393240
3240- return self .metadata .get_metadata_pallet (name )
3241+ return runtime .metadata .get_metadata_pallet (name )
32413242
32423243 async def query (
32433244 self ,
@@ -3655,9 +3656,9 @@ async def get_metadata_call_function(
36553656 Returns:
36563657 list of call functions
36573658 """
3658- await self .init_runtime (block_hash = block_hash )
3659+ runtime = await self .init_runtime (block_hash = block_hash )
36593660
3660- for pallet in self . runtime .metadata .pallets :
3661+ for pallet in runtime .metadata .pallets :
36613662 if pallet .name == module_name and pallet .calls :
36623663 for call in pallet .calls :
36633664 if call .name == call_function_name :
@@ -3679,7 +3680,7 @@ async def get_metadata_events(self, block_hash=None) -> list[dict]:
36793680
36803681 event_list = []
36813682
3682- for event_index , (module , event ) in self .metadata .event_index .items ():
3683+ for event_index , (module , event ) in runtime .metadata .event_index .items ():
36833684 event_list .append (
36843685 self .serialize_module_event (
36853686 module , event , runtime .runtime_version , event_index
0 commit comments