From bff07eb3f5554ff13f81d8ff7ea10c4bc52609f8 Mon Sep 17 00:00:00 2001 From: Andrew Dirksen Date: Wed, 24 Apr 2019 01:26:52 -0700 Subject: [PATCH] fix #88 (#89) --- Cargo.lock | 14 +++++++------- api/Cargo.toml | 2 +- api/src/foreign_rpc.rs | 2 +- api/src/owner_rpc.rs | 2 +- controller/Cargo.toml | 2 +- controller/src/controller.rs | 20 +++++++++++--------- 6 files changed, 22 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6c6ebcf8..e858cd3e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -402,10 +402,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "easy-jsonrpc" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "easy-jsonrpc-proc-macro 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "easy-jsonrpc-proc-macro 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 10.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", @@ -414,7 +414,7 @@ dependencies = [ [[package]] name = "easy-jsonrpc-proc-macro" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -776,7 +776,7 @@ name = "grin_wallet_api" version = "1.1.0-beta.2" dependencies = [ "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "easy-jsonrpc 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "easy-jsonrpc 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "grin_wallet_config 1.1.0-beta.2", @@ -807,7 +807,7 @@ name = "grin_wallet_controller" version = "1.1.0-beta.2" dependencies = [ "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "easy-jsonrpc 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "easy-jsonrpc 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2731,8 +2731,8 @@ dependencies = [ "checksum digest 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "03b072242a8cbaf9c145665af9d250c59af3b958f83ed6824e13533cf76d5b90" "checksum dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" "checksum dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6d301140eb411af13d3115f9a562c85cc6b541ade9dfa314132244aaee7489dd" -"checksum easy-jsonrpc 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2f0d8eaadf5a9ed73697761ad586140c40aa0837fb5b141a2b04ee9c07eacbfe" -"checksum easy-jsonrpc-proc-macro 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b50f53cc7025979b06da8fde906f948f0fa4665bf840043f4de1e25acee53c97" +"checksum easy-jsonrpc 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cb424ab9ae1c46a5ee5a21f5a11a40b01b7d71a5bd45b12961974fd33701b93f" +"checksum easy-jsonrpc-proc-macro 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9fb33793846951f339a70580375734416898ff8ddbb74401865031e25ba6751" "checksum encode_unicode 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "90b2c9496c001e8cb61827acdefad780795c42264c137744cae6f7d9e3450abd" "checksum enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be4551092f4d519593039259a9ed8daedf0da12e5109c5280338073eaeb81180" "checksum env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)" = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38" diff --git a/api/Cargo.toml b/api/Cargo.toml index ce09c338..d9d87c7a 100644 --- a/api/Cargo.toml +++ b/api/Cargo.toml @@ -15,7 +15,7 @@ failure_derive = "0.1" log = "0.4" uuid = { version = "0.7", features = ["serde", "v4"] } serde_json = "1" -easy-jsonrpc = "0.4.1" +easy-jsonrpc = "0.5.1" chrono = { version = "0.4.4", features = ["serde"] } grin_wallet_libwallet = { path = "../libwallet", version = "1.1.0-beta.2" } diff --git a/api/src/foreign_rpc.rs b/api/src/foreign_rpc.rs index 64d66048..9d622a78 100644 --- a/api/src/foreign_rpc.rs +++ b/api/src/foreign_rpc.rs @@ -440,7 +440,7 @@ pub fn run_doctest_foreign( let mut api_foreign = Foreign::new(wallet1.clone()); api_foreign.doctest_mode = true; let foreign_api = &api_foreign as &dyn ForeignRpc; - Ok(foreign_api.handle_request(request)) + Ok(foreign_api.handle_request(request).as_option()) } #[doc(hidden)] diff --git a/api/src/owner_rpc.rs b/api/src/owner_rpc.rs index 6d9be88b..d134e31e 100644 --- a/api/src/owner_rpc.rs +++ b/api/src/owner_rpc.rs @@ -1202,7 +1202,7 @@ pub fn run_doctest_owner( let mut api_owner = Owner::new(wallet1.clone()); api_owner.doctest_mode = true; let owner_api = &api_owner as &dyn OwnerRpc; - Ok(owner_api.handle_request(request)) + Ok(owner_api.handle_request(request).as_option()) } #[doc(hidden)] diff --git a/controller/Cargo.toml b/controller/Cargo.toml index 0631035f..9cbd1207 100644 --- a/controller/Cargo.toml +++ b/controller/Cargo.toml @@ -29,7 +29,7 @@ tokio-retry = "0.1" uuid = { version = "0.7", features = ["serde", "v4"] } url = "1.7.0" chrono = { version = "0.4.4", features = ["serde"] } -easy-jsonrpc = "0.4.1" +easy-jsonrpc = "0.5.1" lazy_static = "1" grin_wallet_util = { path = "../util", version = "1.1.0-beta.2" } diff --git a/controller/src/controller.rs b/controller/src/controller.rs index 0322deda..a2122ec8 100644 --- a/controller/src/controller.rs +++ b/controller/src/controller.rs @@ -44,7 +44,7 @@ use uuid::Uuid; use crate::apiwallet::{Foreign, ForeignRpc, Owner, OwnerRpc}; use easy_jsonrpc; -use easy_jsonrpc::Handler; +use easy_jsonrpc::{Handler, MaybeReply}; lazy_static! { pub static ref GRIN_OWNER_BASIC_REALM: HeaderValue = @@ -687,10 +687,11 @@ where Box::new(parse_body(req).and_then(move |val: serde_json::Value| { let owner_api = &api as &dyn OwnerRpc; match owner_api.handle_request(val) { - Some(r) => ok(r), - None => { - error!("OwnerAPI: call_api: failed with error"); - err(ErrorKind::GenericError(format!("OwnerAPI Call Failed")).into()) + MaybeReply::Reply(r) => ok(r), + MaybeReply::DontReply => { + // Since it's http, we need to return something. We return [] because jsonrpc + // clients will parse it as an empty batch response. + ok(serde_json::json!([])) } } })) @@ -866,10 +867,11 @@ where Box::new(parse_body(req).and_then(move |val: serde_json::Value| { let foreign_api = &api as &dyn ForeignRpc; match foreign_api.handle_request(val) { - Some(r) => ok(r), - None => { - error!("ForeignAPI: call_api: failed with error"); - err(ErrorKind::GenericError(format!("ForeignAPI Call Failed")).into()) + MaybeReply::Reply(r) => ok(r), + MaybeReply::DontReply => { + // Since it's http, we need to return something. We return [] because jsonrpc + // clients will parse it as an empty batch response. + ok(serde_json::json!([])) } } }))