From 97083e4592ece5dc3383d07bb9a19377444cf275 Mon Sep 17 00:00:00 2001 From: lunar-mining Date: Mon, 27 Sep 2021 10:10:38 +0200 Subject: [PATCH] renamed parse_id to generate_id --- src/bin/cashierd.rs | 6 +++--- src/bin/darkfid.rs | 7 ++++--- src/util.rs | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/bin/cashierd.rs b/src/bin/cashierd.rs index d2f588e07..fe4315606 100644 --- a/src/bin/cashierd.rs +++ b/src/bin/cashierd.rs @@ -20,7 +20,7 @@ use drk::{ }, serial::{deserialize, serialize}, service::{bridge, bridge::Bridge}, - util::{expand_path, join_config_path}, + util::{expand_path, generate_id, join_config_path}, wallet::{CashierDb, WalletDb}, Error, Result, }; @@ -298,7 +298,7 @@ impl Cashierd { let result: Result = async { Self::check_token_id(&network, token_id.as_str().unwrap())?; - let asset_id = drk::util::parse_id(token_id)?; + let asset_id = generate_id(token_id)?; let drk_pub_key = bs58::decode(&drk_pub_key).into_vec()?; let drk_pub_key: jubjub::SubgroupPoint = deserialize(&drk_pub_key)?; @@ -393,7 +393,7 @@ impl Cashierd { let result: Result = async { Self::check_token_id(&network, token.as_str().unwrap())?; - let asset_id = drk::util::parse_id(&token)?; + let asset_id = generate_id(&token)?; let address = serialize(&address.to_string()); let cashier_public: jubjub::SubgroupPoint; diff --git a/src/bin/darkfid.rs b/src/bin/darkfid.rs index 4b20263e8..9991844a1 100644 --- a/src/bin/darkfid.rs +++ b/src/bin/darkfid.rs @@ -16,7 +16,7 @@ use drk::{ rpcserver::{listen_and_serve, RequestHandler, RpcServerConfig}, }, serial::{deserialize, serialize}, - util::{expand_path, join_config_path, parse_id}, + util::{expand_path, generate_id, join_config_path}, wallet::WalletDb, Error, Result, }; @@ -349,13 +349,13 @@ impl Darkfid { match token.as_str() { Some("sol") | Some("SOL") => { let id = "So11111111111111111111111111111111111111112"; - let token_id = parse_id(&json!(id))?; + let token_id = generate_id(&json!(id))?; Ok(token_id) } Some("btc") | Some("BTC") => Err(Error::TokenParseError), Some(tkn) => { let id = self.parse_token(tkn)?; - let token_id = parse_id(&id)?; + let token_id = generate_id(&id)?; Ok(token_id) } None => Err(Error::TokenParseError), @@ -380,6 +380,7 @@ impl Darkfid { } } + // symbol to id fn parse_token(&self, token: &str) -> Result { let vec: Vec = token.chars().collect(); let mut counter = 0; diff --git a/src/util.rs b/src/util.rs index ad3c89cf5..aaf323b82 100644 --- a/src/util.rs +++ b/src/util.rs @@ -40,7 +40,7 @@ pub fn join_config_path(file: &Path) -> Result { // here we hash the alphanumeric token ID. if it fails, we change the last 4 bytes and hash it // again, and keep repeating until it works. -pub fn parse_id(token: &Value) -> Result { +pub fn generate_id(token: &Value) -> Result { let tkn_str = token.as_str().unwrap(); if bs58::decode(tkn_str).into_vec().is_err() { // TODO: make this an error