Skip to content

Commit

Permalink
refactor(gateway): remove unnecessary result (#516)
Browse files Browse the repository at this point in the history
  • Loading branch information
yair-starkware authored Jul 23, 2024
1 parent f50696c commit d2a047f
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions crates/gateway/src/stateful_transaction_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl StatefulTransactionValidator {
let tx_hash = get_tx_hash(&account_tx);

let account_nonce = validator.get_nonce(get_sender_address(external_tx))?;
let skip_validate = skip_stateful_validations(external_tx, account_nonce)?;
let skip_validate = skip_stateful_validations(external_tx, account_nonce);
validator.perform_validations(account_tx, skip_validate)?;
Ok(tx_hash)
}
Expand Down Expand Up @@ -76,18 +76,15 @@ impl StatefulTransactionValidator {
// Check if validation of an invoke transaction should be skipped due to deploy_account not being
// proccessed yet. This feature is used to improve UX for users sending deploy_account + invoke at
// once.
fn skip_stateful_validations(
tx: &RPCTransaction,
account_nonce: Nonce,
) -> StatefulTransactionValidatorResult<bool> {
fn skip_stateful_validations(tx: &RPCTransaction, account_nonce: Nonce) -> bool {
match tx {
RPCTransaction::Invoke(RPCInvokeTransaction::V3(tx)) => {
// check if the transaction nonce is 1, meaning it is post deploy_account, and the
// account nonce is zero, meaning the account was not deployed yet. The mempool also
// verifies that the deploy_account transaction exists.
Ok(tx.nonce == Nonce(Felt::ONE) && account_nonce == Nonce(Felt::ZERO))
tx.nonce == Nonce(Felt::ONE) && account_nonce == Nonce(Felt::ZERO)
}
RPCTransaction::DeployAccount(_) | RPCTransaction::Declare(_) => Ok(false),
RPCTransaction::DeployAccount(_) | RPCTransaction::Declare(_) => false,
}
}

Expand Down

0 comments on commit d2a047f

Please sign in to comment.