mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
Revert "src/util: made TokenList struct called in darkfid::main()"
This reverts commit 873d259bd2.
This commit is contained in:
@@ -17,9 +17,7 @@ use drk::{
|
||||
rpcserver::{listen_and_serve, RequestHandler, RpcServerConfig},
|
||||
},
|
||||
serial::{deserialize, serialize},
|
||||
util::{
|
||||
expand_path, join_config_path, parse_network, parse_wrapped_token, search_id, TokenList,
|
||||
},
|
||||
util::{expand_path, join_config_path, parse_network, parse_wrapped_token, search_id},
|
||||
wallet::WalletDb,
|
||||
Result,
|
||||
};
|
||||
@@ -351,8 +349,6 @@ impl Darkfid {
|
||||
|
||||
#[async_std::main]
|
||||
async fn main() -> Result<()> {
|
||||
let _tokens = TokenList::new()?;
|
||||
|
||||
let args = clap_app!(darkfid =>
|
||||
(@arg CONFIG: -c --config +takes_value "Sets a custom config file")
|
||||
(@arg verbose: -v --verbose "Increase verbosity")
|
||||
|
||||
33
src/util.rs
33
src/util.rs
@@ -6,22 +6,9 @@ use crate::{
|
||||
use log::debug;
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
use serde_json::Value;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::str::FromStr;
|
||||
|
||||
pub struct TokenList {
|
||||
tokenlist: Value,
|
||||
}
|
||||
|
||||
impl TokenList {
|
||||
pub fn new() -> Result<Self> {
|
||||
let file_contents = std::fs::read_to_string("token/solanatokenlist.json")?;
|
||||
let tokenlist: serde_json::Value = serde_json::from_str(&file_contents)?;
|
||||
Ok(Self { tokenlist })
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expand_path(path: &str) -> Result<PathBuf> {
|
||||
let ret: PathBuf;
|
||||
|
||||
@@ -52,6 +39,7 @@ pub fn join_config_path(file: &Path) -> Result<PathBuf> {
|
||||
Ok(path)
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
|
||||
pub enum NetworkName {
|
||||
Solana,
|
||||
@@ -217,25 +205,6 @@ pub fn search_id(symbol: &str) -> Result<String> {
|
||||
unreachable!();
|
||||
}
|
||||
|
||||
// TODO: implement this
|
||||
|
||||
//pub fn search_decimals(symbol: &str) -> Result<String> {
|
||||
// // TODO: FIXME
|
||||
// let file_contents = std::fs::read_to_string("token/solanatokenlist.json")?;
|
||||
// let tokenlist: serde_json::Value = serde_json::from_str(&file_contents)?;
|
||||
// let tokens = tokenlist["tokens"]
|
||||
// .as_array()
|
||||
// .ok_or_else(|| Error::TokenParseError)?;
|
||||
// for item in tokens {
|
||||
// if item["symbol"] == symbol.to_uppercase() {
|
||||
// let address = item["address"].clone();
|
||||
// let address = address.as_str().ok_or_else(|| Error::TokenParseError)?;
|
||||
// return Ok(address.to_string());
|
||||
// }
|
||||
// }
|
||||
// unreachable!();
|
||||
//}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::serial::{deserialize, serialize};
|
||||
|
||||
Reference in New Issue
Block a user