mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
util: generate_id() function take &str as token_id instead of
json::Value
This commit is contained in:
@@ -349,13 +349,13 @@ impl Darkfid {
|
||||
match token.as_str() {
|
||||
Some("sol") | Some("SOL") => {
|
||||
let id = "So11111111111111111111111111111111111111112";
|
||||
let token_id = generate_id(&json!(id))?;
|
||||
let token_id = generate_id(id)?;
|
||||
Ok(token_id)
|
||||
}
|
||||
Some("btc") | Some("BTC") => Err(Error::TokenParseError),
|
||||
Some(tkn) => {
|
||||
let id = self.symbol_to_id(tkn)?;
|
||||
let token_id = generate_id(&id)?;
|
||||
let token_id = generate_id(id.as_str().unwrap())?;
|
||||
Ok(token_id)
|
||||
}
|
||||
None => Err(Error::TokenParseError),
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use log::debug;
|
||||
use serde_json::Value;
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
@@ -40,8 +39,7 @@ pub fn join_config_path(file: &Path) -> Result<PathBuf> {
|
||||
|
||||
// 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 generate_id(token: &Value) -> Result<jubjub::Fr> {
|
||||
let tkn_str = token.as_str().unwrap();
|
||||
pub fn generate_id(tkn_str: &str) -> Result<jubjub::Fr> {
|
||||
if bs58::decode(tkn_str).into_vec().is_err() {
|
||||
// TODO: make this an error
|
||||
debug!(target: "PARSE ID", "COULD NOT DECODE STR");
|
||||
|
||||
Reference in New Issue
Block a user