From 13bc50462d86a48402f9836bcae05df842a8fe01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= Date: Mon, 4 Jun 2018 15:00:30 +0100 Subject: [PATCH 1/2] rpc: fix address formatting in TransactionRequest Display --- rpc/src/v1/types/transaction_request.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rpc/src/v1/types/transaction_request.rs b/rpc/src/v1/types/transaction_request.rs index 7fed6f681a0..4c7e4463262 100644 --- a/rpc/src/v1/types/transaction_request.rs +++ b/rpc/src/v1/types/transaction_request.rs @@ -69,14 +69,16 @@ impl fmt::Display for TransactionRequest { f, "{} ETH from {} to 0x{:?}", Colour::White.bold().paint(format_ether(eth)), - Colour::White.bold().paint(format!("0x{:?}", self.from)), + Colour::White.bold().paint( + self.from.as_ref().map(|f| format!("0x{:?}", f)).unwrap_or("?".to_string())), to ), None => write!( f, "{} ETH from {} for contract creation", Colour::White.bold().paint(format_ether(eth)), - Colour::White.bold().paint(format!("0x{:?}", self.from)), + Colour::White.bold().paint( + self.from.as_ref().map(|f| format!("0x{:?}", f)).unwrap_or("?".to_string())), ), } } From 751a7912336c2833ba5a33a00aa9147b9a99c98f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= Date: Mon, 4 Jun 2018 16:03:07 +0100 Subject: [PATCH 2/2] rpc: use unwrap_or_else when no to address provided --- rpc/src/v1/types/transaction_request.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rpc/src/v1/types/transaction_request.rs b/rpc/src/v1/types/transaction_request.rs index 4c7e4463262..4fa47b5acd6 100644 --- a/rpc/src/v1/types/transaction_request.rs +++ b/rpc/src/v1/types/transaction_request.rs @@ -70,7 +70,9 @@ impl fmt::Display for TransactionRequest { "{} ETH from {} to 0x{:?}", Colour::White.bold().paint(format_ether(eth)), Colour::White.bold().paint( - self.from.as_ref().map(|f| format!("0x{:?}", f)).unwrap_or("?".to_string())), + self.from.as_ref() + .map(|f| format!("0x{:?}", f)) + .unwrap_or_else(|| "?".to_string())), to ), None => write!( @@ -78,7 +80,9 @@ impl fmt::Display for TransactionRequest { "{} ETH from {} for contract creation", Colour::White.bold().paint(format_ether(eth)), Colour::White.bold().paint( - self.from.as_ref().map(|f| format!("0x{:?}", f)).unwrap_or("?".to_string())), + self.from.as_ref() + .map(|f| format!("0x{:?}", f)) + .unwrap_or_else(|| "?".to_string())), ), } }