mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore(rpc): remove redundant trait bounds (#8414)
This commit is contained in:
@ -87,8 +87,9 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
// Test vector from: https://eips.ethereum.org/EIPS/eip-2481
|
||||
#[test]
|
||||
#[allow(clippy::needless_update)]
|
||||
fn encode_receipts() {
|
||||
let expected = hex!("f90172820457f9016cf90169f901668001b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f85ff85d940000000000000000000000000000000000000011f842a0000000000000000000000000000000000000000000000000000000000000deada0000000000000000000000000000000000000000000000000000000000000beef830100ff");
|
||||
let mut data = vec![];
|
||||
@ -120,8 +121,9 @@ mod tests {
|
||||
assert_eq!(data, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
// Test vector from: https://eips.ethereum.org/EIPS/eip-2481
|
||||
#[test]
|
||||
#[allow(clippy::needless_update)]
|
||||
fn decode_receipts() {
|
||||
let data = hex!("f90172820457f9016cf90169f901668001b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f85ff85d940000000000000000000000000000000000000011f842a0000000000000000000000000000000000000000000000000000000000000deada0000000000000000000000000000000000000000000000000000000000000beef830100ff");
|
||||
let request = RequestPair::<Receipts>::decode(&mut &data[..]).unwrap();
|
||||
|
||||
@ -1367,11 +1367,7 @@ where
|
||||
|
||||
impl<Provider, Pool, Network, EvmConfig> EthApi<Provider, Pool, Network, EvmConfig>
|
||||
where
|
||||
Pool: TransactionPool + Clone + 'static,
|
||||
Provider:
|
||||
BlockReaderIdExt + ChainSpecProvider + StateProviderFactory + EvmEnvProvider + 'static,
|
||||
Network: NetworkInfo + Send + Sync + 'static,
|
||||
EvmConfig: ConfigureEvm + 'static,
|
||||
Self: Send + Sync + 'static,
|
||||
{
|
||||
/// Spawns the given closure on a new blocking tracing task
|
||||
async fn spawn_tracing_task_with<F, T>(&self, f: F) -> EthResult<T>
|
||||
@ -1390,11 +1386,11 @@ where
|
||||
|
||||
impl<Provider, Pool, Network, EvmConfig> EthApi<Provider, Pool, Network, EvmConfig>
|
||||
where
|
||||
Pool: TransactionPool + Clone + 'static,
|
||||
Pool: TransactionPool + 'static,
|
||||
Provider:
|
||||
BlockReaderIdExt + ChainSpecProvider + StateProviderFactory + EvmEnvProvider + 'static,
|
||||
Network: NetworkInfo + Send + Sync + 'static,
|
||||
EvmConfig: ConfigureEvm + 'static,
|
||||
Network: NetworkInfo + 'static,
|
||||
EvmConfig: ConfigureEvm,
|
||||
{
|
||||
/// Returns the gas price if it is set, otherwise fetches a suggested gas price for legacy
|
||||
/// transactions.
|
||||
@ -1449,13 +1445,67 @@ where
|
||||
None => self.blob_base_fee().await,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn sign_request(
|
||||
&self,
|
||||
from: &Address,
|
||||
request: TypedTransactionRequest,
|
||||
) -> EthResult<TransactionSigned> {
|
||||
for signer in self.inner.signers.read().iter() {
|
||||
if signer.is_signer_for(from) {
|
||||
return match signer.sign_transaction(request, from) {
|
||||
Ok(tx) => Ok(tx),
|
||||
Err(e) => Err(e.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(EthApiError::InvalidTransactionSignature)
|
||||
}
|
||||
|
||||
/// Get Transaction by [BlockId] and the index of the transaction within that Block.
|
||||
///
|
||||
/// Returns `Ok(None)` if the block does not exist, or the block as fewer transactions
|
||||
pub(crate) async fn transaction_by_block_and_tx_index(
|
||||
&self,
|
||||
block_id: impl Into<BlockId>,
|
||||
index: Index,
|
||||
) -> EthResult<Option<Transaction>> {
|
||||
if let Some(block) = self.block_with_senders(block_id.into()).await? {
|
||||
let block_hash = block.hash();
|
||||
let block_number = block.number;
|
||||
let base_fee_per_gas = block.base_fee_per_gas;
|
||||
if let Some(tx) = block.into_transactions_ecrecovered().nth(index.into()) {
|
||||
return Ok(Some(from_recovered_with_block_context(
|
||||
tx,
|
||||
block_hash,
|
||||
block_number,
|
||||
base_fee_per_gas,
|
||||
index.into(),
|
||||
)))
|
||||
}
|
||||
}
|
||||
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
pub(crate) async fn raw_transaction_by_block_and_tx_index(
|
||||
&self,
|
||||
block_id: impl Into<BlockId>,
|
||||
index: Index,
|
||||
) -> EthResult<Option<Bytes>> {
|
||||
if let Some(block) = self.block_with_senders(block_id.into()).await? {
|
||||
if let Some(tx) = block.transactions().nth(index.into()) {
|
||||
return Ok(Some(tx.envelope_encoded()))
|
||||
}
|
||||
}
|
||||
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
impl<Provider, Pool, Network, EvmConfig> EthApi<Provider, Pool, Network, EvmConfig>
|
||||
where
|
||||
Provider:
|
||||
BlockReaderIdExt + ChainSpecProvider + StateProviderFactory + EvmEnvProvider + 'static,
|
||||
Network: NetworkInfo + 'static,
|
||||
Provider: BlockReaderIdExt + ChainSpecProvider,
|
||||
{
|
||||
/// Helper function for `eth_getTransactionReceipt`
|
||||
///
|
||||
@ -1545,70 +1595,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<Provider, Pool, Network, EvmConfig> EthApi<Provider, Pool, Network, EvmConfig>
|
||||
where
|
||||
Pool: TransactionPool + 'static,
|
||||
Provider:
|
||||
BlockReaderIdExt + ChainSpecProvider + StateProviderFactory + EvmEnvProvider + 'static,
|
||||
Network: NetworkInfo + Send + Sync + 'static,
|
||||
EvmConfig: ConfigureEvm + 'static,
|
||||
{
|
||||
pub(crate) fn sign_request(
|
||||
&self,
|
||||
from: &Address,
|
||||
request: TypedTransactionRequest,
|
||||
) -> EthResult<TransactionSigned> {
|
||||
for signer in self.inner.signers.read().iter() {
|
||||
if signer.is_signer_for(from) {
|
||||
return match signer.sign_transaction(request, from) {
|
||||
Ok(tx) => Ok(tx),
|
||||
Err(e) => Err(e.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(EthApiError::InvalidTransactionSignature)
|
||||
}
|
||||
|
||||
/// Get Transaction by [BlockId] and the index of the transaction within that Block.
|
||||
///
|
||||
/// Returns `Ok(None)` if the block does not exist, or the block as fewer transactions
|
||||
pub(crate) async fn transaction_by_block_and_tx_index(
|
||||
&self,
|
||||
block_id: impl Into<BlockId>,
|
||||
index: Index,
|
||||
) -> EthResult<Option<Transaction>> {
|
||||
if let Some(block) = self.block_with_senders(block_id.into()).await? {
|
||||
let block_hash = block.hash();
|
||||
let block_number = block.number;
|
||||
let base_fee_per_gas = block.base_fee_per_gas;
|
||||
if let Some(tx) = block.into_transactions_ecrecovered().nth(index.into()) {
|
||||
return Ok(Some(from_recovered_with_block_context(
|
||||
tx,
|
||||
block_hash,
|
||||
block_number,
|
||||
base_fee_per_gas,
|
||||
index.into(),
|
||||
)))
|
||||
}
|
||||
}
|
||||
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
pub(crate) async fn raw_transaction_by_block_and_tx_index(
|
||||
&self,
|
||||
block_id: impl Into<BlockId>,
|
||||
index: Index,
|
||||
) -> EthResult<Option<Bytes>> {
|
||||
if let Some(block) = self.block_with_senders(block_id.into()).await? {
|
||||
if let Some(tx) = block.transactions().nth(index.into()) {
|
||||
return Ok(Some(tx.envelope_encoded()))
|
||||
}
|
||||
}
|
||||
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
/// Represents from where a transaction was fetched.
|
||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||
pub enum TransactionSource {
|
||||
|
||||
Reference in New Issue
Block a user