Skip to content

Commit

Permalink
Reduce ETH RPC calls error output by using Display instead of Debug #418
Browse files Browse the repository at this point in the history
  • Loading branch information
artemii235 committed May 31, 2019
1 parent 6ef9e00 commit d794c7b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions mm2src/coins/eth.rs
Expand Up @@ -484,7 +484,7 @@ impl MarketCoinOps for EthCoin {
}

fn current_block(&self) -> Box<Future<Item=u64, Error=String> + Send> {
Box::new(self.web3.eth().block_number().map(|res| res.into()).map_err(|e| ERRL!("{:?}", e)))
Box::new(self.web3.eth().block_number().map(|res| res.into()).map_err(|e| ERRL!("{}", e)))
}
}

Expand Down Expand Up @@ -735,7 +735,7 @@ impl EthCoin {

fn my_balance(&self) -> Box<Future<Item=U256, Error=String> + Send> {
match self.coin_type {
EthCoinType::Eth => Box::new(self.web3.eth().balance(self.my_address, Some(BlockNumber::Latest)).map_err(|e| ERRL!("{:?}", e))),
EthCoinType::Eth => Box::new(self.web3.eth().balance(self.my_address, Some(BlockNumber::Latest)).map_err(|e| ERRL!("{}", e))),
EthCoinType::Erc20(token_addr) => {
let function = try_fus!(ERC20_CONTRACT.function("balanceOf"));
let data = try_fus!(function.encode_input(&[
Expand All @@ -757,7 +757,7 @@ impl EthCoin {
}

fn eth_balance(&self) -> Box<Future<Item=U256, Error=String> + Send> {
Box::new(self.web3.eth().balance(self.my_address, Some(BlockNumber::Latest)).map_err(|e| ERRL!("{:?}", e)))
Box::new(self.web3.eth().balance(self.my_address, Some(BlockNumber::Latest)).map_err(|e| ERRL!("{}", e)))
}

fn call_request(&self, to: Address, value: Option<U256>, data: Option<Bytes>) -> impl Future<Item=Bytes, Error=String> {
Expand All @@ -770,7 +770,7 @@ impl EthCoin {
data
};

self.web3.eth().call(request, Some(BlockNumber::Latest)).map_err(|e| ERRL!("{:?}", e))
self.web3.eth().call(request, Some(BlockNumber::Latest)).map_err(|e| ERRL!("{}", e))
}

fn allowance(&self, spender: Address) -> Box<Future<Item=U256, Error=String> + Send + 'static> {
Expand Down Expand Up @@ -821,7 +821,7 @@ impl EthCoin {
.address(vec![self.swap_contract_address])
.build();

Box::new(self.web3.eth().logs(filter).map_err(|e| ERRL!("{:?}", e)))
Box::new(self.web3.eth().logs(filter).map_err(|e| ERRL!("{}", e)))
}

fn validate_payment(
Expand Down Expand Up @@ -1702,7 +1702,7 @@ fn get_token_decimals(web3: &Web3<Web3Transport>, token_addr: Address) -> Result
data: Some(data.into())
};

let f = web3.eth().call(request, Some(BlockNumber::Latest)).map_err(|e| ERRL!("{:?}", e));
let f = web3.eth().call(request, Some(BlockNumber::Latest)).map_err(|e| ERRL!("{}", e));
let res = try_s!(f.wait());
let tokens = try_s!(function.decode_output(&res.0));
let decimals: u64 = match tokens[0] {
Expand Down
2 changes: 1 addition & 1 deletion mm2src/coins/eth/web3_transport.rs
Expand Up @@ -16,7 +16,7 @@ use web3::helpers::{build_request, to_result_from_output, to_string};
/// Parse bytes RPC response into `Result`.
/// Implementation copied from Web3 HTTP transport
fn single_response<T: Deref<Target = [u8]>>(response: T) -> Result<Json, Error> {
let response = serde_json::from_slice(&*response).map_err(|e| Error::from(ErrorKind::InvalidResponse(format!("{:?}", e))))?;
let response = serde_json::from_slice(&*response).map_err(|e| Error::from(ErrorKind::InvalidResponse(format!("{}", e))))?;

match response {
Response::Single(output) => to_result_from_output(output),
Expand Down

0 comments on commit d794c7b

Please sign in to comment.