packages feed

blockfrost-client 0.8.0.1 → 0.9.0.0

raw patch · 7 files changed

+96/−11 lines, 7 filesdep ~blockfrost-apiPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: blockfrost-api

API changes (from Hackage documentation)

- Blockfrost.Client.Types: [countPerPage] :: Paged -> Int
- Blockfrost.Client.Types: [pageNumber] :: Paged -> Int
- Blockfrost.Client.Types: [projectEnv] :: Project -> Env
- Blockfrost.Client.Types: [projectId] :: Project -> Text
- Blockfrost.Client.Types: [unBlockfrostClientT] :: BlockfrostClientT m a -> ExceptT BlockfrostError (ReaderT ClientConfig m) a
+ Blockfrost.Client: getMempoolTransaction :: MonadBlockfrost m => Project -> TxHash -> m MempoolTransaction
+ Blockfrost.Client: getMempoolTransactions :: MonadBlockfrost m => Project -> Paged -> SortOrder -> m [TxHashObject]
+ Blockfrost.Client: getMempoolTransactionsByAddress :: MonadBlockfrost m => Project -> Address -> Paged -> SortOrder -> m [TxHashObject]
+ Blockfrost.Client: getTxCBOR :: MonadBlockfrost m => TxHash -> m [TransactionCBOR]
+ Blockfrost.Client.Cardano.Mempool: getMempoolTransaction :: MonadBlockfrost m => Project -> TxHash -> m MempoolTransaction
+ Blockfrost.Client.Cardano.Mempool: getMempoolTransactions :: MonadBlockfrost m => Project -> Paged -> SortOrder -> m [TxHashObject]
+ Blockfrost.Client.Cardano.Mempool: getMempoolTransactionsByAddress :: MonadBlockfrost m => Project -> Address -> Paged -> SortOrder -> m [TxHashObject]
+ Blockfrost.Client.Cardano.Transactions: getTxCBOR :: MonadBlockfrost m => TxHash -> m [TransactionCBOR]
+ Blockfrost.Client.Types: [$sel:countPerPage:Paged] :: Paged -> Int
+ Blockfrost.Client.Types: [$sel:pageNumber:Paged] :: Paged -> Int
+ Blockfrost.Client.Types: [$sel:projectEnv:Project] :: Project -> Env
+ Blockfrost.Client.Types: [$sel:projectId:Project] :: Project -> Text
+ Blockfrost.Client.Types: [$sel:unBlockfrostClientT:BlockfrostClientT] :: BlockfrostClientT m a -> ExceptT BlockfrostError (ReaderT ClientConfig m) a
- Blockfrost.Client.Types: fromServant :: GenericServant routes mode => ToServant routes mode -> routes mode
+ Blockfrost.Client.Types: fromServant :: forall {k} routes (mode :: k). GenericServant routes mode => ToServant routes mode -> routes mode

Files

