chore: use cost in error (#2213)

Co-authored-by: Roman Krasiuk <rokrassyuk@gmail.com>
This commit is contained in:
Matthias Seitz
2023-04-12 17:53:52 +02:00
committed by GitHub
parent 15ad63f8c2
commit 48dc9987a1
2 changed files with 4 additions and 4 deletions

View File

@ -7,8 +7,8 @@ use crate::U256;
pub enum InvalidTransactionError { pub enum InvalidTransactionError {
#[error("Transaction eip1559 priority fee is more then max fee.")] #[error("Transaction eip1559 priority fee is more then max fee.")]
PriorityFeeMoreThenMaxFee, PriorityFeeMoreThenMaxFee,
#[error("Account does not have enough funds ({available_funds:?}) to cover transaction max fee: {max_fee:?}.")] #[error("Account does not have enough funds ({available_funds:?}) to cover transaction cost: {cost:?}.")]
InsufficientFunds { max_fee: u128, available_funds: U256 }, InsufficientFunds { cost: U256, available_funds: U256 },
#[error("Transaction nonce is not consistent.")] #[error("Transaction nonce is not consistent.")]
NonceNotConsistent, NonceNotConsistent,
#[error("Old legacy transaction before Spurious Dragon should not have chain_id.")] #[error("Old legacy transaction before Spurious Dragon should not have chain_id.")]

View File

@ -257,11 +257,11 @@ where
// Checks for max cost // Checks for max cost
if transaction.cost() > account.balance { if transaction.cost() > account.balance {
let max_fee = transaction.max_fee_per_gas().unwrap_or_default(); let cost = transaction.cost();
return TransactionValidationOutcome::Invalid( return TransactionValidationOutcome::Invalid(
transaction, transaction,
InvalidTransactionError::InsufficientFunds { InvalidTransactionError::InsufficientFunds {
max_fee, cost,
available_funds: account.balance, available_funds: account.balance,
} }
.into(), .into(),