Skip to content

Commit cf59699

Browse files
palascarbolymer
andcommitted
Use .:? for parsing Maybe's
Co-authored-by: Mateusz Galazyn <[email protected]>
1 parent cb89b8d commit cf59699

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

cardano-wasm/src-lib/Cardano/Wasm/Api/Certificate/StakeCertificate.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import Cardano.Ledger.Api (Delegatee (..))
4747
import Cardano.Wasm.ExceptionHandling (rightOrError, throwError, toMonadFail)
4848

4949
import Control.Monad.Catch (MonadThrow)
50-
import Data.Aeson (FromJSON, (.:), (.=))
50+
import Data.Aeson (FromJSON, (.:), (.:?), (.=))
5151
import Data.Aeson qualified as Aeson
5252
import Data.ByteString.Base16 qualified as Base16
5353
import Data.Text (Text)
@@ -94,15 +94,15 @@ instance FromJSON StakeCertificateObject where
9494
toMonadFail $
9595
rightOrError $
9696
Api.deserialiseFromRawBytesHex (Text.encodeUtf8 skHashText)
97-
deposit :: Maybe Coin <- o .: "deposit"
97+
deposit :: Maybe Coin <- o .:? "deposit"
9898
actionStr :: Text <- o .: "action"
9999
action <-
100100
case actionStr of
101101
"RegisterStake" -> return RegisterStake
102102
"UnregisterStake" -> return UnregisterStake
103103
"DelegateOnly" -> return DelegateOnly
104104
_ -> toMonadFail $ throwError ("Invalid action for StakeCertificateObject: " ++ show actionStr)
105-
delegateStakeText :: Maybe Text <- o .: "delegateStake"
105+
delegateStakeText :: Maybe Text <- o .:? "delegateStake"
106106
delegateStake :: Maybe PoolId <-
107107
traverse
108108
( toMonadFail

0 commit comments

Comments
 (0)