diff --git a/src/bin/darkfid.rs b/src/bin/darkfid.rs index 363965c42..ed1f19709 100644 --- a/src/bin/darkfid.rs +++ b/src/bin/darkfid.rs @@ -17,7 +17,7 @@ use drk::{ rpcserver::{listen_and_serve, RequestHandler, RpcServerConfig}, }, serial::{deserialize, serialize}, - util::{expand_path, join_config_path, parse_network, parse_wrapped_token, TokenList}, + util::{assign_id, expand_path, join_config_path, parse_wrapped_token, TokenList}, wallet::WalletDb, Result, }; @@ -213,7 +213,7 @@ impl Darkfid { let network = network.as_str().unwrap(); - let token_id = match parse_network(&network, &token, self.tokenlist.clone()) { + let token_id = match assign_id(&network, &token, self.tokenlist.clone()) { Ok(t) => t, Err(_e) => { debug!(target: "DARKFID", "TOKEN ID IS ERR"); diff --git a/src/util/parse.rs b/src/util/parse.rs index 9bc6c702f..6dd01f2f5 100644 --- a/src/util/parse.rs +++ b/src/util/parse.rs @@ -9,6 +9,7 @@ use sha2::{Digest, Sha256}; use std::str::FromStr; //1. deposit(network, asset) +// //internal ID = hash(externalID, NetworkName) //deposit(internalID) @@ -25,6 +26,32 @@ use std::str::FromStr; //transfer(token_id, amountu64, address) // // +// +// +// +// extern_tokenID +// tokenID +// + +//pub fn create_id(extern_tokenID, NetworkName) -> Result { +//} + +// DEPOSIT +// parse_network +// parse_id + +// generate_id +// +// WITHDRAW +// parse_network +// parse_id +// +// generate_id +// amount.to_u64() +// +// TRANSFER +// get_id +// amount.to_u64() // 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. @@ -82,7 +109,7 @@ pub fn parse_wrapped_token(token: &str, tokenlist: TokenList) -> Result Result { +pub fn assign_id(network: &str, token: &str, tokenlist: TokenList) -> Result { match NetworkName::from_str(network)? { NetworkName::Solana => match token.to_lowercase().as_str() { "solana" | "sol" => {