Skip to content

Commit df5b08a

Browse files
committed
feat: asref bound for transaction response
1 parent ee7ce99 commit df5b08a

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

crates/network/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub trait Network: Debug + Clone + Copy + Sized + Send + Sync + 'static {
8080

8181
/// The JSON body of a transaction response.
8282
#[doc(alias = "TxResponse")]
83-
type TransactionResponse: RpcObject + TransactionResponse;
83+
type TransactionResponse: RpcObject + TransactionResponse + AsRef<Self::TxEnvelope>;
8484

8585
/// The JSON body of a transaction receipt.
8686
#[doc(alias = "TransactionReceiptResponse", alias = "TxReceiptResponse")]

crates/rpc-types-eth/src/transaction/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ pub struct Transaction<T = TxEnvelope> {
6161
// pub hash: B256,
6262
}
6363

64+
impl<T> AsRef<T> for Transaction<T> {
65+
fn as_ref(&self) -> &T {
66+
&self.inner
67+
}
68+
}
69+
6470
impl<T> TransactionTrait for Transaction<T>
6571
where
6672
T: TransactionTrait,

crates/serde/src/other/mod.rs

+9
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,15 @@ pub struct WithOtherFields<T> {
178178
pub other: OtherFields,
179179
}
180180

181+
impl<T, U> AsRef<U> for WithOtherFields<T>
182+
where
183+
T: AsRef<U>,
184+
{
185+
fn as_ref(&self) -> &U {
186+
self.inner.as_ref()
187+
}
188+
}
189+
181190
impl<T> WithOtherFields<T> {
182191
/// Creates a new [`WithOtherFields`] instance.
183192
pub fn new(inner: T) -> Self {

0 commit comments

Comments
 (0)