@@ -20,7 +20,7 @@ use blockifier::transaction::account_transaction::{AccountTransaction, Execution
2020use blockifier:: transaction:: transactions:: enforce_fee;
2121use num_rational:: Ratio ;
2222use starknet_api:: block:: { BlockInfo , NonzeroGasPrice } ;
23- use starknet_api:: core:: Nonce ;
23+ use starknet_api:: core:: { ContractAddress , Nonce } ;
2424use starknet_api:: executable_transaction:: {
2525 AccountTransaction as ExecutableTransaction ,
2626 InvokeTransaction as ExecutableInvokeTransaction ,
@@ -135,6 +135,11 @@ pub trait StatefulTransactionValidatorTrait: Send {
135135 mempool_client : SharedMempoolClient ,
136136 runtime : tokio:: runtime:: Handle ,
137137 ) -> StatefulTransactionValidatorResult < Nonce > ;
138+
139+ fn get_nonce (
140+ & mut self ,
141+ account_address : ContractAddress ,
142+ ) -> StatefulTransactionValidatorResult < Nonce > ;
138143}
139144
140145pub struct StatefulTransactionValidator < B : BlockifierStatefulValidatorTrait + Send > {
@@ -152,18 +157,19 @@ impl<B: BlockifierStatefulValidatorTrait + Send> StatefulTransactionValidatorTra
152157 runtime : tokio:: runtime:: Handle ,
153158 ) -> StatefulTransactionValidatorResult < Nonce > {
154159 let address = executable_tx. contract_address ( ) ;
155- let account_nonce =
156- self . blockifier_stateful_tx_validator . get_nonce ( address) . map_err ( |e| {
157- // TODO(noamsp): Fix this. Need to map the errors better.
158- StarknetError :: internal_with_signature_logging (
159- format ! ( "Failed to get nonce for sender address {address}" ) ,
160- & executable_tx. signature ( ) ,
161- e,
162- )
163- } ) ?;
160+ let account_nonce = self . get_nonce ( address) ?;
164161 self . run_transaction_validations ( executable_tx, account_nonce, mempool_client, runtime) ?;
165162 Ok ( account_nonce)
166163 }
164+
165+ fn get_nonce (
166+ & mut self ,
167+ account_address : ContractAddress ,
168+ ) -> StatefulTransactionValidatorResult < Nonce > {
169+ self . blockifier_stateful_tx_validator
170+ . get_nonce ( account_address)
171+ . map_err ( |e| StarknetError :: internal_with_logging ( "Failed to get nonce" , e) )
172+ }
167173}
168174
169175impl < B : BlockifierStatefulValidatorTrait + Send > StatefulTransactionValidator < B > {
0 commit comments