blockfrost-api 0.6.0.0 → 0.7.0.0
raw patch · 5 files changed
+24/−10 lines, 5 filesdep ~lens
Dependency ranges changed: lens
Files
- CHANGELOG.md +6/−0
- blockfrost-api.cabal +2/−2
- src/Blockfrost/API/Cardano/Scripts.hs +1/−1
- src/Blockfrost/Types/Shared/ScriptHash.hs +13/−5
- test/Cardano/Scripts.hs +2/−2
CHANGELOG.md view
@@ -1,3 +1,9 @@+# Version [0.7.0.0](https://github.com/blockfrost/blockfrost-haskell/compare/v0.6.0.0...v0.7.0.0) (2022-10-11)++* Changes+ * Added `ScriptHashList` newtype instead of overlapping instance for `[ScriptHash]` which is used+ as a result of `_listScripts` in `ScriptsAPI`+ # Version [0.6.0.0](https://github.com/blockfrost/blockfrost-haskell/compare/v0.5.0.0...v0.6.0.0) (2022-08-31) * Additions
blockfrost-api.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: blockfrost-api-version: 0.6.0.0+version: 0.7.0.0 synopsis: API definitions for blockfrost.io description: Core types and Servant API description homepage: https://github.com/blockfrost/blockfrost-haskell@@ -128,7 +128,7 @@ , time , aeson >= 2.0 && < 3.0 , deriving-aeson- , lens >= 5.0 && < 5.1+ , lens >= 5.0 && < 5.3 , template-haskell , servant >= 0.18 && < 0.20 , servant-docs
src/Blockfrost/API/Cardano/Scripts.hs view
@@ -22,7 +22,7 @@ :> Description "List of scripts." :> Pagination :> Sorting- :> Get '[JSON] [ScriptHash]+ :> Get '[JSON] ScriptHashList , _getScript :: route :- Summary "Specific scripts"
@@ -2,6 +2,7 @@ module Blockfrost.Types.Shared.ScriptHash ( ScriptHash (..)+ , ScriptHashList (..) ) where import Data.Aeson (FromJSON (..), ToJSON (..), Value(..), (.=), (.:))@@ -27,11 +28,18 @@ instance FromJSON ScriptHash where parseJSON = fmap ScriptHash <$> parseJSON --- Custom instance for list used by script list endpoint-instance {-# OVERLAPS #-} ToJSON [ScriptHash] where- toJSON = Array . Data.Vector.fromList . map (\sh -> Object ("script_hash" .= (toJSON . unScriptHash $ sh)))-instance {-# OVERLAPS #-} FromJSON [ScriptHash] where- parseJSON (Array a) = mapM parseJSON' (Data.Vector.toList a)+-- | Wrapper for list of ScriptHash-es, used by script list endpoint+newtype ScriptHashList = ScriptHashList { unScriptHashList :: [ScriptHash] }+ deriving stock (Show, Eq, Generic)++instance ToJSON ScriptHashList where+ toJSON =+ Array+ . Data.Vector.fromList+ . map (\sh -> Object ("script_hash" .= (toJSON . unScriptHash $ sh)))+ . unScriptHashList+instance FromJSON ScriptHashList where+ parseJSON (Array a) = ScriptHashList <$> mapM parseJSON' (Data.Vector.toList a) where parseJSON' (Object b) = b .: "script_hash" parseJSON' _ = fail "Unexpected type for ScriptHash"
test/Cardano/Scripts.hs view
@@ -66,8 +66,8 @@ ] |] -scriptListExpected :: [ScriptHash]-scriptListExpected =+scriptListExpected :: ScriptHashList+scriptListExpected = ScriptHashList [ "67f33146617a5e61936081db3b2117cbf59bd2123748f58ac9678656" , "e1457a0c47dfb7a2f6b8fbb059bdceab163c05d34f195b87b9f2b30e" , "a6e63c0ff05c96943d1cc30bf53112ffff0f34b45986021ca058ec54"