diff --git a/crates/providers/src/provider.rs b/crates/providers/src/provider.rs index ff029b7fcff..6aee89ac599 100644 --- a/crates/providers/src/provider.rs +++ b/crates/providers/src/provider.rs @@ -6,7 +6,7 @@ use alloy_rpc_client::{ClientBuilder, RpcClient}; use alloy_rpc_types::{ trace::{GethDebugTracingOptions, GethTrace, LocalizedTransactionTrace}, AccessListWithGasUsed, Block, BlockId, BlockNumberOrTag, CallRequest, - EIP1186AccountProofResponse, FeeHistory, Filter, Log, RpcBlockHash, SyncStatus, Transaction, + EIP1186AccountProofResponse, FeeHistory, Filter, Log, SyncStatus, Transaction, TransactionReceipt, }; use alloy_transport::{BoxTransport, Transport, TransportErrorKind, TransportResult}; @@ -14,7 +14,6 @@ use alloy_transport_http::Http; use auto_impl::auto_impl; use reqwest::Client; use serde::{Deserialize, Serialize}; -use std::borrow::Cow; use thiserror::Error; #[derive(Debug, Error, Serialize, Deserialize)] @@ -280,10 +279,10 @@ impl TempProvider for Provider { self.inner .prepare( "eth_getTransactionCount", - Cow::<(Address, BlockId)>::Owned(( + ( address, tag.unwrap_or(BlockNumberOrTag::Latest.into()), - )), + ), ) .await } @@ -294,7 +293,7 @@ impl TempProvider for Provider { where Self: Sync, { - self.inner.prepare("eth_blockNumber", Cow::<()>::Owned(())).await.map(|num: U64| num.to::()) + self.inner.prepare("eth_blockNumber", ()).await.map(|num: U64| num.to::()) } /// Gets the balance of the account at the specified tag, which defaults to latest. @@ -305,10 +304,10 @@ impl TempProvider for Provider { self.inner .prepare( "eth_getBalance", - Cow::<(Address, BlockId)>::Owned(( + ( address, tag.unwrap_or(BlockId::Number(BlockNumberOrTag::Latest)), - )), + ), ) .await } @@ -319,7 +318,7 @@ impl TempProvider for Provider { Self: Sync, { self.inner - .prepare("eth_getBlockByHash", Cow::<(BlockHash, bool)>::Owned((hash, full))) + .prepare("eth_getBlockByHash", (hash, full)) .await } @@ -335,7 +334,7 @@ impl TempProvider for Provider { self.inner .prepare( "eth_getBlockByNumber", - Cow::<(BlockNumberOrTag, bool)>::Owned((number.into(), full)), + (number.into(), full), ) .await } @@ -345,7 +344,7 @@ impl TempProvider for Provider { where Self: Sync, { - self.inner.prepare("eth_chainId", Cow::<()>::Owned(())).await + self.inner.prepare("eth_chainId", ()).await } /// Gets the specified storage value from [Address]. @@ -358,11 +357,11 @@ impl TempProvider for Provider { self.inner .prepare( "eth_getStorageAt", - Cow::<(Address, StorageKey, BlockId)>::Owned(( + ( address, key, tag.unwrap_or(BlockNumberOrTag::Latest.into()), - )), + ), ) .await } @@ -377,7 +376,7 @@ impl TempProvider for Provider { Self: Sync, { self.inner - .prepare("eth_getCode", Cow::<(Address, BlockId)>::Owned((address, tag.into()))) + .prepare("eth_getCode", (address, tag.into())) .await } @@ -389,9 +388,7 @@ impl TempProvider for Provider { self.inner .prepare( "eth_getTransactionByHash", - // Force alloy-rs/alloy to encode this an array of strings, - // even if we only need to send one hash. - Cow::>::Owned(vec![hash]), + (hash,), ) .await } @@ -401,7 +398,7 @@ impl TempProvider for Provider { where Self: Sync, { - self.inner.prepare("eth_getLogs", Cow::>::Owned(vec![filter])).await + self.inner.prepare("eth_getLogs", vec![filter]).await } /// Gets the accounts in the remote node. This is usually empty unless you're using a local @@ -410,7 +407,7 @@ impl TempProvider for Provider { where Self: Sync, { - self.inner.prepare("eth_accounts", Cow::<()>::Owned(())).await + self.inner.prepare("eth_accounts", ()).await } /// Gets the current gas price. @@ -418,7 +415,7 @@ impl TempProvider for Provider { where Self: Sync, { - self.inner.prepare("eth_gasPrice", Cow::<()>::Owned(())).await + self.inner.prepare("eth_gasPrice", ()).await } /// Gets a [TransactionReceipt] if it exists, by its [TxHash]. @@ -429,7 +426,7 @@ impl TempProvider for Provider { where Self: Sync, { - self.inner.prepare("eth_getTransactionReceipt", Cow::>::Owned(vec![hash])).await + self.inner.prepare("eth_getTransactionReceipt", (hash,)).await } /// Returns a collection of historical gas information [FeeHistory] which @@ -446,11 +443,11 @@ impl TempProvider for Provider { self.inner .prepare( "eth_feeHistory", - Cow::<(U256, BlockNumberOrTag, Vec)>::Owned(( + ( block_count, last_block.into(), - reward_percentiles.to_vec(), - )), + reward_percentiles, + ), ) .await } @@ -463,7 +460,7 @@ impl TempProvider for Provider { where Self: Sync, { - self.inner.prepare("eth_getBlockReceipts", Cow::::Owned(block)).await + self.inner.prepare("eth_getBlockReceipts", block).await } /// Gets an uncle block through the tag [BlockId] and index [U64]. @@ -481,7 +478,7 @@ impl TempProvider for Provider { self.inner .prepare( "eth_getUncleByBlockHashAndIndex", - Cow::<(RpcBlockHash, U64)>::Owned((hash, idx)), + (hash, idx), ) .await } @@ -489,7 +486,7 @@ impl TempProvider for Provider { self.inner .prepare( "eth_getUncleByBlockNumberAndIndex", - Cow::<(BlockNumberOrTag, U64)>::Owned((number, idx)), + (number, idx), ) .await } @@ -501,7 +498,7 @@ impl TempProvider for Provider { where Self: Sync, { - self.inner.prepare("eth_syncing", Cow::<()>::Owned(())).await + self.inner.prepare("eth_syncing", ()).await } /// Execute a smart contract call with [CallRequest] without publishing a transaction. @@ -512,10 +509,10 @@ impl TempProvider for Provider { self.inner .prepare( "eth_call", - Cow::<(CallRequest, BlockId)>::Owned(( + ( tx, block.unwrap_or(BlockId::Number(BlockNumberOrTag::Latest)), - )), + ), ) .await } @@ -526,20 +523,20 @@ impl TempProvider for Provider { Self: Sync, { if let Some(block_id) = block { - let params = Cow::<(CallRequest, BlockId)>::Owned((tx, block_id)); + let params = (tx, block_id); self.inner.prepare("eth_estimateGas", params).await } else { - let params = Cow::::Owned(tx); + let params = tx; self.inner.prepare("eth_estimateGas", params).await } } - /// Sends an already-signed transaction. + /// Sends an already-signed transaction. async fn send_raw_transaction(&self, tx: Bytes) -> TransportResult where Self: Sync, { - self.inner.prepare("eth_sendRawTransaction", Cow::::Owned(tx)).await + self.inner.prepare("eth_sendRawTransaction", tx).await } /// Estimates the EIP1559 `maxFeePerGas` and `maxPriorityFeePerGas` fields. @@ -601,11 +598,11 @@ impl TempProvider for Provider { self.inner .prepare( "eth_getProof", - Cow::<(Address, Vec, BlockId)>::Owned(( + ( address, keys, block.unwrap_or(BlockNumberOrTag::Latest.into()), - )), + ), ) .await } @@ -621,10 +618,10 @@ impl TempProvider for Provider { self.inner .prepare( "eth_createAccessList", - Cow::<(CallRequest, BlockId)>::Owned(( + ( request, block.unwrap_or(BlockNumberOrTag::Latest.into()), - )), + ), ) .await } @@ -637,7 +634,7 @@ impl TempProvider for Provider { where Self: Sync, { - self.inner.prepare("trace_transaction", Cow::>::Owned(vec![hash])).await + self.inner.prepare("trace_transaction", vec![hash]).await } async fn debug_trace_transaction( @@ -651,7 +648,7 @@ impl TempProvider for Provider { self.inner .prepare( "debug_traceTransaction", - Cow::<(TxHash, GethDebugTracingOptions)>::Owned((hash, trace_options)), + (hash, trace_options), ) .await } @@ -663,7 +660,7 @@ impl TempProvider for Provider { where Self: Sync, { - self.inner.prepare("trace_block", Cow::::Owned(block)).await + self.inner.prepare("trace_block", block).await } #[cfg(feature = "anvil")] @@ -672,7 +669,7 @@ impl TempProvider for Provider { Self: Sync, { self.inner - .prepare("anvil_setCode", Cow::<(Address, &'static str)>::Owned((address, code))) + .prepare("anvil_setCode", (address, code)) .await } }