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 {
#[error("Transaction eip1559 priority fee is more then max fee.")]
PriorityFeeMoreThenMaxFee,
#[error("Account does not have enough funds ({available_funds:?}) to cover transaction max fee: {max_fee:?}.")]
InsufficientFunds { max_fee: u128, available_funds: U256 },
#[error("Account does not have enough funds ({available_funds:?}) to cover transaction cost: {cost:?}.")]
InsufficientFunds { cost: U256, available_funds: U256 },
#[error("Transaction nonce is not consistent.")]
NonceNotConsistent,
#[error("Old legacy transaction before Spurious Dragon should not have chain_id.")]

View File

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