-- | Network queries

module Blockfrost.Client.Cardano.Network
  ( getNetworkInfo
  , getNetworkEras
  ) where

import Blockfrost.API
import Blockfrost.Client.Types
import Blockfrost.Types


networkClient :: MonadBlockfrost m => Project -> NetworkAPI (AsClientT m)
networkClient :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> NetworkAPI (AsClientT m)
networkClient = (m Network :<|> m [NetworkEraSummary]) -> NetworkAPI (AsClientT m)
ToServant NetworkAPI (AsClientT m) -> NetworkAPI (AsClientT m)
forall {k} (routes :: k -> *) (mode :: k).
GenericServant routes mode =>
ToServant routes mode -> routes mode
fromServant ((m Network :<|> m [NetworkEraSummary])
 -> NetworkAPI (AsClientT m))
-> (Project -> m Network :<|> m [NetworkEraSummary])
-> Project
-> NetworkAPI (AsClientT m)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CardanoAPI (AsClientT m) -> m Network :<|> m [NetworkEraSummary]
CardanoAPI (AsClientT m)
-> AsClientT m
   :- ("network"
       :> (Tag "Cardano \187 Network" :> ToServantApi NetworkAPI))
forall route.
CardanoAPI route
-> route
   :- ("network"
       :> (Tag "Cardano \187 Network" :> ToServantApi NetworkAPI))
_network (CardanoAPI (AsClientT m) -> m Network :<|> m [NetworkEraSummary])
-> (Project -> CardanoAPI (AsClientT m))
-> Project
-> m Network :<|> m [NetworkEraSummary]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Project -> CardanoAPI (AsClientT m)
forall (m :: * -> *).
MonadBlockfrost m =>
Project -> CardanoAPI (AsClientT m)
cardanoClient

getNetworkInfo_ :: MonadBlockfrost m => Project -> m Network
getNetworkInfo_ :: forall (m :: * -> *). MonadBlockfrost m => Project -> m Network
getNetworkInfo_ = NetworkAPI (AsClientT m) -> m Network
NetworkAPI (AsClientT m)
-> AsClientT m
   :- (Summary "Network information"
       :> (Description "Return detailed network information."
           :> Get '[JSON] Network))
forall route.
NetworkAPI route
-> route
   :- (Summary "Network information"
       :> (Description "Return detailed network information."
           :> Get '[JSON] Network))
_networkInfo (NetworkAPI (AsClientT m) -> m Network)
-> (Project -> NetworkAPI (AsClientT m)) -> Project -> m Network
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Project -> NetworkAPI (AsClientT m)
forall (m :: * -> *).
MonadBlockfrost m =>
Project -> NetworkAPI (AsClientT m)
networkClient

-- | Get detailed network information.
getNetworkInfo :: MonadBlockfrost m => m Network
getNetworkInfo :: forall (m :: * -> *). MonadBlockfrost m => m Network
getNetworkInfo = (Project -> m Network) -> m Network
forall (m :: * -> *) a.
MonadBlockfrost m =>
(Project -> m a) -> m a
go Project -> m Network
forall (m :: * -> *). MonadBlockfrost m => Project -> m Network
getNetworkInfo_

getNetworkEras_ :: MonadBlockfrost m => Project -> m [NetworkEraSummary]
getNetworkEras_ :: forall (m :: * -> *).
MonadBlockfrost m =>
Project -> m [NetworkEraSummary]
getNetworkEras_ = NetworkAPI (AsClientT m) -> m [NetworkEraSummary]
NetworkAPI (AsClientT m)
-> AsClientT m
   :- (Summary "Query summary of blockchain eras"
       :> (Description
             "Returns start and end of each era along with parameters that can vary between hard forks."
           :> ("eras" :> Get '[JSON] [NetworkEraSummary])))
forall route.
NetworkAPI route
-> route
   :- (Summary "Query summary of blockchain eras"
       :> (Description
             "Returns start and end of each era along with parameters that can vary between hard forks."
           :> ("eras" :> Get '[JSON] [NetworkEraSummary])))
_networkEras (NetworkAPI (AsClientT m) -> m [NetworkEraSummary])
-> (Project -> NetworkAPI (AsClientT m))
-> Project
-> m [NetworkEraSummary]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Project -> NetworkAPI (AsClientT m)
forall (m :: * -> *).
MonadBlockfrost m =>
Project -> NetworkAPI (AsClientT m)
networkClient

-- | Get summarized information on each era in the network, including start, end, and variable era parameters.
getNetworkEras :: MonadBlockfrost m => m [NetworkEraSummary]
getNetworkEras :: forall (m :: * -> *). MonadBlockfrost m => m [NetworkEraSummary]
getNetworkEras = (Project -> m [NetworkEraSummary]) -> m [NetworkEraSummary]
forall (m :: * -> *) a.
MonadBlockfrost m =>
(Project -> m a) -> m a
go Project -> m [NetworkEraSummary]
forall (m :: * -> *).
MonadBlockfrost m =>
Project -> m [NetworkEraSummary]
getNetworkEras_