Skip to content

Commit

Permalink
chore: fix new clippy lint (paradigmxyz#5806)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Dec 18, 2023
1 parent 5e7bd64 commit fcdd31a
Showing 1 changed file with 24 additions and 37 deletions.
61 changes: 24 additions & 37 deletions crates/rpc/rpc/src/eth/api/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -950,45 +950,32 @@ where
l1_block_info: Option<L1BlockInfo>,
block_timestamp: u64,
) -> EthResult<OptimismTxMeta> {
if let Some(l1_block_info) = l1_block_info {
let envelope_buf: Bytes = {
let mut envelope_buf = bytes::BytesMut::default();
tx.encode_enveloped(&mut envelope_buf);
envelope_buf.freeze().into()
};

let (l1_fee, l1_data_gas) = match (!tx.is_deposit())
.then(|| {
let inner_l1_fee = match l1_block_info.l1_tx_data_fee(
&self.inner.provider.chain_spec(),
block_timestamp,
&envelope_buf,
tx.is_deposit(),
) {
Ok(inner_l1_fee) => inner_l1_fee,
Err(e) => return Err(e),
};
let inner_l1_data_gas = match l1_block_info.l1_data_gas(
&self.inner.provider.chain_spec(),
block_timestamp,
&envelope_buf,
) {
Ok(inner_l1_data_gas) => inner_l1_data_gas,
Err(e) => return Err(e),
};
Ok((inner_l1_fee, inner_l1_data_gas))
})
.transpose()
.map_err(|_| EthApiError::InternalEthError)?
{
Some((l1_fee, l1_data_gas)) => (Some(l1_fee), Some(l1_data_gas)),
None => (None, None),
};
let Some(l1_block_info) = l1_block_info else { return Ok(OptimismTxMeta::default()) };

let envelope_buf: Bytes = {
let mut envelope_buf = bytes::BytesMut::new();
tx.encode_enveloped(&mut envelope_buf);
envelope_buf.freeze().into()
};

Ok(OptimismTxMeta::new(Some(l1_block_info), l1_fee, l1_data_gas))
let (l1_fee, l1_data_gas) = if tx.is_deposit() {
let inner_l1_fee = l1_block_info
.l1_tx_data_fee(
&self.inner.provider.chain_spec(),
block_timestamp,
&envelope_buf,
tx.is_deposit(),
)
.map_err(|_| EthApiError::InternalEthError)?;
let inner_l1_data_gas = l1_block_info
.l1_data_gas(&self.inner.provider.chain_spec(), block_timestamp, &envelope_buf)
.map_err(|_| EthApiError::InternalEthError)?;
(Some(inner_l1_fee), Some(inner_l1_data_gas))
} else {
Ok(OptimismTxMeta::default())
}
(None, None)
};

Ok(OptimismTxMeta::new(Some(l1_block_info), l1_fee, l1_data_gas))
}

/// Helper function for `eth_sendRawTransaction` for Optimism.
Expand Down

0 comments on commit fcdd31a

Please sign in to comment.