Skip to content

Commit

Permalink
fix: clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuajbouw committed Jan 24, 2023
1 parent c69fb52 commit d448ddd
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions engine/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ pub struct Engine<'env, I: IO, E: Env> {
state: EngineState,
origin: Address,
gas_price: U256,
gas_token: GasToken,
current_account_id: AccountId,
io: I,
env: &'env E,
Expand Down Expand Up @@ -509,7 +508,7 @@ impl<'env, I: IO + Copy, E: Env> Engine<'env, I, E> {
// This part is questionable.
set_balance(&mut self.io, sender, &new_balance);
}
GasToken::ERC20(addr) => {
GasToken::ERC20(_addr) => {
// TODO: Needs SputnikVM balance check
todo!()
}
Expand Down Expand Up @@ -814,7 +813,7 @@ impl<'env, I: IO + Copy, E: Env> Engine<'env, I, E> {
&erc20_token,
Wei::zero(),
setup_receive_erc20_tokens_input(args, &recipient),
u64::MAX,
EthGas::MAX,
Vec::new(), // TODO: are there values we should put here?
handler,
)
Expand Down Expand Up @@ -986,10 +985,13 @@ pub fn submit<I: IO + Copy, E: Env, P: PromiseHandler>(
return Err(EngineErrorKind::GasPayment(err).into());
}
};
let gas_limit: EthGas = transaction
.gas_limit
.try_into()
.map_err(|_| EngineErrorKind::GasOverflow)?;
let gas_limit: EthGas = {
let gas_limit: u64 = transaction
.gas_limit
.try_into()
.map_err(|_| EngineErrorKind::GasOverflow)?;
EthGas::new(gas_limit)
};
let access_list = transaction
.access_list
.into_iter()
Expand Down Expand Up @@ -1564,7 +1566,7 @@ unsafe fn schedule_promise_callback<P: PromiseHandler>(
handler.promise_attach_callback(base_id, promise)
}

impl<'env, I: IO + Copy, E: Env> evm::backend::Backend for Engine<'env, I, E> {
impl<'env, I: IO + Copy, E: Env> Backend for Engine<'env, I, E> {
/// Returns the "effective" gas price (as defined by EIP-1559)
fn gas_price(&self) -> U256 {
self.gas_price
Expand Down Expand Up @@ -1851,6 +1853,7 @@ impl<'env, J: IO + Copy, E: Env> ApplyBackend for Engine<'env, J, E> {
}

#[cfg(test)]
#[cfg(feature = "std")]
mod tests {
use super::*;
use crate::parameters::{FunctionCallArgsV1, FunctionCallArgsV2};
Expand Down Expand Up @@ -2139,7 +2142,10 @@ mod tests {
data: vec![],
access_list: vec![],
};
let actual_result = engine.charge_gas(&origin, &transaction).unwrap();
// TODO: Add other tests than just ETH as a gas token.
let actual_result = engine
.charge_gas(&origin, &transaction, GasToken::ETH)
.unwrap();

let expected_result = GasPaymentResult {
prepaid_amount: Wei::zero(),
Expand Down

0 comments on commit d448ddd

Please sign in to comment.