From 3af235377b2a0f3bd83f4523c5b25fe62001be62 Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Wed, 20 Mar 2024 19:33:36 +0000 Subject: [PATCH] Adapt response handling to Zebra (#40) This PR allows for the Zebra behavior of not having a `result` field in the RPC response on error conditions. Reviewed-on: https://git.vergara.tech/Vergara_Tech/zcash-haskell/pulls/40 Co-authored-by: Rene Vergara Co-committed-by: Rene Vergara --- CHANGELOG.md | 1 + src/ZcashHaskell/Types.hs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad3ee7b..fef5e74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Modified the `makeZebraCall` function to handle errors explicitly +- Modified the RPC response to handle missing `result` field ## [0.5.0.1] diff --git a/src/ZcashHaskell/Types.hs b/src/ZcashHaskell/Types.hs index 32f4e57..182ddc1 100644 --- a/src/ZcashHaskell/Types.hs +++ b/src/ZcashHaskell/Types.hs @@ -168,7 +168,7 @@ instance (FromJSON r) => FromJSON (RpcResponse r) where withObject "RpcResponse" $ \obj -> do e <- obj .:? "error" i <- obj .: "id" - r <- obj .: "result" + r <- obj .:? "result" pure $ MakeRpcResponse e i r -- | A type to model the errors from the Zcash RPC