From 14551a90c1e31e549b41fc81c7965a8422c18d03 Mon Sep 17 00:00:00 2001 From: wolflo <33909953+wolflo@users.noreply.github.com> Date: Tue, 8 Feb 2022 23:48:03 -0700 Subject: [PATCH] fix(providers): PendingTransaction::log() missing deref (#886) --- ethers-providers/src/pending_transaction.rs | 23 +++++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/ethers-providers/src/pending_transaction.rs b/ethers-providers/src/pending_transaction.rs index c59f9623..05298a25 100644 --- a/ethers-providers/src/pending_transaction.rs +++ b/ethers-providers/src/pending_transaction.rs @@ -25,11 +25,15 @@ use wasm_timer::Delay; /// once the transaction has enough `confirmations`. The default number of confirmations /// is 1, but may be adjusted with the `confirmations` method. If the transaction does not /// have enough confirmations or is not mined, the future will stay in the pending state. +/// +/// # Example +/// ///``` -/// use ethers_providers::{Provider, Http, Middleware}; +/// # use ethers_providers::{Provider, Http}; +/// # use ethers_core::utils::Ganache; +/// # use std::convert::TryFrom; +/// use ethers_providers::Middleware; /// use ethers_core::types::TransactionRequest; -/// use ethers_core::utils::Ganache; -/// use std::convert::TryFrom; /// /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() -> Result<(), Box> { @@ -106,8 +110,9 @@ impl<'a, P: JsonRpcClient> PendingTransaction<'a, P> { impl<'a, P> PendingTransaction<'a, P> { /// Allows inspecting the content of a pending transaction in a builder-like way to avoid - /// more verbose calls, e.g.: - /// `let mined = token.transfer(recipient, amt).send().await?.inspect(|tx| println!(".{}", *tx)).await?;` + /// more verbose calls, e.g.: + /// `let mined = token.transfer(recipient, amt).send().await?.inspect(|tx| println!(".{}", + /// *tx)).await?;` pub fn inspect(self, mut f: F) -> Self where F: FnMut(&Self), @@ -115,15 +120,15 @@ impl<'a, P> PendingTransaction<'a, P> { f(&self); self } - + /// Logs the pending transaction hash along with a custom message before it. pub fn log_msg(self, msg: S) -> Self { - self.inspect(|s| println!("{}: {:?}", msg, *s)) + self.inspect(|s| println!("{}: {:?}", msg, **s)) } - + /// Logs the pending transaction's hash pub fn log(self) -> Self { - self.inspect(|s| println!("Pending hash: {:?}", *s)) + self.inspect(|s| println!("Pending hash: {:?}", **s)) } }