Skip to content

Commit

Permalink
Fix the FromJSON instance for Payload (#54)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
enobayram authored Dec 18, 2023
1 parent f9c8e66 commit 33022a1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Chainweb/Api/Payload.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 33022a1

Please sign in to comment.