Skip to content

Commit

Permalink
always convert tx_env.gas_price to wei
Browse files Browse the repository at this point in the history
  • Loading branch information
oXtxNt9U committed Jan 21, 2025
1 parent ef50fe3 commit 3493de5
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/evm/bindings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ mod logger;
mod result;
mod utils;

const ONE_GWEI: u64 = 1_000_000_000;

// A complex struct which cannot be exposed to JavaScript directly.
pub struct EvmInner {
persistent_db: PersistentDB,
Expand Down Expand Up @@ -432,7 +434,10 @@ impl EvmInner {
})
.modify_tx_env(|tx_env| {
tx_env.gas_limit = ctx.gas_limit;
tx_env.gas_price = ctx.gas_price.unwrap_or_else(|| U256::ZERO);
tx_env.gas_price = ctx
.gas_price
.unwrap_or_else(|| U256::ZERO)
.saturating_mul(U256::from(ONE_GWEI));
tx_env.caller = ctx.caller;
tx_env.value = ctx.value;
tx_env.nonce = Some(ctx.nonce);
Expand Down Expand Up @@ -687,7 +692,10 @@ impl EvmInner {
})
.modify_tx_env(|tx_env| {
tx_env.gas_limit = ctx.gas_limit.unwrap_or_else(|| 15_000_000);
tx_env.gas_price = ctx.gas_price.unwrap_or_else(|| U256::ZERO);
tx_env.gas_price = ctx
.gas_price
.unwrap_or_else(|| U256::ZERO)
.saturating_mul(U256::from(ONE_GWEI));
tx_env.caller = ctx.caller;
tx_env.value = ctx.value;
tx_env.nonce = ctx.nonce;
Expand Down

0 comments on commit 3493de5

Please sign in to comment.