diff --git a/crates/wallet/src/lib.rs b/crates/wallet/src/lib.rs index 0f6f4e1..3ece829 100644 --- a/crates/wallet/src/lib.rs +++ b/crates/wallet/src/lib.rs @@ -138,6 +138,11 @@ pub enum OdysseyWalletError { /// This is likely an internal error, as most of the request is built by the sequencer. #[error("invalid tx request")] InvalidTransactionRequest, + /// The request was estimated to consume too much gas. + /// + /// The gas usage by each request is limited to counteract draining the sequencers funds. + #[error("request would use too much gas")] + GasEstimateTooHigh, /// An internal error occurred. #[error("internal error")] InternalError, @@ -267,6 +272,9 @@ where EthCall::estimate_gas_at(&self.inner.eth_api, request.clone(), BlockId::latest(), None) .await .map_err(Into::into)?; + if estimate >= U256::from(150_000) { + return Err(OdysseyWalletError::GasEstimateTooHigh.into()); + } request = request.gas_limit(estimate.to()); // set gas fees