blockfrost-api 0.7.0.0 → 0.7.1.0
raw patch · 8 files changed
+123/−14 lines, 8 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Blockfrost.Lens: boundEpoch :: HasBoundEpoch s a => Lens' s a
+ Blockfrost.Lens: boundSlot :: HasBoundSlot s a => Lens' s a
+ Blockfrost.Lens: boundTime :: HasBoundTime s a => Lens' s a
+ Blockfrost.Lens: class HasBoundEpoch s a | s -> a
+ Blockfrost.Lens: class HasBoundSlot s a | s -> a
+ Blockfrost.Lens: class HasBoundTime s a | s -> a
+ Blockfrost.Lens: class HasNetworkEraEnd s a | s -> a
+ Blockfrost.Lens: class HasNetworkEraParameters s a | s -> a
+ Blockfrost.Lens: class HasNetworkEraStart s a | s -> a
+ Blockfrost.Lens: class HasParametersEpochLength s a | s -> a
+ Blockfrost.Lens: class HasParametersSafeZone s a | s -> a
+ Blockfrost.Lens: class HasParametersSlotLength s a | s -> a
+ Blockfrost.Lens: class HasStakeActive s a | s -> a
+ Blockfrost.Lens: class HasStakeLive s a | s -> a
+ Blockfrost.Lens: class HasSupplyCirculating s a | s -> a
+ Blockfrost.Lens: class HasSupplyLocked s a | s -> a
+ Blockfrost.Lens: class HasSupplyMax s a | s -> a
+ Blockfrost.Lens: class HasSupplyReserves s a | s -> a
+ Blockfrost.Lens: class HasSupplyTotal s a | s -> a
+ Blockfrost.Lens: class HasSupplyTreasury s a | s -> a
+ Blockfrost.Lens: instance (a GHC.Types.~ Blockfrost.Types.Shared.Ada.Lovelaces) => Blockfrost.Lens.HasStakeActive Blockfrost.Types.Cardano.Network.NetworkStake a
+ Blockfrost.Lens: instance (a GHC.Types.~ Blockfrost.Types.Shared.Ada.Lovelaces) => Blockfrost.Lens.HasStakeLive Blockfrost.Types.Cardano.Network.NetworkStake a
+ Blockfrost.Lens: instance (a GHC.Types.~ Blockfrost.Types.Shared.Ada.Lovelaces) => Blockfrost.Lens.HasSupplyCirculating Blockfrost.Types.Cardano.Network.NetworkSupply a
+ Blockfrost.Lens: instance (a GHC.Types.~ Blockfrost.Types.Shared.Ada.Lovelaces) => Blockfrost.Lens.HasSupplyLocked Blockfrost.Types.Cardano.Network.NetworkSupply a
+ Blockfrost.Lens: instance (a GHC.Types.~ Blockfrost.Types.Shared.Ada.Lovelaces) => Blockfrost.Lens.HasSupplyMax Blockfrost.Types.Cardano.Network.NetworkSupply a
+ Blockfrost.Lens: instance (a GHC.Types.~ Blockfrost.Types.Shared.Ada.Lovelaces) => Blockfrost.Lens.HasSupplyReserves Blockfrost.Types.Cardano.Network.NetworkSupply a
+ Blockfrost.Lens: instance (a GHC.Types.~ Blockfrost.Types.Shared.Ada.Lovelaces) => Blockfrost.Lens.HasSupplyTotal Blockfrost.Types.Cardano.Network.NetworkSupply a
+ Blockfrost.Lens: instance (a GHC.Types.~ Blockfrost.Types.Shared.Ada.Lovelaces) => Blockfrost.Lens.HasSupplyTreasury Blockfrost.Types.Cardano.Network.NetworkSupply a
+ Blockfrost.Lens: instance Blockfrost.Lens.HasBoundEpoch Blockfrost.Types.Cardano.Network.NetworkEraBound Blockfrost.Types.Shared.Epoch.Epoch
+ Blockfrost.Lens: instance Blockfrost.Lens.HasBoundSlot Blockfrost.Types.Cardano.Network.NetworkEraBound Blockfrost.Types.Shared.Slot.Slot
+ Blockfrost.Lens: instance Blockfrost.Lens.HasBoundTime Blockfrost.Types.Cardano.Network.NetworkEraBound Data.Time.Clock.Internal.NominalDiffTime.NominalDiffTime
+ Blockfrost.Lens: instance Blockfrost.Lens.HasNetworkEraEnd Blockfrost.Types.Cardano.Network.NetworkEraSummary Blockfrost.Types.Cardano.Network.NetworkEraBound
+ Blockfrost.Lens: instance Blockfrost.Lens.HasNetworkEraParameters Blockfrost.Types.Cardano.Network.NetworkEraSummary Blockfrost.Types.Cardano.Network.NetworkEraParameters
+ Blockfrost.Lens: instance Blockfrost.Lens.HasNetworkEraStart Blockfrost.Types.Cardano.Network.NetworkEraSummary Blockfrost.Types.Cardano.Network.NetworkEraBound
+ Blockfrost.Lens: instance Blockfrost.Lens.HasParametersEpochLength Blockfrost.Types.Cardano.Network.NetworkEraParameters Blockfrost.Types.Shared.Epoch.EpochLength
+ Blockfrost.Lens: instance Blockfrost.Lens.HasParametersSafeZone Blockfrost.Types.Cardano.Network.NetworkEraParameters GHC.Word.Word64
+ Blockfrost.Lens: instance Blockfrost.Lens.HasParametersSlotLength Blockfrost.Types.Cardano.Network.NetworkEraParameters Data.Time.Clock.Internal.NominalDiffTime.NominalDiffTime
+ Blockfrost.Lens: networkEraEnd :: HasNetworkEraEnd s a => Lens' s a
+ Blockfrost.Lens: networkEraParameters :: HasNetworkEraParameters s a => Lens' s a
+ Blockfrost.Lens: networkEraStart :: HasNetworkEraStart s a => Lens' s a
+ Blockfrost.Lens: parametersEpochLength :: HasParametersEpochLength s a => Lens' s a
+ Blockfrost.Lens: parametersSafeZone :: HasParametersSafeZone s a => Lens' s a
+ Blockfrost.Lens: parametersSlotLength :: HasParametersSlotLength s a => Lens' s a
+ Blockfrost.Lens: stakeActive :: HasStakeActive s a => Lens' s a
+ Blockfrost.Lens: stakeLive :: HasStakeLive s a => Lens' s a
+ Blockfrost.Lens: supplyCirculating :: HasSupplyCirculating s a => Lens' s a
+ Blockfrost.Lens: supplyLocked :: HasSupplyLocked s a => Lens' s a
+ Blockfrost.Lens: supplyMax :: HasSupplyMax s a => Lens' s a
+ Blockfrost.Lens: supplyReserves :: HasSupplyReserves s a => Lens' s a
+ Blockfrost.Lens: supplyTotal :: HasSupplyTotal s a => Lens' s a
+ Blockfrost.Lens: supplyTreasury :: HasSupplyTreasury s a => Lens' s a
+ Blockfrost.Types.Cardano.Network: NetworkEraBound :: Epoch -> Slot -> NominalDiffTime -> NetworkEraBound
+ Blockfrost.Types.Cardano.Network: NetworkEraParameters :: EpochLength -> NominalDiffTime -> Word64 -> NetworkEraParameters
+ Blockfrost.Types.Cardano.Network: NetworkEraSummary :: NetworkEraBound -> NetworkEraBound -> NetworkEraParameters -> NetworkEraSummary
+ Blockfrost.Types.Cardano.Network: [_boundEpoch] :: NetworkEraBound -> Epoch
+ Blockfrost.Types.Cardano.Network: [_boundSlot] :: NetworkEraBound -> Slot
+ Blockfrost.Types.Cardano.Network: [_boundTime] :: NetworkEraBound -> NominalDiffTime
+ Blockfrost.Types.Cardano.Network: [_networkEraEnd] :: NetworkEraSummary -> NetworkEraBound
+ Blockfrost.Types.Cardano.Network: [_networkEraParameters] :: NetworkEraSummary -> NetworkEraParameters
+ Blockfrost.Types.Cardano.Network: [_networkEraStart] :: NetworkEraSummary -> NetworkEraBound
+ Blockfrost.Types.Cardano.Network: [_parametersEpochLength] :: NetworkEraParameters -> EpochLength
+ Blockfrost.Types.Cardano.Network: [_parametersSafeZone] :: NetworkEraParameters -> Word64
+ Blockfrost.Types.Cardano.Network: [_parametersSlotLength] :: NetworkEraParameters -> NominalDiffTime
+ Blockfrost.Types.Cardano.Network: data NetworkEraBound
+ Blockfrost.Types.Cardano.Network: data NetworkEraParameters
+ Blockfrost.Types.Cardano.Network: data NetworkEraSummary
+ Blockfrost.Types.Cardano.Network: instance Data.Aeson.Types.FromJSON.FromJSON Blockfrost.Types.Cardano.Network.NetworkEraBound
+ Blockfrost.Types.Cardano.Network: instance Data.Aeson.Types.FromJSON.FromJSON Blockfrost.Types.Cardano.Network.NetworkEraParameters
+ Blockfrost.Types.Cardano.Network: instance Data.Aeson.Types.FromJSON.FromJSON Blockfrost.Types.Cardano.Network.NetworkEraSummary
+ Blockfrost.Types.Cardano.Network: instance Data.Aeson.Types.ToJSON.ToJSON Blockfrost.Types.Cardano.Network.NetworkEraBound
+ Blockfrost.Types.Cardano.Network: instance Data.Aeson.Types.ToJSON.ToJSON Blockfrost.Types.Cardano.Network.NetworkEraParameters
+ Blockfrost.Types.Cardano.Network: instance Data.Aeson.Types.ToJSON.ToJSON Blockfrost.Types.Cardano.Network.NetworkEraSummary
+ Blockfrost.Types.Cardano.Network: instance GHC.Classes.Eq Blockfrost.Types.Cardano.Network.NetworkEraBound
+ Blockfrost.Types.Cardano.Network: instance GHC.Classes.Eq Blockfrost.Types.Cardano.Network.NetworkEraParameters
+ Blockfrost.Types.Cardano.Network: instance GHC.Classes.Eq Blockfrost.Types.Cardano.Network.NetworkEraSummary
+ Blockfrost.Types.Cardano.Network: instance GHC.Generics.Generic Blockfrost.Types.Cardano.Network.NetworkEraBound
+ Blockfrost.Types.Cardano.Network: instance GHC.Generics.Generic Blockfrost.Types.Cardano.Network.NetworkEraParameters
+ Blockfrost.Types.Cardano.Network: instance GHC.Generics.Generic Blockfrost.Types.Cardano.Network.NetworkEraSummary
+ Blockfrost.Types.Cardano.Network: instance GHC.Show.Show Blockfrost.Types.Cardano.Network.NetworkEraBound
+ Blockfrost.Types.Cardano.Network: instance GHC.Show.Show Blockfrost.Types.Cardano.Network.NetworkEraParameters
+ Blockfrost.Types.Cardano.Network: instance GHC.Show.Show Blockfrost.Types.Cardano.Network.NetworkEraSummary
+ Blockfrost.Types.Cardano.Network: instance Servant.Docs.Internal.ToSample Blockfrost.Types.Cardano.Network.NetworkEraBound
+ Blockfrost.Types.Cardano.Network: instance Servant.Docs.Internal.ToSample Blockfrost.Types.Cardano.Network.NetworkEraParameters
+ Blockfrost.Types.Cardano.Network: instance Servant.Docs.Internal.ToSample Blockfrost.Types.Cardano.Network.NetworkEraSummary
+ Blockfrost.Types.Shared.Epoch: EpochLength :: Word64 -> EpochLength
+ Blockfrost.Types.Shared.Epoch: instance Data.Aeson.Types.FromJSON.FromJSON Blockfrost.Types.Shared.Epoch.EpochLength
+ Blockfrost.Types.Shared.Epoch: instance Data.Aeson.Types.ToJSON.ToJSON Blockfrost.Types.Shared.Epoch.EpochLength
+ Blockfrost.Types.Shared.Epoch: instance GHC.Classes.Eq Blockfrost.Types.Shared.Epoch.EpochLength
+ Blockfrost.Types.Shared.Epoch: instance GHC.Classes.Ord Blockfrost.Types.Shared.Epoch.EpochLength
+ Blockfrost.Types.Shared.Epoch: instance GHC.Enum.Enum Blockfrost.Types.Shared.Epoch.EpochLength
+ Blockfrost.Types.Shared.Epoch: instance GHC.Generics.Generic Blockfrost.Types.Shared.Epoch.EpochLength
+ Blockfrost.Types.Shared.Epoch: instance GHC.Num.Num Blockfrost.Types.Shared.Epoch.EpochLength
+ Blockfrost.Types.Shared.Epoch: instance GHC.Real.Integral Blockfrost.Types.Shared.Epoch.EpochLength
+ Blockfrost.Types.Shared.Epoch: instance GHC.Real.Real Blockfrost.Types.Shared.Epoch.EpochLength
+ Blockfrost.Types.Shared.Epoch: instance GHC.Show.Show Blockfrost.Types.Shared.Epoch.EpochLength
+ Blockfrost.Types.Shared.Epoch: instance Servant.Docs.Internal.ToCapture (Servant.API.Capture.Capture "epoch_length" Blockfrost.Types.Shared.Epoch.EpochLength)
+ Blockfrost.Types.Shared.Epoch: instance Servant.Docs.Internal.ToSample Blockfrost.Types.Shared.Epoch.EpochLength
+ Blockfrost.Types.Shared.Epoch: instance Web.Internal.HttpApiData.FromHttpApiData Blockfrost.Types.Shared.Epoch.EpochLength
+ Blockfrost.Types.Shared.Epoch: instance Web.Internal.HttpApiData.ToHttpApiData Blockfrost.Types.Shared.Epoch.EpochLength
+ Blockfrost.Types.Shared.Epoch: newtype EpochLength
+ Blockfrost.Types.Shared.Epoch: unEpochLength :: EpochLength -> Word64
+ Blockfrost.Types.Shared.ScriptHash: instance Servant.Docs.Internal.ToSample Blockfrost.Types.Shared.ScriptHash.ScriptHashList
Files
- CHANGELOG.md +6/−0
- blockfrost-api.cabal +1/−1
- src/Blockfrost/API/Cardano/Network.hs +6/−0
- src/Blockfrost/Lens.hs +5/−2
- src/Blockfrost/Types/Cardano/Epochs.hs +4/−1
- src/Blockfrost/Types/Cardano/Network.hs +74/−1
- src/Blockfrost/Types/Shared/Epoch.hs +16/−4
- src/Blockfrost/Types/Shared/ScriptHash.hs +11/−5
CHANGELOG.md view
@@ -1,3 +1,9 @@+# Version [0.7.1.0](https://github.com/blockfrost/blockfrost-haskell/compare/v0.7.0.0...v0.7.1.0) (2023-01-03)++* Additions+ * `NetworkEraSummary`, `NetworkEraBound`, `NetworkEraParameters` types and `_networkEras` endpoint [#33](https://github.com/blockfrost/blockfrost-haskell/pull/33/)+ * `ToSample ScriptHashList` instance+ # Version [0.7.0.0](https://github.com/blockfrost/blockfrost-haskell/compare/v0.6.0.0...v0.7.0.0) (2022-10-11) * Changes
blockfrost-api.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: blockfrost-api-version: 0.7.0.0+version: 0.7.1.0 synopsis: API definitions for blockfrost.io description: Core types and Servant API description homepage: https://github.com/blockfrost/blockfrost-haskell
src/Blockfrost/API/Cardano/Network.hs view
@@ -18,4 +18,10 @@ :- Summary "Network information" :> Description "Return detailed network information." :> Get '[JSON] Network+ , _networkEras+ :: 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] } deriving (Generic)
src/Blockfrost/Lens.hs view
@@ -47,8 +47,11 @@ makeFields ''TxMetaCBOR makeFields ''Network-makeFields ''NetworkSupply-makeFields ''NetworkStake+makeFieldsNoPrefix ''NetworkSupply+makeFieldsNoPrefix ''NetworkStake+makeFieldsNoPrefix ''NetworkEraSummary+makeFieldsNoPrefix ''NetworkEraBound+makeFieldsNoPrefix ''NetworkEraParameters makeFields ''PoolEpoch makeFields ''PoolInfo
src/Blockfrost/Types/Cardano/Epochs.hs view
@@ -157,7 +157,10 @@ (\(kLang, vParams) -> do l <- parseJSON $ toJSON- $ (\(x:xs) -> Data.Char.toLower x:xs)+ $ (\lang -> case lang of+ [] -> fail "Absurd empty language in CostModels"+ (x:xs) -> Data.Char.toLower x:xs+ ) $ Data.Aeson.Key.toString kLang ps <- parseParams vParams pure (l, Data.Map.fromList ps)
src/Blockfrost/Types/Cardano/Network.hs view
@@ -6,10 +6,15 @@ ( Network (..) , NetworkStake (..) , NetworkSupply (..)+ , NetworkEraSummary (..)+ , NetworkEraBound (..)+ , NetworkEraParameters (..) ) where +import Data.Time (NominalDiffTime)+import Data.Word (Word64) import Deriving.Aeson-import Servant.Docs (ToSample (..), singleSample)+import Servant.Docs (ToSample (..), samples, singleSample) import Blockfrost.Types.Shared @@ -71,3 +76,71 @@ instance ToSample Network where toSamples = pure $ singleSample $ Network netSupplySample netStakeSample++-- | Time bounds of an era.+data NetworkEraBound = NetworkEraBound+ { _boundEpoch :: Epoch, -- ^ The epoch number bounding a specific era.+ _boundSlot :: Slot, -- ^ The slot number bounding a specific era.+ _boundTime :: NominalDiffTime -- ^ The time, relative to network system start, bounding a specific era.+ }+ deriving stock (Show, Eq, Generic)+ deriving (FromJSON, ToJSON)+ via CustomJSON '[FieldLabelModifier '[StripPrefix "_bound", CamelToSnake]] NetworkEraBound++netEraBoundSample0 :: NetworkEraBound+netEraBoundSample0 =+ NetworkEraBound+ { _boundEpoch = 4+ , _boundSlot = 86_400+ , _boundTime = 1_728_000+ }++netEraBoundSample1 :: NetworkEraBound+netEraBoundSample1 =+ NetworkEraBound+ { _boundEpoch = 5+ , _boundSlot = 518_400+ , _boundTime = 2_160_00+ }++instance ToSample NetworkEraBound where+ toSamples = pure $ samples [netEraBoundSample0, netEraBoundSample1]++-- | Parameters for a network era which can vary between hardforks.+data NetworkEraParameters = NetworkEraParameters+ { _parametersEpochLength :: EpochLength, -- ^ Number of slots in an epoch.+ _parametersSlotLength :: NominalDiffTime, -- ^ How long a slot lasts.+ _parametersSafeZone :: Word64 -- ^ Number of slots from the tip of the ledger in which a hardfork will not happen.+ }+ deriving stock (Show, Eq, Generic)+ deriving (FromJSON, ToJSON)+ via CustomJSON '[FieldLabelModifier '[StripPrefix "_parameters", CamelToSnake]] NetworkEraParameters++netEraParamSample :: NetworkEraParameters+netEraParamSample =+ NetworkEraParameters+ { _parametersEpochLength = 432_000+ , _parametersSlotLength = 1+ , _parametersSafeZone = 129_600+ }++instance ToSample NetworkEraParameters where+ toSamples = pure $ singleSample netEraParamSample++-- | Summary of information about network eras.+data NetworkEraSummary = NetworkEraSummary+ { _networkEraStart :: NetworkEraBound, -- ^ Start of a specific era.+ _networkEraEnd :: NetworkEraBound, -- ^ End of a specific era.+ _networkEraParameters :: NetworkEraParameters -- ^ Active parameters for a specific era.+ }+ deriving stock (Show, Eq, Generic)+ deriving (FromJSON, ToJSON)+ via CustomJSON '[FieldLabelModifier '[StripPrefix "_networkEra", CamelToSnake]] NetworkEraSummary++instance ToSample NetworkEraSummary where+ toSamples = pure . singleSample $+ NetworkEraSummary+ { _networkEraStart = netEraBoundSample0+ , _networkEraEnd = netEraBoundSample1+ , _networkEraParameters = netEraParamSample+ }
@@ -1,9 +1,8 @@ -- | Epoch--module Blockfrost.Types.Shared.Epoch- where+module Blockfrost.Types.Shared.Epoch where import Data.Aeson (FromJSON, ToJSON)+import Data.Word (Word64) import GHC.Generics import Servant.API (Capture, FromHttpApiData (..), ToHttpApiData (..)) import Servant.Docs (DocCapture (..), ToCapture (..), ToSample (..), samples)@@ -19,4 +18,17 @@ toCapture _ = DocCapture "epoch_number" "Epoch for specific epoch slot." instance ToSample Epoch where- toSamples = pure $ samples [425, 500, 1200]+ toSamples = pure $ samples [425, 500, 1200]++newtype EpochLength = EpochLength Word64+ deriving stock (Eq, Ord, Show, Generic)+ deriving newtype (Num, Enum, Real, Integral, FromHttpApiData, ToHttpApiData, FromJSON, ToJSON)++unEpochLength :: EpochLength -> Word64+unEpochLength (EpochLength u) = u++instance ToCapture (Capture "epoch_length" EpochLength) where+ toCapture _ = DocCapture "epoch_length" "Epoch size in a specific Cardano era."++instance ToSample EpochLength where+ toSamples = pure $ samples [21600, 86400, 432000]
@@ -12,7 +12,7 @@ import qualified Data.Vector import GHC.Generics import Servant.API (Capture, FromHttpApiData (..), ToHttpApiData (..))-import Servant.Docs (DocCapture (..), ToCapture (..), ToSample (..), samples)+import Servant.Docs (DocCapture (..), ToCapture (..), ToSample (..), samples, singleSample) -- | Script Hash newtype newtype ScriptHash = ScriptHash { unScriptHash :: Text }@@ -45,11 +45,17 @@ parseJSON' _ = fail "Unexpected type for ScriptHash" parseJSON _ = fail "Expected array for [ScriptHash]" +instance ToSample ScriptHashList where+ toSamples = pure $ singleSample $ ScriptHashList $ map ScriptHash+ [ "67f33146617a5e61936081db3b2117cbf59bd2123748f58ac9678656"+ , "e1457a0c47dfb7a2f6b8fbb059bdceab163c05d34f195b87b9f2b30e"+ ]+ instance ToSample ScriptHash where- toSamples _ = samples $ map ScriptHash- [ "67f33146617a5e61936081db3b2117cbf59bd2123748f58ac9678656"- , "e1457a0c47dfb7a2f6b8fbb059bdceab163c05d34f195b87b9f2b30e"- ]+ toSamples _ = samples $ map ScriptHash+ [ "67f33146617a5e61936081db3b2117cbf59bd2123748f58ac9678656"+ , "e1457a0c47dfb7a2f6b8fbb059bdceab163c05d34f195b87b9f2b30e"+ ] instance ToCapture (Capture "script_hash" ScriptHash) where toCapture _ = DocCapture "script_hash" "Hash of the script."