packages feed

blockfrost-client-core 0.6.0.1 → 0.7.0.0

raw patch · 3 files changed

+32/−12 lines, 3 filesdep +exceptionsPVP ok

version bump matches the API change (PVP)

Dependencies added: exceptions

API changes (from Hackage documentation)

- Blockfrost.Client.Auth: data () => Project
+ Blockfrost.Client.Auth: data Project
- Blockfrost.Client.Core: BlockfrostNotFound :: BlockfrostError
+ Blockfrost.Client.Core: BlockfrostNotFound :: Text -> BlockfrostError
- Blockfrost.Client.Core: data () => Paged
+ Blockfrost.Client.Core: data Paged
- Blockfrost.Client.Core: data () => SortOrder
+ Blockfrost.Client.Core: data SortOrder
- Blockfrost.Client.Pagination: data () => Paged
+ Blockfrost.Client.Pagination: data Paged
- Blockfrost.Client.Sorting: data () => SortOrder
+ Blockfrost.Client.Sorting: data SortOrder

Files

CHANGELOG.md view
@@ -1,3 +1,11 @@+# Version [0.7.0.0](https://github.com/blockfrost/blockfrost-haskell/compare/client-core-0.6.0.1...client-core-0.7.0.0) (2025-12-02)++* Changes+  * Add `CustomURL` to `Env`, to allow arbitrary Blockfrost instance [#79](https://github.com/blockfrost/blockfrost-haskell/pull/79)+  * `BlockfrostNotFound` constructor of `BlockfrostError` is now `BlockfrostNotFound Text`+    containing path that resulted in 404 error [#80](https://github.com/blockfrost/blockfrost-haskell/pull/80)+  * Drop `Sanchonet` `Env` [#79](https://github.com/blockfrost/blockfrost-haskell/pull/79)+ # Version [0.6.0.1](https://github.com/blockfrost/blockfrost-haskell/compare/v0.6.0.0...client-core-0.6.0.1) (2024-01-16)  * Allow servant `0.20`
blockfrost-client-core.cabal view
@@ -1,6 +1,6 @@ cabal-version:       2.2 name:                blockfrost-client-core-version:             0.6.0.1+version:             0.7.0.0 synopsis:            blockfrost.io common client definitions / instances description:         HasClient for our auth homepage:            https://github.com/blockfrost/blockfrost-haskell@@ -50,6 +50,7 @@                       , case-insensitive                       , containers                       , data-default+                      , exceptions                       , http-client                       , http-client-tls                       , http-types
src/Blockfrost/Client/Core.hs view
@@ -34,14 +34,18 @@ import Data.Aeson (eitherDecode) import Data.Default (Default (def)) import Data.Text (Text)+import qualified Data.ByteString.Char8+import qualified Data.Text import qualified Data.Text.IO import qualified Network.HTTP.Client import qualified Network.HTTP.Client.TLS import Network.HTTP.Types import Servant.Client+import Servant.Client.Core.Request import Servant.Multipart.API import Servant.Multipart.Client () import qualified System.Environment+import Control.Monad.Catch.Pure (runCatch)  domain :: String domain = "blockfrost.io"@@ -60,17 +64,20 @@     mempty  baseUrlByEnv :: Env -> BaseUrl-baseUrlByEnv Localhost = BaseUrl Http "localhost" 8000 ""-baseUrlByEnv e         = maybe (error "absurd") buildUrl (subdomainByEnv e)+baseUrlByEnv (CustomURL url) = case runCatch $ parseBaseUrl url of+  Left e     -> error ("parseBaseUrl exception: " <> show e)+  Right bUrl -> bUrl+baseUrlByEnv Localhost       = BaseUrl Http "localhost" 8000 ""+baseUrlByEnv e               = maybe (error "absurd") buildUrl (subdomainByEnv e)  subdomainByEnv :: Env -> Maybe String-subdomainByEnv Ipfs      = pure "ipfs"-subdomainByEnv Mainnet   = pure "cardano-mainnet"-subdomainByEnv Testnet   = pure "cardano-testnet"-subdomainByEnv Preprod   = pure "cardano-preprod"-subdomainByEnv Preview   = pure "cardano-preview"-subdomainByEnv Sanchonet = pure "cardano-sanchonet"-subdomainByEnv Localhost = Nothing+subdomainByEnv Ipfs          = pure "ipfs"+subdomainByEnv Mainnet       = pure "cardano-mainnet"+subdomainByEnv Testnet       = pure "cardano-testnet"+subdomainByEnv Preprod       = pure "cardano-preprod"+subdomainByEnv Preview       = pure "cardano-preview"+subdomainByEnv Localhost     = Nothing+subdomainByEnv (CustomURL _) = Nothing  -- | Read file according to BLOCKFROST_TOKEN_PATH environment variable name. projectFromEnv :: IO Project@@ -92,7 +99,7 @@     BlockfrostError Text   | BlockfrostBadRequest Text   -- 400   | BlockfrostTokenMissing Text -- 403-  | BlockfrostNotFound          -- 404+  | BlockfrostNotFound Text     -- 404   | BlockfrostIPBanned          -- 418   | BlockfrostMempoolFullOrPinQueueFull -- 425   | BlockfrostUsageLimitReached -- 429@@ -102,13 +109,17 @@  fromServantClientError :: ClientError -> BlockfrostError fromServantClientError e = case e of-  FailureResponse _bUrl (Response s _ _ body)+  FailureResponse req (Response s _ _ body)     | s == status400 ->         BlockfrostBadRequest (withMessage body)     | s == status403 ->         BlockfrostTokenMissing (withMessage body)     | s == status404 ->         BlockfrostNotFound+          . Data.Text.pack+          . Data.ByteString.Char8.unpack+          . snd+          $ requestPath req     | s == status418 ->         BlockfrostIPBanned     | s == mkStatus 425 "Mempool Full (TXs) or Pin Queue Full (IPFS)" ->