@@ -24,7 +24,7 @@ use blockifier::transaction::account_transaction::{AccountTransaction, Execution
2424use blockifier:: transaction:: transactions:: enforce_fee;
2525use num_rational:: Ratio ;
2626use starknet_api:: block:: { BlockInfo , NonzeroGasPrice } ;
27- use starknet_api:: core:: Nonce ;
27+ use starknet_api:: core:: { ContractAddress , Nonce } ;
2828use starknet_api:: executable_transaction:: {
2929 AccountTransaction as ExecutableTransaction ,
3030 InvokeTransaction as ExecutableInvokeTransaction ,
@@ -150,6 +150,11 @@ pub trait StatefulTransactionValidatorTrait: Send {
150150 mempool_client : SharedMempoolClient ,
151151 runtime : tokio:: runtime:: Handle ,
152152 ) -> StatefulTransactionValidatorResult < Nonce > ;
153+
154+ fn get_nonce (
155+ & mut self ,
156+ account_address : ContractAddress ,
157+ ) -> StatefulTransactionValidatorResult < Nonce > ;
153158}
154159
155160pub struct StatefulTransactionValidator < B : BlockifierStatefulValidatorTrait + Send > {
@@ -167,18 +172,19 @@ impl<B: BlockifierStatefulValidatorTrait + Send> StatefulTransactionValidatorTra
167172 runtime : tokio:: runtime:: Handle ,
168173 ) -> StatefulTransactionValidatorResult < Nonce > {
169174 let address = executable_tx. contract_address ( ) ;
170- let account_nonce =
171- self . blockifier_stateful_tx_validator . get_nonce ( address) . map_err ( |e| {
172- // TODO(noamsp): Fix this. Need to map the errors better.
173- StarknetError :: internal_with_signature_logging (
174- format ! ( "Failed to get nonce for sender address {address}" ) ,
175- & executable_tx. signature ( ) ,
176- e,
177- )
178- } ) ?;
175+ let account_nonce = self . get_nonce ( address) ?;
179176 self . run_transaction_validations ( executable_tx, account_nonce, mempool_client, runtime) ?;
180177 Ok ( account_nonce)
181178 }
179+
180+ fn get_nonce (
181+ & mut self ,
182+ account_address : ContractAddress ,
183+ ) -> StatefulTransactionValidatorResult < Nonce > {
184+ self . blockifier_stateful_tx_validator
185+ . get_nonce ( account_address)
186+ . map_err ( |e| StarknetError :: internal_with_logging ( "Failed to get nonce" , e) )
187+ }
182188}
183189
184190impl < B : BlockifierStatefulValidatorTrait + Send > StatefulTransactionValidator < B > {
0 commit comments