瀏覽代碼

bin/drk: Finalize features refactor.

parazyd 4 年之前
父節點
當前提交
d192ae23f0
共有 5 個文件被更改,包括 58 次插入30 次删除
  1. 1 3
      bin/drk/.gitignore
  2. 11 16
      bin/drk/Cargo.toml
  3. 37 0
      bin/drk/Makefile
  4. 2 6
      bin/drk/src/main.rs
  5. 7 5
      src/error.rs

+ 1 - 3
bin/drk/.gitignore

@@ -1,3 +1 @@
-
-/target
-Cargo.lock
+target

+ 11 - 16
bin/drk/Cargo.toml

@@ -1,26 +1,21 @@
 [package]
 name = "drk"
-version = "0.1.0"
+version = "0.2.0"
 edition = "2021"
 
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+[dependencies.darkfi]
+path= "../../"
+features = ["rpc", "cli"]
 
 [dependencies]
-darkfi = {path= "../../"}
-
-# Encoding and parsing
-serde_json = "1.0.72"
-serde = {version = "1.0.130", features = ["derive"]}
-
 # Async
 async-std = {version = "1.10.0", features = ["attributes"]}
-async-executor = "1.4.1"
-futures = "0.3.17"
-smol = "1.2.5"
-
 
-# Utilities
-clap = { version = "3.0.0", features = ["derive"] }
-prettytable-rs = "0.8.0"
-simplelog = "0.11.1"
+# Misc
+clap = {version = "3.0.7", features = ["derive"]}
 log = "0.4.14"
+simplelog = "0.11.2"
+prettytable-rs = "0.8.0"
+
+# Encoding and parsing
+serde_json = "1.0.74"

+ 37 - 0
bin/drk/Makefile

@@ -0,0 +1,37 @@
+.POSIX:
+
+# Cargo binary
+CARGO = cargo
+
+# Binary to be built
+BIN = drk
+
+# Dependencies which should force the binaries to be rebuilt
+BINDEPS = \
+	Cargo.toml \
+	$(shell find src -type f) \
+	$(shell find ../../sql -type f) \
+	$(shell find ../../contrib/token -type f)
+
+all: $(BIN)
+
+$(BIN): $(BINDEPS)
+	$(CARGO) build --release --all-features
+	cp -f target/release/$@ $@
+
+check: $(BINDEPS)
+	$(CARGO) hack check --release --feature-powerset --no-dev-deps
+
+fix:
+	$(CARGO) clippy --release --all-features --fix --allow-dirty
+
+clippy:
+	$(CARGO) clippy --release --all-features
+
+test:
+	$(CARGO) test --release --all-features
+
+clean:
+	rm -f $(BIN)
+
+.PHONY: all check fix clippy test clean

+ 2 - 6
bin/drk/src/main.rs

@@ -10,12 +10,8 @@ use simplelog::{ColorChoice, LevelFilter, TermLogger, TerminalMode};
 
 use darkfi::{
     cli::{CliDrk, CliDrkSubCommands, Config, DrkConfig},
-    util::{
-        join_config_path,
-        path::expand_path,
-        rpc::{jsonrpc, jsonrpc::JsonResult},
-        NetworkName,
-    },
+    rpc::{jsonrpc, jsonrpc::JsonResult},
+    util::{join_config_path, path::expand_path, NetworkName},
     Error, Result,
 };
 

+ 7 - 5
src/error.rs

@@ -86,8 +86,10 @@ pub enum Error {
     InvalidParamName,
     #[error("Invalid param type")]
     InvalidParamType,
-    // #[error("Missing params")]
-    // MissingParams,
+
+    #[error("Missing params")]
+    MissingParams,
+
     // #[error("Contract is poorly defined")]
     // BadContract,
     #[cfg(feature = "crypto")]
@@ -122,9 +124,9 @@ pub enum Error {
     #[error("SlabsStore Error: `{0}`")]
     SlabsStore(String),
 
-    // /// RPC errors
-    // #[error("JsonRpc Error: `{0}`")]
-    // JsonRpcError(String),
+    #[error("JsonRpc Error: `{0}`")]
+    JsonRpcError(String),
+
     #[error("Not supported network")]
     NotSupportedNetwork,