From 33022a1b4e8800d01120b5c2a41979adfe65d987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enis=20Bayramo=C4=9Flu?= Date: Mon, 18 Dec 2023 23:27:07 +0100 Subject: [PATCH] Fix the FromJSON instance for Payload (#54) This PR fixes a regression introduced by #52. The rewrite of the `FromJSON` instance in that PR changed the behavior when the `exec` field doesn't exist. --- lib/Chainweb/Api/Payload.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Chainweb/Api/Payload.hs b/lib/Chainweb/Api/Payload.hs index de91dbe..f0f531b 100644 --- a/lib/Chainweb/Api/Payload.hs +++ b/lib/Chainweb/Api/Payload.hs @@ -59,8 +59,8 @@ instance ToJSON Payload where instance FromJSON Payload where parseJSON = withObject "Payload" $ \o -> do - o .: "exec" >>= \case - Nothing -> o .: "cont" >>= \case + o .:? "exec" >>= \case + Nothing -> o .:? "cont" >>= \case Nothing -> fail "Payload must be exec or cont" Just cont -> return $ ContPayload cont Just exec -> return $ ExecPayload exec