@@ -22,7 +22,7 @@ use blockifier::transaction::account_transaction::{AccountTransaction, Execution
2222use blockifier:: transaction:: transactions:: enforce_fee;
2323use num_rational:: Ratio ;
2424use starknet_api:: block:: { BlockInfo , NonzeroGasPrice } ;
25- use starknet_api:: core:: Nonce ;
25+ use starknet_api:: core:: { ContractAddress , Nonce } ;
2626use starknet_api:: executable_transaction:: {
2727 AccountTransaction as ExecutableTransaction ,
2828 InvokeTransaction as ExecutableInvokeTransaction ,
@@ -148,6 +148,11 @@ pub trait StatefulTransactionValidatorTrait: Send {
148148 mempool_client : SharedMempoolClient ,
149149 runtime : tokio:: runtime:: Handle ,
150150 ) -> StatefulTransactionValidatorResult < Nonce > ;
151+
152+ fn get_nonce (
153+ & mut self ,
154+ account_address : ContractAddress ,
155+ ) -> StatefulTransactionValidatorResult < Nonce > ;
151156}
152157
153158pub struct StatefulTransactionValidator < B : BlockifierStatefulValidatorTrait + Send > {
@@ -165,18 +170,19 @@ impl<B: BlockifierStatefulValidatorTrait + Send> StatefulTransactionValidatorTra
165170 runtime : tokio:: runtime:: Handle ,
166171 ) -> StatefulTransactionValidatorResult < Nonce > {
167172 let address = executable_tx. contract_address ( ) ;
168- let account_nonce =
169- self . blockifier_stateful_tx_validator . get_nonce ( address) . map_err ( |e| {
170- // TODO(noamsp): Fix this. Need to map the errors better.
171- StarknetError :: internal_with_signature_logging (
172- format ! ( "Failed to get nonce for sender address {address}" ) ,
173- & executable_tx. signature ( ) ,
174- e,
175- )
176- } ) ?;
173+ let account_nonce = self . get_nonce ( address) ?;
177174 self . run_transaction_validations ( executable_tx, account_nonce, mempool_client, runtime) ?;
178175 Ok ( account_nonce)
179176 }
177+
178+ fn get_nonce (
179+ & mut self ,
180+ account_address : ContractAddress ,
181+ ) -> StatefulTransactionValidatorResult < Nonce > {
182+ self . blockifier_stateful_tx_validator
183+ . get_nonce ( account_address)
184+ . map_err ( |e| StarknetError :: internal_with_logging ( "Failed to get nonce" , e) )
185+ }
180186}
181187
182188impl < B : BlockifierStatefulValidatorTrait + Send > StatefulTransactionValidator < B > {
0 commit comments