diff --git a/crates/wallet/src/lib.rs b/crates/wallet/src/lib.rs index 32a82a2..47d431f 100644 --- a/crates/wallet/src/lib.rs +++ b/crates/wallet/src/lib.rs @@ -272,17 +272,20 @@ where request.chain_id = Some(self.chain_id()); // set gas limit + // note: we also set the `from` field here to correctly estimate for contracts that use e.g. + // `tx.origin` + request.from = Some(NetworkWallet::::default_signer_address(&self.inner.wallet)); let (estimate, base_fee) = tokio::join!( EthCall::estimate_gas_at(&self.inner.eth_api, request.clone(), BlockId::latest(), None), LoadFee::eip1559_fees(&self.inner.eth_api, None, None) ); - let estimate = estimate.map_err(Into::into)?; if estimate >= U256::from(350_000) { return Err(OdysseyWalletError::GasEstimateTooHigh { estimate: estimate.to() }.into()); } request.gas = Some(estimate.to()); + // set gas price let (base_fee, _) = base_fee.map_err(|_| OdysseyWalletError::InvalidTransactionRequest)?; let max_priority_fee_per_gas = 1_000_000_000; // 1 gwei request.max_fee_per_gas = Some(base_fee.to::() + max_priority_fee_per_gas);