CHANGELOG.md view
@@ -1,3 +1,10 @@+# Version [0.9.0.0](https://github.com/blockfrost/blockfrost-haskell/compare/client-0.8.0.1...client-0.9.0.0) (2024-09-19)++* Additions+  * `ProtocolParams` extended with Conway related protocol parameters and raw cost models [#59](https://github.com/blockfrost/blockfrost-haskell/pull/59)+  * Mempool endpoints [#62](https://github.com/blockfrost/blockfrost-haskell/pull/62)+  * `getTxCBOR` for `/txs/:hash/cbor` [#63](https://github.com/blockfrost/blockfrost-haskell/pull/63)+ # Version [0.8.0.1](https://github.com/blockfrost/blockfrost-haskell/compare/client-0.8.0.0...client-0.8.0.1) (2024-01-16)  * GHC 9.6.3 compatibility@@ -11,8 +18,8 @@   * `listPoolsExtended` for `/pools/extended`   * `/utils` API     * `deriveShelleyAddress` for `/utils/addresses/xpub/:xpub/:role/:index`-    * `evaluateTx` for `/utils/txs/evaluate` endpoint-    * `evaluateTxUTXOs` for `/utils/txs/evaluate/utxos` endpoint+    * `txEvaluate` for `/utils/txs/evaluate` endpoint+    * `txEvaluateUTXOs` for `/utils/txs/evaluate/utxos` endpoint  # Version [0.7.1.1](https://github.com/blockfrost/blockfrost-haskell/compare/v0.7.1.0...client-0.7.1.1) (2023-01-10) 
blockfrost-client.cabal view
@@ -1,6 +1,6 @@ cabal-version:       2.2 name:                blockfrost-client-version:             0.8.0.1+version:             0.9.0.0 synopsis:            blockfrost.io basic client description:         Simple Blockfrost clients for use with transformers or mtl homepage:            https://github.com/blockfrost/blockfrost-haskell@@ -35,6 +35,7 @@  common libstuff   default-language:    Haskell2010+  default-extensions:  DuplicateRecordFields   ghc-options:         -Wall -Wunused-packages                        -fno-specialize                        -- ^ this helps quite a lot@@ -57,6 +58,7 @@                       , Blockfrost.Client.Cardano.Blocks                       , Blockfrost.Client.Cardano.Epochs                       , Blockfrost.Client.Cardano.Ledger+                      , Blockfrost.Client.Cardano.Mempool                       , Blockfrost.Client.Cardano.Metadata                       , Blockfrost.Client.Cardano.Network                       , Blockfrost.Client.Cardano.Pools@@ -66,7 +68,7 @@                       , Blockfrost.Client.IPFS                       , Blockfrost.Client.NutLink    build-depends:       base                     >= 4.7 && < 5-                      , blockfrost-api           >= 0.9+                      , blockfrost-api           >= 0.12                       , blockfrost-client-core   ^>= 0.6                       , bytestring                       , directory
example/Main.hs view
@@ -3,7 +3,8 @@ module Main   where -import Blockfrost.Client+import Blockfrost.Client hiding (NutLinkAPI(..))+import Control.Monad.IO.Class  main = do   -- reads token from BLOCKFROST_TOKEN_PATH@@ -15,8 +16,45 @@     latestBlocks <- getLatestBlock     (ers :: Either BlockfrostError [AccountReward]) <-       tryError $ getAccountRewards "gonnaFail"+    +    allMempoolTxs <- +      getMempoolTransactions prj def def+    +    if null allMempoolTxs +    then return $ (latestBlocks, ers, allMempoolTxs, Nothing)+    else do let lastTxInMempool = TxHash . unTxHashObject $ last allMempoolTxs+            lastMempoolTx <- getMempoolTransaction prj lastTxInMempool+                +            return (latestBlocks, ers, allMempoolTxs, Just lastMempoolTx) +    +  -- variant accepting @Paged@ and @SortOrder@ arguments+  -- getAccountRewards' "gonnaFail" (page 10) desc+  case res of +    Left e -> print e+    Right ((latestBlocks, ers, allMempoolTxs, lastMempoolTx)) -> do +      print "Latest blocks:"+      print latestBlocks+      putStrLn ""+      print "Account rewards (expected to error):"+      print ers+      putStrLn ""+      print "All mempool transactions (mempool potentially empty):"+      print allMempoolTxs+      putStrLn ""+      print "Last mempool transaction (if any):"+      print lastMempoolTx+      putStrLn "" -    -- variant accepting @Paged@ and @SortOrder@ arguments-    -- getAccountRewards' "gonnaFail" (page 10) desc-    pure (latestBlocks, ers)-  print res+      case lastMempoolTx of +        Nothing -> print "No mempool transactions found."+        Just mempoolTx -> do+          let inputs = _inputs mempoolTx+          if null inputs +          then print "No mempool transactions found" -- Should be impossible+          else +            do let address = Address . _address $ head inputs+               mempoolTxByAddress <- runBlockfrost prj $ getMempoolTransactionsByAddress prj address def def+               print "Mempool transactions by address:"+               print mempoolTxByAddress+               +  
src/Blockfrost/Client.hs view
@@ -97,6 +97,10 @@   , getTxMetadataByLabelJSON'   , getTxMetadataByLabelCBOR   , getTxMetadataByLabelCBOR'+    -- Cardano - Mempool+  , getMempoolTransactions+  , getMempoolTransaction+  , getMempoolTransactionsByAddress     -- Cardano - Network   , getNetworkInfo   , getNetworkEras@@ -140,6 +144,7 @@   , getTxPoolUpdates   , getTxPoolRetiring   , getTxMetadataJSON+  , getTxCBOR   , getTxMetadataCBOR   , getTxRedeemers   , submitTx@@ -177,6 +182,7 @@ import Blockfrost.Client.Cardano.Blocks import Blockfrost.Client.Cardano.Epochs import Blockfrost.Client.Cardano.Ledger+import Blockfrost.Client.Cardano.Mempool import Blockfrost.Client.Cardano.Metadata import Blockfrost.Client.Cardano.Network import Blockfrost.Client.Cardano.Pools
+ src/Blockfrost/Client/Cardano/Mempool.hs view
@@ -0,0 +1,24 @@+-- | Mempool queries++module Blockfrost.Client.Cardano.Mempool+  ( getMempoolTransactions+  , getMempoolTransaction +  , getMempoolTransactionsByAddress+  ) where++import Blockfrost.API+import Blockfrost.Client.Types+import Blockfrost.Types++mempoolClient :: MonadBlockfrost m => Project -> MempoolAPI (AsClientT m)+mempoolClient = fromServant . _mempool . cardanoClient++getMempoolTransactions :: MonadBlockfrost m => Project -> Paged -> SortOrder -> m [TxHashObject]+getMempoolTransactions = _mempoolTransactions . mempoolClient ++getMempoolTransaction :: MonadBlockfrost m => Project -> TxHash -> m MempoolTransaction+getMempoolTransaction = _specificTransaction . mempoolClient  ++getMempoolTransactionsByAddress :: MonadBlockfrost m => Project -> Address -> Paged -> SortOrder -> m [TxHashObject]+getMempoolTransactionsByAddress = _specificAddress . mempoolClient +
src/Blockfrost/Client/Cardano/Transactions.hs view
@@ -11,13 +11,14 @@   , getTxPoolUpdates   , getTxPoolRetiring   , getTxMetadataJSON+  , getTxCBOR   , getTxMetadataCBOR   , submitTx   ) where  import Blockfrost.API import Blockfrost.Client.Types-import Blockfrost.Types+import Blockfrost.Types hiding (MempoolTransaction(..))  transactionsClient :: MonadBlockfrost m => Project -> TransactionsAPI (AsClientT m) transactionsClient = fromServant . _transactions . cardanoClient@@ -91,6 +92,13 @@ -- | Get transaction metadata in JSON getTxMetadataJSON :: MonadBlockfrost m => TxHash -> m [TransactionMetaJSON] getTxMetadataJSON t = go (`getTxMetadataJSON_` t)++getTxCBOR_ :: MonadBlockfrost m => Project -> TxHash -> m [TransactionCBOR]+getTxCBOR_ = _txCBOR . transactionsClient++-- | Get transaction in CBOR+getTxCBOR :: MonadBlockfrost m => TxHash -> m [TransactionCBOR]+getTxCBOR t = go (`getTxCBOR_` t)  getTxMetadataCBOR_ :: MonadBlockfrost m => Project -> TxHash -> m [TransactionMetaCBOR] getTxMetadataCBOR_ = _txMetadataCBOR . transactionsClient
src/Blockfrost/Client/NutLink.hs view
@@ -12,7 +12,7 @@  import Blockfrost.API import Blockfrost.Client.Types-import Blockfrost.Types+import Blockfrost.Types hiding (MempoolUTxOInput(..)) import Data.Text (Text)  nutlinkListAddress_ :: MonadBlockfrost m => Project -> Address-> m NutlinkAddress