Syntax cleanups.

This commit is contained in:
parazyd
2021-10-11 10:51:55 +02:00
parent 5325fe7d3c
commit fa8a07d4ca
4 changed files with 15 additions and 21 deletions

View File

@@ -125,7 +125,7 @@ impl Client {
debug!(target: "CLIENT", "Start transfer {}", amount);
if amount == 0 {
return Err(ClientFailed::InvalidAmount(amount as u64).into());
return Err(ClientFailed::InvalidAmount(amount as u64));
}
let token_id_exists = self.state.lock().await.wallet.token_id_exists(&token_id)?;
@@ -349,9 +349,7 @@ impl Client {
let secret_keys: Vec<jubjub::Fr> = vec![secret_key];
let state_apply = state
.apply(update?, secret_keys.clone(), None)
.await;
let state_apply = state.apply(update?, secret_keys.clone(), None).await;
if let Err(e) = state_apply {
warn!("apply state: {}", e.to_string());

View File

@@ -83,7 +83,7 @@ impl SolClient {
}))
}
async fn handle_subscribe_request(
async fn handle_subscribe_request(
self: Arc<Self>,
keypair: Keypair,
drk_pub_key: jubjub::SubgroupPoint,
@@ -157,14 +157,11 @@ impl SolClient {
let message = read.next().await.ok_or(Error::TungsteniteError)?;
let message = message?;
match message.clone() {
Message::Pong(_) => {
async_std::task::sleep(Duration::from_secs(1)).await;
write.send(Message::Ping(ping_payload.clone())).await?;
continue;
}
_ => {}
}
if let Message::Pong(_) = message.clone() {
async_std::task::sleep(Duration::from_secs(1)).await;
write.send(Message::Ping(ping_payload.clone())).await?;
continue;
};
match serde_json::from_slice(&message.into_data())? {
JsonResult::Resp(r) => {

View File

@@ -1,4 +1,3 @@
use log::debug;
use sha2::{Digest, Sha256};
use std::iter::FromIterator;
use std::str::FromStr;
@@ -43,7 +42,7 @@ pub fn generate_id(tkn_str: &str, network: &NetworkName) -> Result<jubjub::Fr> {
}
pub fn assign_id(network: &str, token: &str, _tokenlist: &SolTokenList) -> Result<String> {
let token = token.to_lowercase().clone();
let token = token.to_lowercase();
let _token = token.as_str();
match NetworkName::from_str(network)? {
#[cfg(feature = "sol")]
@@ -68,9 +67,9 @@ pub fn decimals(network: &str, _token: &str, _tokenlist: &SolTokenList) -> Resul
NetworkName::Solana => {
let decimals = _tokenlist.search_decimal(_token)?;
if let Some(decimals) = decimals {
return Ok(decimals);
Ok(decimals)
} else {
return Err(Error::NotSupportedToken);
Err(Error::NotSupportedToken)
}
}
#[cfg(feature = "btc")]
@@ -89,9 +88,9 @@ pub fn symbol_to_id(token: &str, tokenlist: &SolTokenList) -> Result<String> {
}
if counter == token.len() {
if let Some(id) = tokenlist.search_id(token)? {
return Ok(id);
Ok(id)
} else {
return Err(Error::TokenParseError);
Err(Error::TokenParseError)
}
} else {
Ok(token.to_string())

View File

@@ -29,7 +29,7 @@ impl SolTokenList {
let symbol = item["symbol"].as_str().unwrap();
symbols.push(symbol.to_string());
}
return Ok(symbols);
Ok(symbols)
}
pub fn search_id(&self, symbol: &str) -> Result<Option<String>> {
@@ -63,7 +63,7 @@ pub struct DrkTokenList {
impl DrkTokenList {
pub fn new(sol_list: SolTokenList) -> Result<Self> {
let sol_symbols = sol_list.clone().get_symbols()?;
let sol_symbols = sol_list.get_symbols()?;
let tokens: HashMap<String, jubjub::Fr> = sol_symbols
.iter()