Skip to content

Commit af58ddf

Browse files
authored
chore: relax receipt fn bounds (#2538)
* chore: relax receipt fn bounds * docs: rm wrong note about from field
1 parent 5b10db2 commit af58ddf

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

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

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -155,27 +155,6 @@ impl TransactionReceipt {
155155
pub const fn transaction_type(&self) -> TxType {
156156
self.inner.tx_type()
157157
}
158-
159-
/// Calculates the address that will be created by the transaction, if any.
160-
///
161-
/// Returns `None` if the transaction is not a contract creation (the `to` field is set), or if
162-
/// the `from` field is not set.
163-
pub fn calculate_create_address(&self, nonce: u64) -> Option<Address> {
164-
if self.to.is_some() {
165-
return None;
166-
}
167-
Some(self.from.create(nonce))
168-
}
169-
170-
/// Attempts to decode the logs to the provided log type.
171-
///
172-
/// Returns the first log that decodes successfully.
173-
///
174-
/// Returns None, if none of the logs could be decoded to the provided log type or if there
175-
/// are no logs.
176-
pub fn decoded_log<E: SolEvent>(&self) -> Option<alloy_primitives::Log<E>> {
177-
self.logs().iter().find_map(|log| E::decode_log(&log.inner).ok())
178-
}
179158
}
180159

181160
impl<T> TransactionReceipt<T> {
@@ -204,6 +183,16 @@ impl<T> TransactionReceipt<T> {
204183
pub fn into_inner(self) -> T {
205184
self.inner
206185
}
186+
187+
/// Calculates the address that will be created by the transaction, if any.
188+
///
189+
/// Returns `None` if the transaction is not a contract creation (the `to` field is set).
190+
pub fn calculate_create_address(&self, nonce: u64) -> Option<Address> {
191+
if self.to.is_some() {
192+
return None;
193+
}
194+
Some(self.from.create(nonce))
195+
}
207196
}
208197

209198
impl<L> TransactionReceipt<ReceiptEnvelope<L>> {
@@ -225,12 +214,25 @@ impl<L> TransactionReceipt<ReceiptEnvelope<L>> {
225214
{
226215
self.map_logs(Into::into)
227216
}
217+
}
228218

219+
impl<T: TxReceipt> TransactionReceipt<T> {
229220
/// Get the receipt logs.
230-
pub fn logs(&self) -> &[L] {
221+
pub fn logs(&self) -> &[T::Log] {
231222
self.inner.logs()
232223
}
233224
}
225+
impl<T: TxReceipt<Log: AsRef<alloy_primitives::Log>>> TransactionReceipt<T> {
226+
/// Attempts to decode the logs to the provided log type.
227+
///
228+
/// Returns the first log that decodes successfully.
229+
///
230+
/// Returns None, if none of the logs could be decoded to the provided log type or if there
231+
/// are no logs.
232+
pub fn decoded_log<E: SolEvent>(&self) -> Option<alloy_primitives::Log<E>> {
233+
self.logs().iter().find_map(|log| E::decode_log(log.as_ref()).ok())
234+
}
235+
}
234236

235237
impl<T: TxReceipt<Log = Log>> ReceiptResponse for TransactionReceipt<T> {
236238
fn contract_address(&self) -> Option<Address> {

0 commit comments

Comments
 (0)