renamed parse_network to assign_id

This commit is contained in:
lunar-mining
2021-09-30 11:22:34 +02:00
parent 181d337d6e
commit a5f0e629ce
2 changed files with 30 additions and 3 deletions

View File

@@ -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");

View File

@@ -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<jubjub::Fr> {
//}
// 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<jubjub::
}
}
pub fn parse_network(network: &str, token: &str, tokenlist: TokenList) -> Result<String> {
pub fn assign_id(network: &str, token: &str, tokenlist: TokenList) -> Result<String> {
match NetworkName::from_str(network)? {
NetworkName::Solana => match token.to_lowercase().as_str() {
"solana" | "sol" => {