From 9206efa46c07fa95216b521b7423c35d46500deb Mon Sep 17 00:00:00 2001 From: James Prestwich <10149425+prestwich@users.noreply.github.com> Date: Sun, 10 Apr 2022 09:04:43 -0700 Subject: [PATCH] fixes: correct etherscan url address, remove double quotes in solc error (#1130) --- CHANGELOG.md | 1 + ethers-etherscan/src/lib.rs | 24 ++++++++++++------------ ethers-solc/src/lib.rs | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07c18d83..10c47343 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -107,6 +107,7 @@ some files - Add support for library linking and make `Bytecode`'s `object` filed an `enum BytecodeObject` [#656](https://github.com/gakonst/ethers-rs/pull/656). +- Nit: remove accidentally doubled double-quotes in an error message ### 0.6.0 diff --git a/ethers-etherscan/src/lib.rs b/ethers-etherscan/src/lib.rs index b1385724..2a6213eb 100644 --- a/ethers-etherscan/src/lib.rs +++ b/ethers-etherscan/src/lib.rs @@ -14,7 +14,7 @@ use serde::{de::DeserializeOwned, Deserialize, Serialize}; use errors::EtherscanError; use ethers_core::{ abi::{Abi, Address}, - types::Chain, + types::{Chain, H256}, }; pub mod account; @@ -247,17 +247,17 @@ impl Client { /// Return the URL for the given address pub fn address_url(&self, address: Address) -> String { - format!("{}address/{}", self.etherscan_url, address) + format!("{}address/{:?}", self.etherscan_url, address) } /// Return the URL for the given transaction hash - pub fn transaction_url(&self, tx_hash: impl AsRef) -> String { - format!("{}tx/{}", self.etherscan_url, tx_hash.as_ref()) + pub fn transaction_url(&self, tx_hash: H256) -> String { + format!("{}tx/{:?}", self.etherscan_url, tx_hash) } /// Return the URL for the given token hash - pub fn token_url(&self, token_hash: impl AsRef) -> String { - format!("{}token/{}", self.etherscan_url, token_hash.as_ref()) + pub fn token_url(&self, token_hash: Address) -> String { + format!("{}token/{:?}", self.etherscan_url, token_hash) } /// Execute an API POST request with a form @@ -347,7 +347,7 @@ mod tests { time::{Duration, SystemTime}, }; - use ethers_core::types::{Address, Chain}; + use ethers_core::types::{Address, Chain, H256}; use crate::{Client, EtherscanError}; @@ -372,23 +372,23 @@ mod tests { let etherscan = Client::new_from_env(Chain::Mainnet).unwrap(); let addr: Address = Address::zero(); let address_url: String = etherscan.address_url(addr); - assert_eq!(address_url, format!("https://etherscan.io/address/{}", addr)); + assert_eq!(address_url, format!("https://etherscan.io/address/{:?}", addr)); } #[test] fn stringifies_transaction_url() { let etherscan = Client::new_from_env(Chain::Mainnet).unwrap(); - let tx_hash = "0x0"; + let tx_hash = H256::zero(); let tx_url: String = etherscan.transaction_url(tx_hash); - assert_eq!(tx_url, format!("https://etherscan.io/tx/{}", tx_hash)); + assert_eq!(tx_url, format!("https://etherscan.io/tx/{:?}", tx_hash)); } #[test] fn stringifies_token_url() { let etherscan = Client::new_from_env(Chain::Mainnet).unwrap(); - let token_hash = "0x0"; + let token_hash = Address::zero(); let token_url: String = etherscan.token_url(token_hash); - assert_eq!(token_url, format!("https://etherscan.io/token/{}", token_hash)); + assert_eq!(token_url, format!("https://etherscan.io/token/{:?}", token_hash)); } #[test] diff --git a/ethers-solc/src/lib.rs b/ethers-solc/src/lib.rs index a65cc728..506b8c9f 100644 --- a/ethers-solc/src/lib.rs +++ b/ethers-solc/src/lib.rs @@ -432,7 +432,7 @@ impl Project { tracing::trace!("Building standard-json-input"); let graph = Graph::resolve(&self.paths)?; let target_index = graph.files().get(target).ok_or_else(|| { - SolcError::msg(format!("cannot resolve file at \"{:?}\"", target.display())) + SolcError::msg(format!("cannot resolve file at {:?}", target.display())) })?; let mut sources = Vec::new(); let (path, source) = graph.node(*target_index).unpack();