Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(gateway): remove unnecessary result #516

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -80,18 +80,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
Loading