@@ -1731,7 +1731,11 @@ def get_account_nonce(self, account_address) -> int:
1731
1731
-------
1732
1732
int
1733
1733
"""
1734
- response = self .rpc_request ("system_accountNextIndex" , [account_address ])
1734
+ if self .supports_rpc_method ('state_call' ):
1735
+ nonce_obj = self .runtime_call ("AccountNonceApi" , "account_nonce" , [account_address ])
1736
+ return nonce_obj .value
1737
+ else :
1738
+ response = self .rpc_request ("system_accountNextIndex" , [account_address ])
1735
1739
return response .get ('result' , 0 )
1736
1740
1737
1741
def generate_signature_payload (self , call : GenericCall , era = None , nonce : int = 0 , tip : int = 0 ,
@@ -2143,27 +2147,36 @@ def get_payment_info(self, call: GenericCall, keypair: Keypair):
2143
2147
signature = signature
2144
2148
)
2145
2149
2146
- payment_info = self .rpc_request ('payment_queryInfo' , [str (extrinsic .data )])
2150
+ if self .supports_rpc_method ('state_call' ):
2151
+ extrinsic_len = self .runtime_config .create_scale_object ('u32' )
2152
+ extrinsic_len .encode (len (extrinsic .data ))
2147
2153
2148
- # convert partialFee to int
2149
- if 'result' in payment_info :
2150
- payment_info ['result' ]['partialFee' ] = int (payment_info ['result' ]['partialFee' ])
2154
+ result = self .runtime_call ("TransactionPaymentApi" , "query_info" , [extrinsic , extrinsic_len ])
2151
2155
2152
- if type (payment_info ['result' ]['weight' ]) is int :
2153
- # Transform format to WeightV2 if applicable as per https://github.com/paritytech/substrate/pull/12633
2154
- try :
2155
- weight_obj = self .runtime_config .create_scale_object ("sp_weights::weight_v2::Weight" )
2156
- if weight_obj is not None :
2157
- payment_info ['result' ]['weight' ] = {
2158
- 'ref_time' : payment_info ['result' ]['weight' ],
2159
- 'proof_size' : 0
2160
- }
2161
- except NotImplementedError :
2162
- pass
2163
-
2164
- return payment_info ['result' ]
2156
+ return result .value
2165
2157
else :
2166
- raise SubstrateRequestException (payment_info ['error' ]['message' ])
2158
+ # Backwards compatibility; deprecated RPC method
2159
+ payment_info = self .rpc_request ('payment_queryInfo' , [str (extrinsic .data )])
2160
+
2161
+ # convert partialFee to int
2162
+ if 'result' in payment_info :
2163
+ payment_info ['result' ]['partialFee' ] = int (payment_info ['result' ]['partialFee' ])
2164
+
2165
+ if type (payment_info ['result' ]['weight' ]) is int :
2166
+ # Transform format to WeightV2 if applicable as per https://github.com/paritytech/substrate/pull/12633
2167
+ try :
2168
+ weight_obj = self .runtime_config .create_scale_object ("sp_weights::weight_v2::Weight" )
2169
+ if weight_obj is not None :
2170
+ payment_info ['result' ]['weight' ] = {
2171
+ 'ref_time' : payment_info ['result' ]['weight' ],
2172
+ 'proof_size' : 0
2173
+ }
2174
+ except NotImplementedError :
2175
+ pass
2176
+
2177
+ return payment_info ['result' ]
2178
+ else :
2179
+ raise SubstrateRequestException (payment_info ['error' ]['message' ])
2167
2180
2168
2181
def get_type_registry (self , block_hash : str = None , max_recursion : int = 4 ) -> dict :
2169
2182
"""
0 commit comments