Added from<alloy_rpc_types_eth::Transaction> for TransactionSigned (#14350)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Poulav Bhowmick
2025-02-10 22:57:49 +05:30
committed by GitHub
parent 30488a1292
commit cdb7c63d51
5 changed files with 17 additions and 13 deletions

View File

@ -24,7 +24,7 @@ alloy-network = { workspace = true, optional = true }
alloy-consensus = { workspace = true, features = ["serde"] }
alloy-serde = { workspace = true, optional = true }
alloy-rlp.workspace = true
alloy-rpc-types = { workspace = true, optional = true }
alloy-rpc-types-eth = { workspace = true, optional = true }
revm-primitives.workspace = true
# misc
@ -54,7 +54,7 @@ test-utils = [
"reth-codecs?/test-utils",
"reth-primitives-traits/test-utils",
]
alloy-compat = ["dep:alloy-network", "dep:alloy-serde", "dep:alloy-rpc-types"]
alloy-compat = ["dep:alloy-network", "dep:alloy-serde", "dep:alloy-rpc-types-eth"]
std = [
"alloy-consensus/std",
"alloy-primitives/std",
@ -67,6 +67,7 @@ std = [
"secp256k1?/std",
"revm-primitives/std",
"alloy-serde?/std",
"alloy-rpc-types-eth?/std",
]
reth-codec = [
"std",
@ -84,8 +85,8 @@ arbitrary = [
"reth-primitives-traits/arbitrary",
"alloy-eips/arbitrary",
"revm-primitives/arbitrary",
"alloy-rpc-types?/arbitrary",
"alloy-serde?/arbitrary",
"alloy-rpc-types-eth?/arbitrary",
]
serde-bincode-compat = [
"alloy-consensus/serde-bincode-compat",

View File

@ -4,13 +4,14 @@ use crate::{Transaction, TransactionSigned};
use alloc::string::ToString;
use alloy_consensus::TxEnvelope;
use alloy_network::{AnyRpcTransaction, AnyTxEnvelope};
use alloy_rpc_types_eth::Transaction as AlloyRpcTransaction;
use alloy_serde::WithOtherFields;
impl TryFrom<AnyRpcTransaction> for TransactionSigned {
type Error = alloy_rpc_types::ConversionError;
type Error = alloy_rpc_types_eth::ConversionError;
fn try_from(tx: AnyRpcTransaction) -> Result<Self, Self::Error> {
use alloy_rpc_types::ConversionError;
use alloy_rpc_types_eth::ConversionError;
let WithOtherFields { inner: tx, other: _ } = tx;
@ -41,3 +42,12 @@ impl TryFrom<AnyRpcTransaction> for TransactionSigned {
Ok(Self::new(transaction, signature, hash))
}
}
impl<T> From<AlloyRpcTransaction<T>> for TransactionSigned
where
Self: From<T>,
{
fn from(value: AlloyRpcTransaction<T>) -> Self {
value.inner.into()
}
}

View File

@ -6,7 +6,6 @@
issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;