Bläddra i källkod

Merge branch 'master' of github.com:darkrenaissance/darkfi

ghassmo 4 år sedan
förälder
incheckning
c5c5f9ff56
2 ändrade filer med 9 tillägg och 12 borttagningar
  1. 8 8
      src/bin/darkfid.rs
  2. 1 4
      todo.md

+ 8 - 8
src/bin/darkfid.rs

@@ -22,7 +22,7 @@ use drk::{
     serial::serialize,
     serial::serialize,
     util::join_config_path,
     util::join_config_path,
     wallet::WalletDb,
     wallet::WalletDb,
-    Error,
+    Error, Result,
 };
 };
 
 
 #[derive(Clone)]
 #[derive(Clone)]
@@ -30,21 +30,25 @@ struct Darkfid {
     verbose: bool,
     verbose: bool,
     config: DarkfidConfig,
     config: DarkfidConfig,
     wallet: Arc<WalletDb>,
     wallet: Arc<WalletDb>,
+    tokenlist: Value,
     // clientdb:
     // clientdb:
     // mint_params:
     // mint_params:
     // spend_params:
     // spend_params:
 }
 }
 
 
 impl Darkfid {
 impl Darkfid {
-    fn new(verbose: bool, config_path: PathBuf) -> Result<Self, Error> {
+    fn new(verbose: bool, config_path: PathBuf) -> Result<Self> {
         let config: DarkfidConfig = Config::<DarkfidConfig>::load(config_path)?;
         let config: DarkfidConfig = Config::<DarkfidConfig>::load(config_path)?;
         let wallet_path = join_config_path(&PathBuf::from("walletdb.db"))?;
         let wallet_path = join_config_path(&PathBuf::from("walletdb.db"))?;
         let wallet = WalletDb::new(&PathBuf::from(wallet_path.clone()), config.password.clone())?;
         let wallet = WalletDb::new(&PathBuf::from(wallet_path.clone()), config.password.clone())?;
+        let file_contents = fs::read_to_string("token/solanatokenlist.json")?;
+        let tokenlist: Value = serde_json::from_str(&file_contents)?;
 
 
         Ok(Self {
         Ok(Self {
             verbose,
             verbose,
             config,
             config,
             wallet,
             wallet,
+            tokenlist,
         })
         })
     }
     }
 
 
@@ -137,11 +141,7 @@ impl Darkfid {
     // TODO: proper error handling here
     // TODO: proper error handling here
     fn search_id(self, symbol: &str) -> Value {
     fn search_id(self, symbol: &str) -> Value {
         debug!(target: "DARKFID", "SEARCHING FOR {}", symbol);
         debug!(target: "DARKFID", "SEARCHING FOR {}", symbol);
-        let file_contents =
-            fs::read_to_string("token/solanatokenlist.json").expect("Can't find tokenlist file");
-        let root: Value =
-            serde_json::from_str(&file_contents).expect("Can't parse file into valid json");
-        let tokens = root["tokens"]
+        let tokens = self.tokenlist["tokens"]
             .as_array()
             .as_array()
             .expect("Can't find 'tokens' in file");
             .expect("Can't find 'tokens' in file");
         for item in tokens {
         for item in tokens {
@@ -289,7 +289,7 @@ impl Darkfid {
 }
 }
 
 
 #[tokio::main]
 #[tokio::main]
-async fn main() -> Result<(), Box<dyn std::error::Error>> {
+async fn main() -> Result<()> {
     let args = clap_app!(darkfid =>
     let args = clap_app!(darkfid =>
         (@arg CONFIG: -c --config +takes_value "Sets a custom config file")
         (@arg CONFIG: -c --config +takes_value "Sets a custom config file")
         (@arg verbose: -v --verbose "Increase verbosity")
         (@arg verbose: -v --verbose "Increase verbosity")

+ 1 - 4
todo.md

@@ -11,12 +11,9 @@
 - [ ] cashierd config has explicit mainnet and testnet configurations, simplify this and have a single endpoint
 - [ ] cashierd config has explicit mainnet and testnet configurations, simplify this and have a single endpoint
 - [ ] drk -wk reports success on subsequent calls, it should rather tell that things are already initialized
 - [ ] drk -wk reports success on subsequent calls, it should rather tell that things are already initialized
 - [ ] use f64 (and only positive/absolute) for amounts only on the client-facing side. internally, use u64 and num of decimals
 - [ ] use f64 (and only positive/absolute) for amounts only on the client-facing side. internally, use u64 and num of decimals
-- [ ] replace bin/drk, cashierd, darkfid with new binaries
-- [ ] delete deprecated rpc code 
-- [ ] drk2: check user input is valid tokenID and not symbol
 - [ ] drk2: retrieve cashier features and error if don't support the network
 - [ ] drk2: retrieve cashier features and error if don't support the network
+- [ ] darkfid: match 'bitcoin' to 'btc'
 - [ ] standardize error handling in drk2, cashierd, darkfid
 - [ ] standardize error handling in drk2, cashierd, darkfid
-- [ ] load token/solanatokenlist.json into global variable in darkfid
 
 
 ## deposit
 ## deposit