blockfrost-client (empty) → 0.1.0.0
raw patch · 22 files changed
+1519/−0 lines, 22 filesdep +basedep +blockfrost-apidep +blockfrost-clientsetup-changed
Dependencies added: base, blockfrost-api, blockfrost-client, blockfrost-client-core, bytestring, data-default, directory, filepath, hspec, mtl, servant, servant-client, servant-client-core, tasty, tasty-hspec, tasty-hunit, tasty-quickcheck, text
Files
- CHANGELOG.md +11/−0
- LICENSE +13/−0
- README.md +110/−0
- Setup.hs +2/−0
- blockfrost-client.cabal +106/−0
- example/Main.hs +22/−0
- src/Blockfrost/Client.hs +200/−0
- src/Blockfrost/Client/Cardano/Accounts.hs +103/−0
- src/Blockfrost/Client/Cardano/Addresses.hs +71/−0
- src/Blockfrost/Client/Cardano/Assets.hs +89/−0
- src/Blockfrost/Client/Cardano/Blocks.hs +98/−0
- src/Blockfrost/Client/Cardano/Epochs.hs +128/−0
- src/Blockfrost/Client/Cardano/Ledger.hs +19/−0
- src/Blockfrost/Client/Cardano/Metadata.hs +54/−0
- src/Blockfrost/Client/Cardano/Network.hs +20/−0
- src/Blockfrost/Client/Cardano/Pools.hs +133/−0
- src/Blockfrost/Client/Cardano/Transactions.hs +99/−0
- src/Blockfrost/Client/IPFS.hs +77/−0
- src/Blockfrost/Client/NutLink.hs +59/−0
- src/Blockfrost/Client/Types.hs +88/−0
- test/SampleSpec.hs +16/−0
- test/Spec.hs +1/−0
+ CHANGELOG.md view
@@ -0,0 +1,11 @@+# Version [0.1.0.0](https://github.com/blockfrost/blockfrost-haskell/compare/initial...0.1.0.0) (2021-09-14)++* Added `allPages`, re-exported couple more pagination helpers+* Initial release++---++`blockfrost-client` uses [PVP Versioning][1].++[1]: https://pvp.haskell.org+
+ LICENSE view
@@ -0,0 +1,13 @@+Copyright 2021 blockfrost.io++Licensed under the Apache License, Version 2.0 (the "License");+you may not use this file except in compliance with the License.+You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++Unless required by applicable law or agreed to in writing, software+distributed under the License is distributed on an "AS IS" BASIS,+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+See the License for the specific language governing permissions and+limitations under the License.
+ README.md view
@@ -0,0 +1,110 @@+# blockfrost-client++Haskell SDK for [Blockfrost.io](https://blockfrost.io) API.++## Development shell++```sh+nix-shell # from repository root, optional+cabal repl blockfrost-client+```++## Usage++[Blockfrost.io](https://blockfrost.io) API token is required to use this SDK.++### Obtaining token++Create a project at [blockfrost.io](https://blockfrost.io) and save the+generated token to a file.++For authentication, client uses a `Project` type which carries an environment and a token itself, for example `Project Testnet "someToken"`.++#### Project from file++Instead of constructing this type manually, you can load the `Project`+from file using `projectFromFile "/secrets/blockfrost-testnet-token"`.++In this case, token needs to be prefixed with the enviromnent to which+it belongs to. The format expected is `<env><token>` (similar to human readable+identifiers used for Cardano keys and addresses), examples:++* `testnet123notArealToken`+* `mainnet456notRealEither`+* `ipfs789mightBeARealOne`++### Using environment variables++In similar manner to loading project from file, you can use+`projectFromEnv` function to load the `Project` from file+pointed to by `BLOCKFROST_TOKEN_PATH` environment variable.++For custom variable name, a principled version `projectFromEnv' "CUSTOM_ENV_VAR"` can be used instead.++## Exploring the API++You can now perform queries from `cabal repl blockfrost-client`, an example session follows:++```haskell+λ: testnet <- projectFromFile "/secrets/blockfrost.testnet.token"+λ: testnet+Project {projectEnv = Testnet, projectId = "censored"}+λ: runBlockfrost testnet $ getLatestBlock+Right (Block {_blockTime = 1629716610s, ... })+λ: runBlockfrost testnet $ listPools+Right [PoolId "pool1adur9jcn0dkjpm3v8ayf94yn3fe5xfk2rqfz7rfpuh6cw6evd7w", ... ]+```++## Pagination and sorting++Some API functions have a variant with trailing `'`. These accept+`Paged` and `SortOrder` arguments for querying multiple pages+and setting a custom sort order.++For example to query the second page of pool list, we can use `listPools'`++```haskell+λ: runBlockfrost testnet $ listPools' (page 2) desc+```++To use default ordering (which is `asc` or `Ascending`), you can just use re-exported `def` from [Data.Default](https://hackage.haskell.org/package/data-default/docs/Data-Default.html).++```haskell+λ: runBlockfrost testnet $ listPools' (page 2) def+```++Similar, to just change an ordering but use default page size and a first page:++```haskell+λ: runBlockfrost testnet $ listPools' def desc+```++## Catching errors++We can use `tryError` inside `BlockfrostClient` monad to try a call,+when we it may fail (dealing with external inputs, enumerating addresses).++Complete program example with error handling:++```haskell+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ScopedTypeVariables #-}+module Main+ where++import Blockfrost.Client++main = do+ -- reads token from BLOCKFROST_TOKEN_PATH+ -- environment variable. It expects token+ -- prefixed with Blockfrost environment name+ -- e.g.: testnet-someTokenHash+ prj <- projectFromEnv+ res <- runBlockfrost prj $ do+ latestBlocks <- getLatestBlock+ (ers :: Either BlockfrostError [AccountReward]) <-+ tryError $ getAccountRewards "gonnaFail"+ pure (latestBlocks, ers)++ print res+```
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ blockfrost-client.cabal view
@@ -0,0 +1,106 @@+cabal-version: 2.2+name: blockfrost-client+version: 0.1.0.0+synopsis: blockfrost.io basic client+description: Simple Blockfrost clients for use with transformers or mtl+homepage: https://github.com/blockfrost/blockfrost-haskell+license: Apache-2.0+license-file: LICENSE+author: blockfrost.io+maintainer: srk@48.io+copyright: 2021 blockfrost.io+category: Web+build-type: Simple+++extra-source-files:+ CHANGELOG.md+ LICENSE+ README.md++flag BuildFast+ Default: True+ Description: Turn off optimizations++flag Examples+ Default: False+ Manual: True+ Description: Build examples++flag Production+ Default: False+ Manual: True+ Description: Production build++common libstuff+ default-language: Haskell2010+ ghc-options: -Wall -Wunused-packages+ -fno-specialize+ -- ^ this helps quite a lot+ -- with memory usage+ -- https://github.com/haskell-servant/servant/issues/986+ -- but -O0 is even better+ if flag(BuildFast)+ ghc-options: -O0+ if flag(Production)+ ghc-options: -Werror++library+ import: libstuff+ hs-source-dirs: src+ exposed-modules: Blockfrost.Client+ , Blockfrost.Client.Types+ , Blockfrost.Client.Cardano.Accounts+ , Blockfrost.Client.Cardano.Addresses+ , Blockfrost.Client.Cardano.Assets+ , Blockfrost.Client.Cardano.Blocks+ , Blockfrost.Client.Cardano.Epochs+ , Blockfrost.Client.Cardano.Ledger+ , Blockfrost.Client.Cardano.Metadata+ , Blockfrost.Client.Cardano.Network+ , Blockfrost.Client.Cardano.Pools+ , Blockfrost.Client.Cardano.Transactions+ , Blockfrost.Client.IPFS+ , Blockfrost.Client.NutLink+ build-depends: base >= 4.7 && < 5+ , blockfrost-api+ , blockfrost-client-core+ , bytestring+ , directory+ , data-default+ , filepath+ , text+ , mtl+ , servant ^>= 0.18+ , servant-client+ , servant-client-core++executable blockfrost-client-example+ if !flag(Examples)+ buildable: False+ hs-source-dirs: example+ main-is: Main.hs+ ghc-options: -threaded -rtsopts -with-rtsopts=-N+ build-depends: base+ , blockfrost-client+ default-language: Haskell2010++test-suite blockfrost-client-tests+ type: exitcode-stdio-1.0+ hs-source-dirs: test+ main-is: Spec.hs+ other-modules: SampleSpec+ build-depends: base >= 4.7 && < 5+ , blockfrost-client+ , hspec+ , tasty+ , tasty-hspec+ , tasty-hunit+ , tasty-quickcheck+ build-tool-depends:+ tasty-discover:tasty-discover+ default-language: Haskell2010++source-repository head+ type: git+ location: https://github.com/blockfrost/blockfrost-haskell
+ example/Main.hs view
@@ -0,0 +1,22 @@+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ScopedTypeVariables #-}+module Main+ where++import Blockfrost.Client++main = do+ -- reads token from BLOCKFROST_TOKEN_PATH+ -- environment variable. It expects token+ -- prefixed with Blockfrost environment name+ -- e.g.: testnet-someTokenHash+ prj <- projectFromEnv+ res <- runBlockfrost prj $ do+ latestBlocks <- getLatestBlock+ (ers :: Either BlockfrostError [AccountReward]) <-+ tryError $ getAccountRewards "gonnaFail"++ -- variant accepting @Paged@ and @SortOrder@ arguments+ -- getAccountRewards' "gonnaFail" (page 10) desc+ pure (latestBlocks, ers)+ print res
+ src/Blockfrost/Client.hs view
@@ -0,0 +1,200 @@+-- | Blockfrost client+{-# LANGUAGE CPP #-}+{-# LANGUAGE DeriveFunctor #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}++module Blockfrost.Client+ ( module Blockfrost.API+ , module Blockfrost.Env+ , module Blockfrost.Types+ , module Blockfrost.Lens+ , module Blockfrost.Client.Core+ , module Blockfrost.Client.Types+ -- Common+ , getRoot+ , getHealth+ , getClock+ -- Metrics+ , getMetrics+ , getMetricsEndpoints+ -- Cardano - Accounts+ , getAccount+ , getAccountRewards+ , getAccountRewards'+ , getAccountHistory+ , getAccountHistory'+ , getAccountDelegations+ , getAccountDelegations'+ , getAccountRegistrations+ , getAccountRegistrations'+ , getAccountWithdrawals+ , getAccountWithdrawals'+ , getAccountMirs+ , getAccountMirs'+ -- Cardano - Addresses+ , getAddressInfo+ , getAddressDetails+ , getAddressUtxos+ , getAddressUtxos'+ , getAddressTransactions+ , getAddressTransactions'+ -- Cardano - Assets+ , getAssets+ , getAssets'+ , getAssetDetails+ , getAssetHistory+ , getAssetHistory'+ , getAssetTransactions+ , getAssetTransactions'+ , getAssetAddresses+ , getAssetAddresses'+ , getAssetsByPolicy+ , getAssetsByPolicy'+ -- Cardano - Blocks+ , getLatestBlock+ , getLatestBlockTxs+ , getLatestBlockTxs'+ , getBlock+ , getBlockSlot+ , getBlockEpochSlot+ , getNextBlocks+ , getNextBlocks'+ , getPreviousBlocks+ , getPreviousBlocks'+ , getBlockTxs+ , getBlockTxs'+ -- Cardano - Epochs+ , getLatestEpoch+ , getLatestEpochProtocolParams+ , getEpoch+ , getNextEpochs+ , getNextEpochs'+ , getPreviousEpochs+ , getPreviousEpochs'+ , getEpochStake+ , getEpochStake'+ , getEpochStakeByPool+ , getEpochStakeByPool'+ , getEpochBlocks+ , getEpochBlocks'+ , getEpochBlocksByPool+ , getEpochBlocksByPool'+ , getEpochProtocolParams+ -- Cardano - Ledger+ , getLedgerGenesis+ -- Cardano - Metadata+ , getTxMetadataLabels+ , getTxMetadataLabels'+ , getTxMetadataByLabelJSON+ , getTxMetadataByLabelJSON'+ , getTxMetadataByLabelCBOR+ , getTxMetadataByLabelCBOR'+ -- Cardano - Network+ , getNetworkInfo+ -- Cardano - Pools+ , listPools+ , listPools'+ , listRetiredPools+ , listRetiredPools'+ , listRetiringPools+ , listRetiringPools'+ , getPool+ , getPoolHistory+ , getPoolHistory'+ , getPoolMetadata+ , getPoolRelays+ , getPoolDelegators+ , getPoolDelegators'+ , getPoolBlocks+ , getPoolBlocks'+ , getPoolUpdates+ , getPoolUpdates'+ -- Cardano - Transactions+ , getTx+ , getTxUtxos+ , getTxStakes+ , getTxDelegations+ , getTxWithdrawals+ , getTxMirs+ , getTxPoolUpdates+ , getTxPoolRetiring+ , getTxMetadataJSON+ , getTxMetadataCBOR+ , submitTx+ -- IPFS+ , ipfsAdd+ , ipfsGateway+ , ipfsGetPin+ , ipfsListPins+ , ipfsListPins'+ , ipfsPin+ , ipfsRemovePin+ -- Nut.link+ , nutlinkListAddress+ , nutlinkListAddressTickers+ , nutlinkListAddressTickers'+ , nutlinkAddressTickers+ , nutlinkAddressTickers'+ , nutlinkTickers+ , nutlinkTickers'+ ) where++import Blockfrost.API+import Blockfrost.Client.Core+import Blockfrost.Env+import Blockfrost.Lens+import Blockfrost.Types++import Blockfrost.Client.Cardano.Accounts+import Blockfrost.Client.Cardano.Addresses+import Blockfrost.Client.Cardano.Assets+import Blockfrost.Client.Cardano.Blocks+import Blockfrost.Client.Cardano.Epochs+import Blockfrost.Client.Cardano.Ledger+import Blockfrost.Client.Cardano.Metadata+import Blockfrost.Client.Cardano.Network+import Blockfrost.Client.Cardano.Pools+import Blockfrost.Client.Cardano.Transactions+import Blockfrost.Client.IPFS+import Blockfrost.Client.NutLink+import Blockfrost.Client.Types++import Data.Text (Text)++-- ** Client functions+-- *** Health++getRoot' :: Project -> BlockfrostClient URLVersion+getRoot' = _getRoot . commonClient++-- | Root endpoint has no other function than to point end users to documentation+getRoot :: BlockfrostClient URLVersion+getRoot = go getRoot'++getHealth' :: Project -> BlockfrostClient Healthy+getHealth' = _getHealth . commonClient++-- | Return backend status. Your application should handle situations when backend for the given chain is unavailable.+getHealth :: BlockfrostClient Healthy+getHealth = go getHealth'++getClock':: Project -> BlockfrostClient ServerTime+getClock' = _getClock . commonClient++-- | Get current backend time+getClock:: BlockfrostClient ServerTime+getClock = go getClock'++getMetrics':: Project -> BlockfrostClient [Metric]+getMetrics' = _metrics . commonClient++-- | Get Blockfrost usage metrics over last 30 days+getMetrics:: BlockfrostClient [Metric]+getMetrics = go getMetrics'++getMetricsEndpoints':: Project -> BlockfrostClient [(Text, Metric)]+getMetricsEndpoints' = _metricsEndpoints . commonClient++-- | Get Blockfrost endpoint usage metrics over last 30 days+getMetricsEndpoints:: BlockfrostClient [(Text, Metric)]+getMetricsEndpoints = go getMetricsEndpoints'
+ src/Blockfrost/Client/Cardano/Accounts.hs view
@@ -0,0 +1,103 @@+-- | Account queries++module Blockfrost.Client.Cardano.Accounts+ ( getAccount+ , getAccountRewards+ , getAccountRewards'+ , getAccountHistory+ , getAccountHistory'+ , getAccountDelegations+ , getAccountDelegations'+ , getAccountRegistrations+ , getAccountRegistrations'+ , getAccountWithdrawals+ , getAccountWithdrawals'+ , getAccountMirs+ , getAccountMirs'+ ) where++import Blockfrost.API+import Blockfrost.Client.Types+import Blockfrost.Types++accountsClient :: Project -> AccountsAPI (AsClientT BlockfrostClient)+accountsClient = fromServant . _accounts . cardanoClient++getAccount_ :: Project -> Address -> BlockfrostClient AccountInfo+getAccount_ = _account . accountsClient++-- | Obtain information about a specific stake account.+getAccount :: Address -> BlockfrostClient AccountInfo+getAccount a = go (`getAccount_` a)++getAccountRewards_ :: Project -> Address -> Paged -> SortOrder -> BlockfrostClient [AccountReward]+getAccountRewards_ = _accountRewards . accountsClient++-- | Obtain information about the history of a specific account.+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+getAccountRewards' :: Address -> Paged -> SortOrder -> BlockfrostClient [AccountReward]+getAccountRewards' a pg s = go (\p -> getAccountRewards_ p a pg s)++-- | Obtain information about the history of a specific account.+getAccountRewards :: Address -> BlockfrostClient [AccountReward]+getAccountRewards a = getAccountRewards' a def def++getAccountHistory_ :: Project -> Address -> Paged -> SortOrder -> BlockfrostClient [AccountHistory]+getAccountHistory_ = _accountHistory . accountsClient++-- | Obtain information about the history of a specific account.+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+getAccountHistory' :: Address -> Paged -> SortOrder -> BlockfrostClient [AccountHistory]+getAccountHistory' a pg s = go (\p -> getAccountHistory_ p a pg s)++-- | Obtain information about the history of a specific account.+getAccountHistory :: Address -> BlockfrostClient [AccountHistory]+getAccountHistory a = getAccountHistory' a def def++getAccountDelegations_ :: Project -> Address -> Paged -> SortOrder -> BlockfrostClient [AccountDelegation]+getAccountDelegations_ = _accountDelegations . accountsClient++-- | Obtain information about the delegation of a specific account.+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+getAccountDelegations' :: Address -> Paged -> SortOrder -> BlockfrostClient [AccountDelegation]+getAccountDelegations' a pg s = go (\p -> getAccountDelegations_ p a pg s)++-- | Obtain information about the delegation of a specific account.+getAccountDelegations :: Address -> BlockfrostClient [AccountDelegation]+getAccountDelegations a = getAccountDelegations' a def def++getAccountRegistrations_ :: Project -> Address -> Paged -> SortOrder -> BlockfrostClient [AccountRegistration]+getAccountRegistrations_ = _accountRegistrations . accountsClient++-- | Obtain information about the registrations and deregistrations of a specific account.+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+getAccountRegistrations' :: Address -> Paged -> SortOrder -> BlockfrostClient [AccountRegistration]+getAccountRegistrations' a pg s = go (\p -> getAccountRegistrations_ p a pg s)++-- | Obtain information about the registrations and deregistrations of a specific account.+getAccountRegistrations :: Address -> BlockfrostClient [AccountRegistration]+getAccountRegistrations a = getAccountRegistrations' a def def++getAccountWithdrawals_ :: Project -> Address -> Paged -> SortOrder -> BlockfrostClient [AccountWithdrawal]+getAccountWithdrawals_ = _accountWithdrawals . accountsClient++-- | Obtain information about the withdrawals of a specific account.+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+getAccountWithdrawals' :: Address -> Paged -> SortOrder -> BlockfrostClient [AccountWithdrawal]+getAccountWithdrawals' a pg s = go (\p -> getAccountWithdrawals_ p a pg s)++-- | Obtain information about the withdrawals of a specific account.+getAccountWithdrawals :: Address -> BlockfrostClient [AccountWithdrawal]+getAccountWithdrawals a = getAccountWithdrawals' a def def++getAccountMirs_ :: Project -> Address -> Paged -> SortOrder -> BlockfrostClient [AccountMir]+getAccountMirs_ = _accountMirs . accountsClient++-- | Obtain information about the MIRs of a specific account.+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+getAccountMirs' :: Address -> Paged -> SortOrder -> BlockfrostClient [AccountMir]+getAccountMirs' a pg s = go (\p -> getAccountMirs_ p a pg s)++-- | Obtain information about the MIRs of a specific account.+getAccountMirs :: Address -> BlockfrostClient [AccountMir]+getAccountMirs a = getAccountMirs' a def def
+ src/Blockfrost/Client/Cardano/Addresses.hs view
@@ -0,0 +1,71 @@+-- | Address queries++module Blockfrost.Client.Cardano.Addresses+ ( getAddressInfo+ , getAddressDetails+ , getAddressUtxos+ , getAddressUtxos'+ , getAddressTransactions+ , getAddressTransactions'+ ) where++import Blockfrost.API+import Blockfrost.Client.Types+import Blockfrost.Types++addressesClient :: Project -> AddressesAPI (AsClientT BlockfrostClient)+addressesClient = fromServant . _addresses . cardanoClient++getAddressInfo_ :: Project -> Address -> BlockfrostClient AddressInfo+getAddressInfo_ = _addressInfo . addressesClient++-- | Obtain information about a specific address.+getAddressInfo :: Address -> BlockfrostClient AddressInfo+getAddressInfo a = go (`getAddressInfo_` a)++getAddressDetails_ :: Project -> Address -> BlockfrostClient AddressDetails+getAddressDetails_ = _addressDetails . addressesClient++-- | Obtain details about an address.+getAddressDetails :: Address -> BlockfrostClient AddressDetails+getAddressDetails a = go (`getAddressDetails_` a)++getAddressUtxos_ :: Project -> Address -> Paged -> SortOrder -> BlockfrostClient [AddressUTXO]+getAddressUtxos_ = _addressUtxos . addressesClient++-- | UTXOs of the address.+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+getAddressUtxos' :: Address -> Paged -> SortOrder -> BlockfrostClient [AddressUTXO]+getAddressUtxos' a pg s = go (\p -> getAddressUtxos_ p a pg s)++-- | UTXOs of the address.+getAddressUtxos :: Address -> BlockfrostClient [AddressUTXO]+getAddressUtxos a = getAddressUtxos' a def def++getAddressTransactions_ ::+--- Project -> Address -> BlockfrostClient [AddressTransaction]+ Project+ -> Address+ -> Paged+ -> SortOrder+ -> Maybe BlockIndex+ -> Maybe BlockIndex+ -> BlockfrostClient [AddressTransaction]+getAddressTransactions_ = _addressTransactions . addressesClient++-- | Transactions on the address.+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+-- Also allows support for limiting block ranges using `from`/`to`+-- @BlockIndex@es.+getAddressTransactions' ::+ Address+ -> Paged+ -> SortOrder+ -> Maybe BlockIndex+ -> Maybe BlockIndex+ -> BlockfrostClient [AddressTransaction]+getAddressTransactions' a pg s from to = go (\p -> getAddressTransactions_ p a pg s from to)++-- | Transactions on the address.+getAddressTransactions :: Address -> BlockfrostClient [AddressTransaction]+getAddressTransactions a = getAddressTransactions' a def def Nothing Nothing
+ src/Blockfrost/Client/Cardano/Assets.hs view
@@ -0,0 +1,89 @@+-- | Asset queries++module Blockfrost.Client.Cardano.Assets+ ( getAssets+ , getAssets'+ , getAssetDetails+ , getAssetHistory+ , getAssetHistory'+ , getAssetTransactions+ , getAssetTransactions'+ , getAssetAddresses+ , getAssetAddresses'+ , getAssetsByPolicy+ , getAssetsByPolicy'+ ) where++import Blockfrost.API+import Blockfrost.Client.Types+import Blockfrost.Types++assetsClient :: Project -> AssetsAPI (AsClientT BlockfrostClient)+assetsClient = fromServant . _assets . cardanoClient++getAssets_ :: Project -> Paged -> SortOrder -> BlockfrostClient [AssetInfo]+getAssets_ = _listAssets . assetsClient++-- | List all assets+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+getAssets' :: Paged -> SortOrder -> BlockfrostClient [AssetInfo]+getAssets' pg s = go (\p -> getAssets_ p pg s)++-- | List all assets+getAssets :: BlockfrostClient [AssetInfo]+getAssets = getAssets' def def++getAssetDetails_ :: Project -> AssetId -> BlockfrostClient AssetDetails+getAssetDetails_ = _assetDetails . assetsClient++-- | Information about a specific asset+getAssetDetails :: AssetId -> BlockfrostClient AssetDetails+getAssetDetails a = go (`getAssetDetails_` a)++getAssetHistory_ :: Project -> AssetId -> Paged -> SortOrder -> BlockfrostClient [AssetHistory]+getAssetHistory_ = _assetHistory . assetsClient++-- | History of a specific asset+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+getAssetHistory' :: AssetId -> Paged -> SortOrder -> BlockfrostClient [AssetHistory]+getAssetHistory' a pg s = go (\p -> getAssetHistory_ p a pg s)++-- | History of a specific asset+getAssetHistory :: AssetId -> BlockfrostClient [AssetHistory]+getAssetHistory a = getAssetHistory' a def def++getAssetTransactions_ :: Project -> AssetId -> Paged -> SortOrder -> BlockfrostClient [AssetTransaction]+getAssetTransactions_ = _assetTransactions . assetsClient++-- | List of a specific asset transactions+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+getAssetTransactions' :: AssetId -> Paged -> SortOrder -> BlockfrostClient [AssetTransaction]+getAssetTransactions' a pg s = go (\p -> getAssetTransactions_ p a pg s)++-- | List of a specific asset transactions+getAssetTransactions :: AssetId -> BlockfrostClient [AssetTransaction]+getAssetTransactions a = getAssetTransactions' a def def++getAssetAddresses_ :: Project -> AssetId -> Paged -> SortOrder -> BlockfrostClient [AssetAddress]+getAssetAddresses_ = _assetAddresses . assetsClient++-- | List of a addresses containing a specific asset+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+getAssetAddresses' :: AssetId -> Paged -> SortOrder -> BlockfrostClient [AssetAddress]+getAssetAddresses' a pg s = go (\p -> getAssetAddresses_ p a pg s)++-- | List of a addresses containing a specific asset+getAssetAddresses :: AssetId -> BlockfrostClient [AssetAddress]+getAssetAddresses a = getAssetAddresses' a def def++getAssetsByPolicy_ :: Project -> PolicyId -> Paged -> SortOrder -> BlockfrostClient [AssetInfo]+getAssetsByPolicy_ = _listAssetsPolicy . assetsClient++-- | List of asset minted under a specific policy+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+getAssetsByPolicy' :: PolicyId -> Paged -> SortOrder -> BlockfrostClient [AssetInfo]+getAssetsByPolicy' a pg s = go (\p -> getAssetsByPolicy_ p a pg s)++-- | List of asset minted under a specific policy+getAssetsByPolicy :: PolicyId -> BlockfrostClient [AssetInfo]+getAssetsByPolicy a = getAssetsByPolicy' a def def
+ src/Blockfrost/Client/Cardano/Blocks.hs view
@@ -0,0 +1,98 @@+-- | Block queries++module Blockfrost.Client.Cardano.Blocks+ ( getLatestBlock+ , getLatestBlockTxs+ , getLatestBlockTxs'+ , getBlock+ , getBlockSlot+ , getBlockEpochSlot+ , getNextBlocks+ , getNextBlocks'+ , getPreviousBlocks+ , getPreviousBlocks'+ , getBlockTxs+ , getBlockTxs'+ ) where++import Blockfrost.API+import Blockfrost.Client.Types+import Blockfrost.Types++blocksClient :: Project -> BlocksAPI (AsClientT BlockfrostClient)+blocksClient = fromServant . _blocks . cardanoClient++getLatestBlock_ :: Project -> BlockfrostClient Block+getLatestBlock_ = _latest . blocksClient++-- | Return the latest block available to the backends, also known as the tip of the blockchain.+getLatestBlock :: BlockfrostClient Block+getLatestBlock = go getLatestBlock_++getLatestBlockTxs_ :: Project -> Paged -> SortOrder -> BlockfrostClient [TxHash]+getLatestBlockTxs_ = _latestTxs . blocksClient++-- | Return the transactions within the latest block.+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+getLatestBlockTxs' :: Paged -> SortOrder -> BlockfrostClient [TxHash]+getLatestBlockTxs' pg s = go (\p -> getLatestBlockTxs_ p pg s)++getLatestBlockTxs :: BlockfrostClient [TxHash]+getLatestBlockTxs = getLatestBlockTxs' def def++getBlock_ :: Project -> Either Integer BlockHash -> BlockfrostClient Block+getBlock_ = _block . blocksClient++-- | Return the content of a requested block.+getBlock :: Either Integer BlockHash -> BlockfrostClient Block+getBlock a = go (`getBlock_` a)++getBlockSlot_ :: Project -> Slot -> BlockfrostClient Block+getBlockSlot_ = __blockSlot . blocksClient++-- | Return the content of a requested block for a specific slot.+getBlockSlot :: Slot -> BlockfrostClient Block+getBlockSlot i = go (`getBlockSlot_` i)++getBlockEpochSlot_ :: Project -> Epoch -> Slot -> BlockfrostClient Block+getBlockEpochSlot_ = __blockEpochSlot . blocksClient++-- | Return the content of a requested block for a specific slot in an epoch.+getBlockEpochSlot :: Epoch -> Slot -> BlockfrostClient Block+getBlockEpochSlot ep sl = go (\p -> getBlockEpochSlot_ p ep sl)++getNextBlocks_ :: Project -> Either Integer BlockHash -> Paged -> BlockfrostClient [Block]+getNextBlocks_ = _blockNext . blocksClient++-- | Return the list of blocks following a specific block.+-- Allows custom paging using @Paged@.+getNextBlocks' :: Either Integer BlockHash -> Paged -> BlockfrostClient [Block]+getNextBlocks' a pg = go (\p -> getNextBlocks_ p a pg)++-- | Return the list of blocks following a specific block.+getNextBlocks :: Either Integer BlockHash -> BlockfrostClient [Block]+getNextBlocks a = getNextBlocks' a def++getPreviousBlocks_ :: Project -> Either Integer BlockHash -> Paged -> BlockfrostClient [Block]+getPreviousBlocks_ = _blockPrevious . blocksClient++-- | Return the list of blocks preceding a specific block.+-- Allows custom paging using @Paged@.+getPreviousBlocks' :: Either Integer BlockHash -> Paged -> BlockfrostClient [Block]+getPreviousBlocks' a pg = go (\p -> getPreviousBlocks_ p a pg)++-- | Return the list of blocks preceding a specific block.+getPreviousBlocks :: Either Integer BlockHash -> BlockfrostClient [Block]+getPreviousBlocks a = getPreviousBlocks' a def++getBlockTxs_ :: Project -> Either Integer BlockHash -> Paged -> SortOrder -> BlockfrostClient [TxHash]+getBlockTxs_ = _blockTxs . blocksClient++-- | Return the transactions within the block.+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+getBlockTxs' :: Either Integer BlockHash -> Paged -> SortOrder -> BlockfrostClient [TxHash]+getBlockTxs' a pg s = go (\p -> getBlockTxs_ p a pg s)++-- | Return the transactions within the block.+getBlockTxs :: Either Integer BlockHash -> BlockfrostClient [TxHash]+getBlockTxs a = getBlockTxs' a def def
+ src/Blockfrost/Client/Cardano/Epochs.hs view
@@ -0,0 +1,128 @@+-- | Epoch queries++module Blockfrost.Client.Cardano.Epochs+ ( getLatestEpoch+ , getLatestEpochProtocolParams+ , getEpoch+ , getNextEpochs+ , getNextEpochs'+ , getPreviousEpochs+ , getPreviousEpochs'+ , getEpochStake+ , getEpochStake'+ , getEpochStakeByPool+ , getEpochStakeByPool'+ , getEpochBlocks+ , getEpochBlocks'+ , getEpochBlocksByPool+ , getEpochBlocksByPool'+ , getEpochProtocolParams+ ) where++import Blockfrost.API+import Blockfrost.Client.Types+import Blockfrost.Types+++epochsClient :: Project -> EpochsAPI (AsClientT BlockfrostClient)+epochsClient = fromServant . _epochs . cardanoClient++getLatestEpoch_ :: Project -> BlockfrostClient EpochInfo+getLatestEpoch_ = _latestEpoch . epochsClient++-- | Get the information about the latest, therefore current, epoch.+getLatestEpoch :: BlockfrostClient EpochInfo+getLatestEpoch = go getLatestEpoch_++getLatestEpochProtocolParams_ :: Project -> BlockfrostClient ProtocolParams+getLatestEpochProtocolParams_ = _latestEpochProtocolParams . epochsClient++-- | Get the protocol parameters for the latest epoch.+getLatestEpochProtocolParams :: BlockfrostClient ProtocolParams+getLatestEpochProtocolParams = go getLatestEpochProtocolParams_++getEpoch_ :: Project -> Epoch -> BlockfrostClient EpochInfo+getEpoch_ = _getEpoch . epochsClient++-- | Get the information about specific epoch.+getEpoch :: Epoch -> BlockfrostClient EpochInfo+getEpoch e = go (`getEpoch_` e)++getNextEpochs_ :: Project -> Epoch -> Paged -> BlockfrostClient [EpochInfo]+getNextEpochs_ = _getNextEpochs . epochsClient++-- | Return the list of epochs following a specific epoch.+-- Allows custom paging using @Paged@.+getNextEpochs' :: Epoch -> Paged -> BlockfrostClient [EpochInfo]+getNextEpochs' e pg = go (\p -> getNextEpochs_ p e pg)++-- | Return the list of epochs following a specific epoch.+getNextEpochs :: Epoch -> BlockfrostClient [EpochInfo]+getNextEpochs e = getNextEpochs' e def++getPreviousEpochs_ :: Project -> Epoch -> Paged -> BlockfrostClient [EpochInfo]+getPreviousEpochs_ = _getPreviousEpochs . epochsClient++-- | Return the list of epochs preceding a specific epoch.+-- Allows custom paging using @Paged@.+getPreviousEpochs' :: Epoch -> Paged -> BlockfrostClient [EpochInfo]+getPreviousEpochs' e pg = go (\p -> getPreviousEpochs_ p e pg)++-- | Return the list of epochs preceding a specific epoch.+getPreviousEpochs :: Epoch -> BlockfrostClient [EpochInfo]+getPreviousEpochs e = getPreviousEpochs' e def++getEpochStake_ :: Project -> Epoch -> Paged -> BlockfrostClient [StakeDistribution]+getEpochStake_ = _getEpochStake . epochsClient++-- | Return the active stake distribution for the specified epoch.+-- Allows custom paging using @Paged@.+getEpochStake' :: Epoch -> Paged -> BlockfrostClient [StakeDistribution]+getEpochStake' e pg = go (\p -> getEpochStake_ p e pg)++-- | Return the active stake distribution for the specified epoch.+getEpochStake :: Epoch -> BlockfrostClient [StakeDistribution]+getEpochStake e = getEpochStake' e def++getEpochStakeByPool_ :: Project -> Epoch -> PoolId -> Paged -> BlockfrostClient [StakeDistribution]+getEpochStakeByPool_ = _getEpochStakeByPool . epochsClient++-- | Return the active stake distribution for the epoch specified by stake pool.+-- Allows custom paging using @Paged@.+getEpochStakeByPool' :: Epoch -> PoolId -> Paged -> BlockfrostClient [StakeDistribution]+getEpochStakeByPool' e i pg = go (\p -> getEpochStakeByPool_ p e i pg)++-- | Return the active stake distribution for the epoch specified by stake pool.+getEpochStakeByPool :: Epoch -> PoolId -> BlockfrostClient [StakeDistribution]+getEpochStakeByPool e i = getEpochStakeByPool' e i def++getEpochBlocks_ :: Project -> Epoch -> Paged -> SortOrder -> BlockfrostClient [BlockHash]+getEpochBlocks_ = _getEpochBlocks . epochsClient++-- | Return the blocks minted for the epoch specified.+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+getEpochBlocks' :: Epoch -> Paged -> SortOrder -> BlockfrostClient [BlockHash]+getEpochBlocks' e pg s = go (\p -> getEpochBlocks_ p e pg s)++-- | Return the blocks minted for the epoch specified.+getEpochBlocks :: Epoch -> BlockfrostClient [BlockHash]+getEpochBlocks e = getEpochBlocks' e def def++getEpochBlocksByPool_ :: Project -> Epoch -> PoolId -> Paged -> SortOrder -> BlockfrostClient [BlockHash]+getEpochBlocksByPool_ = _getEpochBlocksByPool . epochsClient++-- | Return the block minted for the epoch specified by stake pool.+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+getEpochBlocksByPool' :: Epoch -> PoolId -> Paged -> SortOrder -> BlockfrostClient [BlockHash]+getEpochBlocksByPool' e i pg s = go (\p -> getEpochBlocksByPool_ p e i pg s)++-- | Return the block minted for the epoch specified by stake pool.+getEpochBlocksByPool :: Epoch -> PoolId -> BlockfrostClient [BlockHash]+getEpochBlocksByPool e i = getEpochBlocksByPool' e i def def++getEpochProtocolParams_ :: Project -> Epoch -> BlockfrostClient ProtocolParams+getEpochProtocolParams_ = _getEpochProtocolParams . epochsClient++-- | Return the protocol parameters for the specified epoch.+getEpochProtocolParams :: Epoch -> BlockfrostClient ProtocolParams+getEpochProtocolParams e = go (`getEpochProtocolParams_` e)
+ src/Blockfrost/Client/Cardano/Ledger.hs view
@@ -0,0 +1,19 @@+-- | Ledger queries++module Blockfrost.Client.Cardano.Ledger+ ( getLedgerGenesis+ ) where++import Blockfrost.API+import Blockfrost.Client.Types+import Blockfrost.Types++ledgerClient :: Project -> LedgerAPI (AsClientT BlockfrostClient)+ledgerClient = fromServant . _ledger . cardanoClient++getLedgerGenesis_ :: Project -> BlockfrostClient Genesis+getLedgerGenesis_ = _genesis . ledgerClient++-- | Get the information about blockchain genesis.+getLedgerGenesis:: BlockfrostClient Genesis+getLedgerGenesis = go getLedgerGenesis_
+ src/Blockfrost/Client/Cardano/Metadata.hs view
@@ -0,0 +1,54 @@+-- | Metadata queries++module Blockfrost.Client.Cardano.Metadata+ ( getTxMetadataLabels+ , getTxMetadataLabels'+ , getTxMetadataByLabelJSON+ , getTxMetadataByLabelJSON'+ , getTxMetadataByLabelCBOR+ , getTxMetadataByLabelCBOR'+ ) where++import Blockfrost.API+import Blockfrost.Client.Types+import Blockfrost.Types+import Data.Text (Text)++metadataClient :: Project -> MetadataAPI (AsClientT BlockfrostClient)+metadataClient = fromServant . _metadata . cardanoClient++getTxMetadataLabels_ :: Project -> Paged -> SortOrder -> BlockfrostClient [TxMeta]+getTxMetadataLabels_ = _txMetadataLabels . metadataClient++-- | List of all used transaction metadata labels.+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+getTxMetadataLabels' :: Paged -> SortOrder -> BlockfrostClient [TxMeta]+getTxMetadataLabels' pg s = go (\p -> getTxMetadataLabels_ p pg s)++-- | List of all used transaction metadata labels.+getTxMetadataLabels :: BlockfrostClient [TxMeta]+getTxMetadataLabels = getTxMetadataLabels' def def++getTxMetadataByLabelJSON_ :: Project -> Text -> Paged -> SortOrder -> BlockfrostClient [TxMetaJSON]+getTxMetadataByLabelJSON_ = _txMetadataByLabelJSON . metadataClient++-- | Transaction metadata per label (JSON @Value@)+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+getTxMetadataByLabelJSON' :: Text -> Paged -> SortOrder -> BlockfrostClient [TxMetaJSON]+getTxMetadataByLabelJSON' t pg s = go (\p -> getTxMetadataByLabelJSON_ p t pg s)++-- | Transaction metadata per label (JSON @Value@)+getTxMetadataByLabelJSON :: Text -> BlockfrostClient [TxMetaJSON]+getTxMetadataByLabelJSON t = getTxMetadataByLabelJSON' t def def++getTxMetadataByLabelCBOR_ :: Project -> Text -> Paged -> SortOrder -> BlockfrostClient [TxMetaCBOR]+getTxMetadataByLabelCBOR_ = _txMetadataByLabelCBOR . metadataClient++-- | Transaction metadata per label (CBOR @ByteString@)+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+getTxMetadataByLabelCBOR' :: Text -> Paged -> SortOrder -> BlockfrostClient [TxMetaCBOR]+getTxMetadataByLabelCBOR' t pg s = go (\p -> getTxMetadataByLabelCBOR_ p t pg s)++-- | Transaction metadata per label (CBOR @ByteString@)+getTxMetadataByLabelCBOR :: Text -> BlockfrostClient [TxMetaCBOR]+getTxMetadataByLabelCBOR t = getTxMetadataByLabelCBOR' t def def
+ src/Blockfrost/Client/Cardano/Network.hs view
@@ -0,0 +1,20 @@+-- | Network queries++module Blockfrost.Client.Cardano.Network+ ( getNetworkInfo+ ) where++import Blockfrost.API+import Blockfrost.Client.Types+import Blockfrost.Types+++networkClient :: Project -> NetworkAPI (AsClientT BlockfrostClient)+networkClient = fromServant . _network . cardanoClient++getNetworkInfo_ :: Project -> BlockfrostClient Network+getNetworkInfo_ = _networkInfo . networkClient++-- | Get detailed network information.+getNetworkInfo:: BlockfrostClient Network+getNetworkInfo = go getNetworkInfo_
+ src/Blockfrost/Client/Cardano/Pools.hs view
@@ -0,0 +1,133 @@+-- | Pool queries++module Blockfrost.Client.Cardano.Pools+ ( listPools+ , listPools'+ , listRetiredPools+ , listRetiredPools'+ , listRetiringPools+ , listRetiringPools'+ , getPool+ , getPoolHistory+ , getPoolHistory'+ , getPoolMetadata+ , getPoolRelays+ , getPoolDelegators+ , getPoolDelegators'+ , getPoolBlocks+ , getPoolBlocks'+ , getPoolUpdates+ , getPoolUpdates'+ ) where++import Blockfrost.API+import Blockfrost.Client.Types+import Blockfrost.Types++poolsClient :: Project -> PoolsAPI (AsClientT BlockfrostClient)+poolsClient = fromServant . _pools . cardanoClient++listPools_ :: Project -> Paged -> SortOrder -> BlockfrostClient [PoolId]+listPools_ = _listPools . poolsClient++-- | List registered stake pools.+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+listPools' :: Paged -> SortOrder -> BlockfrostClient [PoolId]+listPools' pg s = go (\p -> listPools_ p pg s)++-- | List registered stake pools.+listPools :: BlockfrostClient [PoolId]+listPools = listPools' def def++listRetiredPools_ :: Project -> Paged -> SortOrder -> BlockfrostClient [PoolEpoch]+listRetiredPools_ = _listRetiredPools . poolsClient++-- | List retired stake pools.+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+listRetiredPools' :: Paged -> SortOrder -> BlockfrostClient [PoolEpoch]+listRetiredPools' pg s = go (\p -> listRetiredPools_ p pg s)++-- | List retired stake pools.+listRetiredPools :: BlockfrostClient [PoolEpoch]+listRetiredPools = listRetiredPools' def def++listRetiringPools_ :: Project -> Paged -> SortOrder -> BlockfrostClient [PoolEpoch]+listRetiringPools_ = _listRetiringPools . poolsClient++-- | List retiring stake pools.+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+listRetiringPools' :: Paged -> SortOrder -> BlockfrostClient [PoolEpoch]+listRetiringPools' pg s = go (\p -> listRetiringPools_ p pg s)++-- | List retiring stake pools.+listRetiringPools :: BlockfrostClient [PoolEpoch]+listRetiringPools = listRetiringPools' def def++getPool_ :: Project -> PoolId -> BlockfrostClient PoolInfo+getPool_ = _getPool . poolsClient++-- | Get specific stake pool information+getPool:: PoolId -> BlockfrostClient PoolInfo+getPool p = go (`getPool_` p)++getPoolHistory_ :: Project -> PoolId -> Paged -> SortOrder -> BlockfrostClient [PoolHistory]+getPoolHistory_ = _getPoolHistory . poolsClient++-- | Get stake pool history+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+getPoolHistory' :: PoolId -> Paged -> SortOrder -> BlockfrostClient [PoolHistory]+getPoolHistory' pid pg s = go (\p -> getPoolHistory_ p pid pg s)++-- | Get stake pool history+getPoolHistory :: PoolId -> BlockfrostClient [PoolHistory]+getPoolHistory p = getPoolHistory' p def def++getPoolMetadata_ :: Project -> PoolId -> BlockfrostClient (Maybe PoolMetadata)+getPoolMetadata_ = _getPoolMetadata . poolsClient++-- | Get stake pool metadata+getPoolMetadata :: PoolId -> BlockfrostClient (Maybe PoolMetadata)+getPoolMetadata p = go (`getPoolMetadata_` p)++getPoolRelays_ :: Project -> PoolId -> BlockfrostClient [PoolRelay]+getPoolRelays_ = _getPoolRelays . poolsClient++-- | Get stake pool relays+getPoolRelays :: PoolId -> BlockfrostClient [PoolRelay]+getPoolRelays p = go (`getPoolRelays_` p)++getPoolDelegators_ :: Project -> PoolId -> Paged -> SortOrder -> BlockfrostClient [PoolDelegator]+getPoolDelegators_ = _getPoolDelegators . poolsClient++-- | Get stake pool delegators+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+getPoolDelegators' :: PoolId -> Paged -> SortOrder -> BlockfrostClient [PoolDelegator]+getPoolDelegators' pid pg s = go (\p -> getPoolDelegators_ p pid pg s)++-- | Get stake pool delegators+getPoolDelegators :: PoolId -> BlockfrostClient [PoolDelegator]+getPoolDelegators p = getPoolDelegators' p def def++getPoolBlocks_ :: Project -> PoolId -> Paged -> SortOrder -> BlockfrostClient [BlockHash]+getPoolBlocks_ = _getPoolBlocks . poolsClient++-- | Get stake pool blocks+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+getPoolBlocks' :: PoolId -> Paged -> SortOrder -> BlockfrostClient [BlockHash]+getPoolBlocks' pid pg s = go (\p -> getPoolBlocks_ p pid pg s)++-- | Get stake pool blocks+getPoolBlocks :: PoolId -> BlockfrostClient [BlockHash]+getPoolBlocks p = getPoolBlocks' p def def++getPoolUpdates_ :: Project -> PoolId -> Paged -> SortOrder -> BlockfrostClient [PoolUpdate]+getPoolUpdates_ = _getPoolUpdates . poolsClient++-- | Get stake pool updates+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+getPoolUpdates' :: PoolId -> Paged -> SortOrder -> BlockfrostClient [PoolUpdate]+getPoolUpdates' pid pg s = go (\p -> getPoolUpdates_ p pid pg s)++-- | Get stake pool updates+getPoolUpdates :: PoolId -> BlockfrostClient [PoolUpdate]+getPoolUpdates p = getPoolUpdates' p def def
+ src/Blockfrost/Client/Cardano/Transactions.hs view
@@ -0,0 +1,99 @@+-- | Transaction queries++module Blockfrost.Client.Cardano.Transactions+ ( getTx+ , getTxUtxos+ , getTxStakes+ , getTxDelegations+ , getTxWithdrawals+ , getTxMirs+ , getTxPoolUpdates+ , getTxPoolRetiring+ , getTxMetadataJSON+ , getTxMetadataCBOR+ , submitTx+ ) where++import Blockfrost.API+import Blockfrost.Client.Types+import Blockfrost.Types++transactionsClient :: Project -> TransactionsAPI (AsClientT BlockfrostClient)+transactionsClient = fromServant . _transactions . cardanoClient++getTx_ :: Project -> TxHash -> BlockfrostClient Transaction+getTx_ = _tx . transactionsClient++-- | Get specific transaction+getTx :: TxHash -> BlockfrostClient Transaction+getTx t = go (`getTx_` t)++getTxUtxos_ :: Project -> TxHash -> BlockfrostClient TransactionUtxos+getTxUtxos_ = _txUtxos . transactionsClient++-- | Get transaction UTXOs+getTxUtxos :: TxHash -> BlockfrostClient TransactionUtxos+getTxUtxos t = go (`getTxUtxos_` t)++getTxStakes_ :: Project -> TxHash -> BlockfrostClient [TransactionStake]+getTxStakes_ = _txStakes . transactionsClient++-- | Get transaction UTXOs+getTxStakes :: TxHash -> BlockfrostClient [TransactionStake]+getTxStakes t = go (`getTxStakes_` t)++getTxDelegations_ :: Project -> TxHash -> BlockfrostClient [TransactionDelegation]+getTxDelegations_ = _txDelegations . transactionsClient++-- | Get transaction delegation certificates+getTxDelegations :: TxHash -> BlockfrostClient [TransactionDelegation]+getTxDelegations t = go (`getTxDelegations_` t)++getTxWithdrawals_ :: Project -> TxHash -> BlockfrostClient [TransactionWithdrawal]+getTxWithdrawals_ = _txWithdrawals . transactionsClient++-- | Get transaction withdrawals+getTxWithdrawals :: TxHash -> BlockfrostClient [TransactionWithdrawal]+getTxWithdrawals t = go (`getTxWithdrawals_` t)++getTxMirs_ :: Project -> TxHash -> BlockfrostClient [TransactionMir]+getTxMirs_ = _txMirs . transactionsClient++-- | Get transaction MIRs (Move Instantaneous Rewards)+getTxMirs :: TxHash -> BlockfrostClient [TransactionMir]+getTxMirs t = go (`getTxMirs_` t)++getTxPoolUpdates_ :: Project -> TxHash -> BlockfrostClient [TransactionPoolUpdate]+getTxPoolUpdates_ = _txPoolUpdates . transactionsClient++-- | Get transaction stake pool registration and update certificates+getTxPoolUpdates :: TxHash -> BlockfrostClient [TransactionPoolUpdate]+getTxPoolUpdates t = go (`getTxPoolUpdates_` t)++getTxPoolRetiring_ :: Project -> TxHash -> BlockfrostClient [TransactionPoolRetiring]+getTxPoolRetiring_ = _txPoolRetiring . transactionsClient++-- | Get transaction stake pool retirement certificates+getTxPoolRetiring :: TxHash -> BlockfrostClient [TransactionPoolRetiring]+getTxPoolRetiring t = go (`getTxPoolRetiring_` t)++getTxMetadataJSON_ :: Project -> TxHash -> BlockfrostClient [TransactionMetaJSON]+getTxMetadataJSON_ = _txMetadataJSON . transactionsClient++-- | Get transaction metadata in JSON+getTxMetadataJSON :: TxHash -> BlockfrostClient [TransactionMetaJSON]+getTxMetadataJSON t = go (`getTxMetadataJSON_` t)++getTxMetadataCBOR_ :: Project -> TxHash -> BlockfrostClient [TransactionMetaCBOR]+getTxMetadataCBOR_ = _txMetadataCBOR . transactionsClient++-- | Get transaction metadata in CBOR+getTxMetadataCBOR :: TxHash -> BlockfrostClient [TransactionMetaCBOR]+getTxMetadataCBOR t = go (`getTxMetadataCBOR_` t)++submitTx_ :: Project -> CBORString -> BlockfrostClient TxHash+submitTx_ = _txSubmit . cardanoClient++-- | Submit an already serialized transaction to the network.+submitTx :: CBORString -> BlockfrostClient TxHash+submitTx txCbor = go (`submitTx_` txCbor)
+ src/Blockfrost/Client/IPFS.hs view
@@ -0,0 +1,77 @@+-- | IPFS client functions+{-# LANGUAGE OverloadedStrings #-}++module Blockfrost.Client.IPFS+ ( ipfsAdd+ , ipfsGateway+ , ipfsGetPin+ , ipfsListPins+ , ipfsListPins'+ , ipfsPin+ , ipfsRemovePin+ ) where++import Blockfrost.API+import Blockfrost.Client.Types+import Blockfrost.Types+import Control.Monad.Except+import Data.ByteString.Lazy (ByteString)+import Data.Text (Text)+import qualified Data.Text+import qualified System.Directory+import qualified System.FilePath++ipfsAdd_ :: Project -> (ByteString, Form) -> BlockfrostClient IPFSAdd+ipfsAdd_ = _add . ipfsClient++-- | Add a file or directory to IPFS+ipfsAdd :: FilePath -> BlockfrostClient IPFSAdd+ipfsAdd fp = do+ hasFile <- liftIO $ System.Directory.doesFileExist fp+ if hasFile+ then do+ liftIO $ putStrLn $ "Uploading: " ++ fp+ let fn = Data.Text.pack $ System.FilePath.takeBaseName fp+ go (\proj -> ipfsAdd_ proj ("suchBoundary", (Form fn fp)))+ else+ throwError (BlockfrostError "No such file")++ipfsGateway_ :: Project -> Text -> BlockfrostClient IPFSData+ipfsGateway_ = _gateway . ipfsClient++-- | Fetch file via API+ipfsGateway :: Text -> BlockfrostClient IPFSData+ipfsGateway x = go (`ipfsGateway_` x)++ipfsPin_ :: Project -> Text -> BlockfrostClient IPFSPinChange+ipfsPin_ = _pin . ipfsClient++-- | Pin an object+ipfsPin :: Text -> BlockfrostClient IPFSPinChange+ipfsPin x = go (`ipfsPin_` x)++ipfsListPins_ :: Project -> Paged -> SortOrder -> BlockfrostClient [IPFSPin]+ipfsListPins_ = _listPins . ipfsClient++-- | List objects pinned to local storage+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+ipfsListPins' :: Paged -> SortOrder -> BlockfrostClient [IPFSPin]+ipfsListPins' pg s = go (\p -> ipfsListPins_ p pg s)++-- | List objects pinned to local storage+ipfsListPins :: BlockfrostClient [IPFSPin]+ipfsListPins = ipfsListPins' def def++ipfsGetPin_ :: Project -> Text -> BlockfrostClient IPFSPin+ipfsGetPin_ = _getPin . ipfsClient++-- | Get pinned object details+ipfsGetPin :: Text -> BlockfrostClient IPFSPin+ipfsGetPin x = go (`ipfsGetPin_` x)++ipfsRemovePin_ :: Project -> Text -> BlockfrostClient IPFSPinChange+ipfsRemovePin_ = _removePin . ipfsClient++-- | Remove pinned object from local storage+ipfsRemovePin :: Text -> BlockfrostClient IPFSPinChange+ipfsRemovePin x = go (`ipfsRemovePin_` x)
+ src/Blockfrost/Client/NutLink.hs view
@@ -0,0 +1,59 @@+-- | Nut.link client functions++module Blockfrost.Client.NutLink+ ( nutlinkAddressTickers+ , nutlinkAddressTickers'+ , nutlinkListAddress+ , nutlinkListAddressTickers+ , nutlinkListAddressTickers'+ , nutlinkTickers+ , nutlinkTickers'+ ) where++import Blockfrost.API+import Blockfrost.Client.Types+import Blockfrost.Types+import Data.Text (Text)++nutlinkListAddress_ :: Project -> Address-> BlockfrostClient NutlinkAddress+nutlinkListAddress_ = _address . nutLinkClient++-- | List metadata about specific address+nutlinkListAddress :: Address -> BlockfrostClient NutlinkAddress+nutlinkListAddress a = go (`nutlinkListAddress_` a)++nutlinkListAddressTickers_ :: Project -> Address -> Paged -> SortOrder -> BlockfrostClient [NutlinkAddressTicker]+nutlinkListAddressTickers_ = _listAddressTickers . nutLinkClient++-- | List tickers for a specific metadata oracle+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+nutlinkListAddressTickers' :: Address -> Paged -> SortOrder -> BlockfrostClient [NutlinkAddressTicker]+nutlinkListAddressTickers' a pg s = go (\p -> nutlinkListAddressTickers_ p a pg s)++-- | List tickers for a specific metadata oracle+nutlinkListAddressTickers :: Address -> BlockfrostClient [NutlinkAddressTicker]+nutlinkListAddressTickers a = nutlinkListAddressTickers' a def def++nutlinkAddressTickers_ :: Project -> Address -> Text -> Paged -> SortOrder -> BlockfrostClient [NutlinkTicker]+nutlinkAddressTickers_ = _addressTickers . nutLinkClient++-- | List of records of a specific ticker+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+nutlinkAddressTickers' :: Address -> Text -> Paged -> SortOrder -> BlockfrostClient [NutlinkTicker]+nutlinkAddressTickers' a t pg s = go (\p -> nutlinkAddressTickers_ p a t pg s)++-- | List of records of a specific ticker+nutlinkAddressTickers :: Address -> Text -> BlockfrostClient [NutlinkTicker]+nutlinkAddressTickers a t = nutlinkAddressTickers' a t def def++nutlinkTickers_ :: Project -> Text -> Paged -> SortOrder -> BlockfrostClient [(Address, NutlinkTicker)]+nutlinkTickers_ = _tickers . nutLinkClient++-- | List of records of a specific ticker+-- Allows custom paging and ordering using @Paged@ and @SortOrder@.+nutlinkTickers' :: Text -> Paged -> SortOrder -> BlockfrostClient [(Address, NutlinkTicker)]+nutlinkTickers' a pg s = go (\p -> nutlinkTickers_ p a pg s)++-- | List of records of a specific ticker+nutlinkTickers :: Text -> BlockfrostClient [(Address, NutlinkTicker)]+nutlinkTickers a = nutlinkTickers' a def def
+ src/Blockfrost/Client/Types.hs view
@@ -0,0 +1,88 @@+-- | Client Types+{-# LANGUAGE CPP #-}++module Blockfrost.Client.Types+ ( BlockfrostClient+ , BlockfrostError (..)+ , ClientConfig+ , runBlockfrost+ , apiClient+ , api0Client+ , commonClient+ , cardanoClient+ , ipfsClient+ , nutLinkClient+ , Project (..)+ , Paged (..)+ , SortOrder (..)+ , go+ , AsClientT+ , fromServant+ , tryError+ , def+ ) where++import Control.Monad.Except+import Control.Monad.Reader+import Data.Default++import Servant.API.Generic+import Servant.Client+import Servant.Client.Generic++import Blockfrost.API+import Blockfrost.Client.Core++type ClientConfig = (ClientEnv, Project)+type BlockfrostClient =+ ExceptT BlockfrostError+ (ReaderT ClientConfig IO)++apiClient :: BlockfrostAPI (AsClientT BlockfrostClient)+apiClient = genericClientHoist nt+ where nt :: ClientM a -> BlockfrostClient a+ nt act = do+ (env, _proj) <- ask+ liftIO (runClientM act env)+ >>= either (throwError . fromServantClientError) pure++api0Client :: Project -> BlockfrostV0API (AsClientT BlockfrostClient)+api0Client = fromServant . _apiV0 apiClient++-- ** Client runner++-- | Run @BlockfrostClient@ monad, using provided @Project@+runBlockfrost :: Project+ -> BlockfrostClient a+ -> IO (Either BlockfrostError a)+runBlockfrost proj act = do+ env <- newEnvByProject proj+ flip runReaderT (env, proj)+ $ runExceptT act++-- | Helper+go :: (Project -> BlockfrostClient a)+ -> BlockfrostClient a+go act = ask >>= act . snd++-- Until mtl > 2.2.2+-- https://github.com/haskell/mtl/pull/66+#if !MIN_VERSION_mtl(2,3,0)+-- | 'MonadError' analogue to the 'Control.Exception.try' function.+tryError :: MonadError e m => m a -> m (Either e a)+tryError action = (Right <$> action) `catchError` (pure . Left)+#endif++-- ** Service clients++commonClient :: Project -> CommonAPI (AsClientT BlockfrostClient)+commonClient = fromServant . _common . api0Client++cardanoClient :: Project -> CardanoAPI (AsClientT BlockfrostClient)+cardanoClient = fromServant . _cardano . api0Client++ipfsClient :: Project -> IPFSAPI (AsClientT BlockfrostClient)+ipfsClient = fromServant . _ipfs . api0Client++nutLinkClient :: Project -> NutLinkAPI (AsClientT BlockfrostClient)+nutLinkClient = fromServant . _nutLink . api0Client
+ test/SampleSpec.hs view
@@ -0,0 +1,16 @@+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE TemplateHaskell #-}++module SampleSpec+ where++import Test.Hspec+import Test.Tasty.Hspec++spec_sample :: Spec+spec_sample = do+ it "has tests" $ do+ True `shouldBe` True++--main :: IO ()+--main = hspec spec
+ test/Spec.hs view
@@ -0,0 +1,1 @@+{-# OPTIONS_GHC -F -pgmF tasty-discover #-}