{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}
{-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
module Bcc.Api.Orphans () where
import Prelude
import Data.Aeson (FromJSON (..), ToJSON (..), object, (.!=), (.:), (.:?), (.=))
import qualified Data.Aeson as Aeson
import Data.Aeson.Types (FromJSONKey (..), ToJSONKey (..), toJSONKeyText)
import qualified Data.ByteString.Base16 as B16
import qualified Data.Map.Strict as Map
import Data.Text (Text)
import qualified Data.Text as Text
import qualified Data.Text.Encoding as Text
import Control.Applicative
import Control.Iterate.SetAlgebra (BiMap (..), Bimap)
import Bcc.Api.Json
import Bcc.Ledger.BaseTypes (StrictMaybe (..), strictMaybeToMaybe)
import qualified Bcc.Ledger.BaseTypes as Ledger
import Bcc.Ledger.Crypto (StandardCrypto)
import Bcc.Slotting.Slot (SlotNo (..))
import Bcc.Slotting.Time (SystemStart (..))
import qualified Bcc.Crypto.Hash.Class as Crypto
import qualified Bcc.Ledger.Aurum as Aurum
import qualified Bcc.Ledger.Aurum.Genesis as Aurum
import qualified Bcc.Ledger.Aurum.Language as Aurum
import qualified Bcc.Ledger.Aurum.PParams as Aurum
import qualified Bcc.Ledger.Aurum.Scripts as Aurum
import qualified Bcc.Ledger.Aurum.TxBody as Aurum
import qualified Bcc.Ledger.Coin as Sophie
import qualified Bcc.Ledger.Core as Core
import qualified Bcc.Ledger.Core as Ledger
import qualified Bcc.Ledger.Crypto as Crypto
import qualified Bcc.Ledger.Era as Ledger
import qualified Bcc.Ledger.Jen.Value as Jen
import qualified Bcc.Ledger.SafeHash as SafeHash
import qualified Bcc.Ledger.Sophie.Constraints as Sophie
import qualified Bcc.Protocol.TOptimum as Optimum
import qualified Shardagnostic.Consensus.Sophie.Eras as Consensus
import qualified Sophie.Spec.Ledger.API as Sophie
import qualified Sophie.Spec.Ledger.EpochBoundary as SophieEpoch
import qualified Sophie.Spec.Ledger.LedgerState as SophieLedger
import Sophie.Spec.Ledger.PParams (PParamsUpdate)
import qualified Sophie.Spec.Ledger.RewardUpdate as Sophie
import qualified Sophie.Spec.Ledger.Rewards as Sophie
import Zerepoch.V1.Ledger.Api (defaultCostModelParams)
instance ToJSON (Jen.Value era) where
toJSON :: Value era -> Value
toJSON (Jen.Value Integer
l Map (PolicyID era) (Map AssetName Integer)
ps) =
[Pair] -> Value
object
[ Text
"entropic" Text -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Integer -> Value
forall a. ToJSON a => a -> Value
toJSON Integer
l
, Text
"policies" Text -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Map (PolicyID era) (Map AssetName Integer) -> Value
forall a. ToJSON a => a -> Value
toJSON Map (PolicyID era) (Map AssetName Integer)
ps
]
instance ToJSONKey Jen.AssetName where
toJSONKey :: ToJSONKeyFunction AssetName
toJSONKey = (AssetName -> Text) -> ToJSONKeyFunction AssetName
forall a. (a -> Text) -> ToJSONKeyFunction a
toJSONKeyText AssetName -> Text
render
where
render :: AssetName -> Text
render = ByteString -> Text
Text.decodeLatin1 (ByteString -> Text)
-> (AssetName -> ByteString) -> AssetName -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
B16.encode (ByteString -> ByteString)
-> (AssetName -> ByteString) -> AssetName -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AssetName -> ByteString
Jen.assetName
instance ToJSON (Jen.PolicyID era) where
toJSON :: PolicyID era -> Value
toJSON (Jen.PolicyID (Sophie.ScriptHash Hash (ADDRHASH era) EraIndependentScript
h)) = Text -> Value
Aeson.String (Hash (ADDRHASH era) EraIndependentScript -> Text
forall crypto a. Hash crypto a -> Text
hashToText Hash (ADDRHASH era) EraIndependentScript
h)
instance ToJSONKey (Jen.PolicyID era) where
toJSONKey :: ToJSONKeyFunction (PolicyID era)
toJSONKey = (PolicyID era -> Text) -> ToJSONKeyFunction (PolicyID era)
forall a. (a -> Text) -> ToJSONKeyFunction a
toJSONKeyText PolicyID era -> Text
forall crypto. PolicyID crypto -> Text
render
where
render :: PolicyID crypto -> Text
render (Jen.PolicyID (Sophie.ScriptHash Hash (ADDRHASH crypto) EraIndependentScript
h)) = Hash (ADDRHASH crypto) EraIndependentScript -> Text
forall crypto a. Hash crypto a -> Text
hashToText Hash (ADDRHASH crypto) EraIndependentScript
h
instance ToJSON Jen.AssetName where
toJSON :: AssetName -> Value
toJSON = Text -> Value
Aeson.String (Text -> Value) -> (AssetName -> Text) -> AssetName -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Text
Text.decodeLatin1 (ByteString -> Text)
-> (AssetName -> ByteString) -> AssetName -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
B16.encode (ByteString -> ByteString)
-> (AssetName -> ByteString) -> AssetName -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AssetName -> ByteString
Jen.assetName
instance ToJSON Sophie.AccountState where
toJSON :: AccountState -> Value
toJSON (Sophie.AccountState Coin
tr Coin
rs) = [Pair] -> Value
object [ Text
"treasury" Text -> Coin -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Coin
tr
, Text
"reserves" Text -> Coin -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Coin
rs
]
instance ( Consensus.SophieBasedEra era
, ToJSON (Core.TxOut era)
, ToJSON (Core.PParams era)
, ToJSON (Core.PParamsDelta era)
) => ToJSON (Sophie.EpochState era) where
toJSON :: EpochState era -> Value
toJSON EpochState era
eState = [Pair] -> Value
object [ Text
"esAccountState" Text -> AccountState -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= EpochState era -> AccountState
forall era. EpochState era -> AccountState
Sophie.esAccountState EpochState era
eState
, Text
"esSnapshots" Text -> SnapShots (Crypto era) -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= EpochState era -> SnapShots (Crypto era)
forall era. EpochState era -> SnapShots (Crypto era)
Sophie.esSnapshots EpochState era
eState
, Text
"esLState" Text -> LedgerState era -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= EpochState era -> LedgerState era
forall era. EpochState era -> LedgerState era
Sophie.esLState EpochState era
eState
, Text
"esPrevPp" Text -> PParams era -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= EpochState era -> PParams era
forall era. EpochState era -> PParams era
Sophie.esPrevPp EpochState era
eState
, Text
"esPp" Text -> PParams era -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= EpochState era -> PParams era
forall era. EpochState era -> PParams era
Sophie.esPp EpochState era
eState
, Text
"esNonMyopic" Text -> NonMyopic (Crypto era) -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= EpochState era -> NonMyopic (Crypto era)
forall era. EpochState era -> NonMyopic (Crypto era)
Sophie.esNonMyopic EpochState era
eState
]
instance ( Consensus.SophieBasedEra era
, ToJSON (Core.TxOut era)
, ToJSON (Core.PParamsDelta era)
) => ToJSON (Sophie.LedgerState era) where
toJSON :: LedgerState era -> Value
toJSON LedgerState era
lState = [Pair] -> Value
object [ Text
"utxoState" Text -> UTxOState era -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= LedgerState era -> UTxOState era
forall era. LedgerState era -> UTxOState era
Sophie._utxoState LedgerState era
lState
, Text
"delegationState" Text -> DPState (Crypto era) -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= LedgerState era -> DPState (Crypto era)
forall era. LedgerState era -> DPState (Crypto era)
Sophie._delegationState LedgerState era
lState
]
instance ( Consensus.SophieBasedEra era
, ToJSON (Core.TxOut era)
, ToJSON (Core.PParamsDelta era)
) => ToJSON (Sophie.UTxOState era) where
toJSON :: UTxOState era -> Value
toJSON UTxOState era
utxoState = [Pair] -> Value
object [ Text
"utxo" Text -> UTxO era -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= UTxOState era -> UTxO era
forall era. UTxOState era -> UTxO era
Sophie._utxo UTxOState era
utxoState
, Text
"deposited" Text -> Coin -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= UTxOState era -> Coin
forall era. UTxOState era -> Coin
Sophie._deposited UTxOState era
utxoState
, Text
"fees" Text -> Coin -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= UTxOState era -> Coin
forall era. UTxOState era -> Coin
Sophie._fees UTxOState era
utxoState
, Text
"ppups" Text -> PPUPState era -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= UTxOState era -> State (EraRule "PPUP" era)
forall era. UTxOState era -> State (EraRule "PPUP" era)
Sophie._ppups UTxOState era
utxoState
]
instance ( ToJSON (Core.PParamsDelta era)
, Sophie.UsesPParams era
) => ToJSON (Sophie.PPUPState era) where
toJSON :: PPUPState era -> Value
toJSON PPUPState era
ppUpState = [Pair] -> Value
object [ Text
"proposals" Text -> ProposedPPUpdates era -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PPUPState era -> ProposedPPUpdates era
forall era. PPUPState era -> ProposedPPUpdates era
Sophie.proposals PPUPState era
ppUpState
, Text
"futureProposals" Text -> ProposedPPUpdates era -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PPUPState era -> ProposedPPUpdates era
forall era. PPUPState era -> ProposedPPUpdates era
Sophie.futureProposals PPUPState era
ppUpState
]
instance ( ToJSON (Core.PParamsDelta era)
, Sophie.UsesPParams era
) => ToJSON (Sophie.ProposedPPUpdates era) where
toJSON :: ProposedPPUpdates era -> Value
toJSON (Sophie.ProposedPPUpdates Map (KeyHash 'Genesis (Crypto era)) (PParamsDelta era)
ppUpdates) = [(KeyHash 'Genesis (Crypto era), PParamsDelta era)] -> Value
forall a. ToJSON a => a -> Value
toJSON ([(KeyHash 'Genesis (Crypto era), PParamsDelta era)] -> Value)
-> [(KeyHash 'Genesis (Crypto era), PParamsDelta era)] -> Value
forall a b. (a -> b) -> a -> b
$ Map (KeyHash 'Genesis (Crypto era)) (PParamsDelta era)
-> [(KeyHash 'Genesis (Crypto era), PParamsDelta era)]
forall k a. Map k a -> [(k, a)]
Map.toList Map (KeyHash 'Genesis (Crypto era)) (PParamsDelta era)
ppUpdates
instance ToJSON (PParamsUpdate era) where
toJSON :: PParamsUpdate era -> Value
toJSON PParamsUpdate era
pp =
[Pair] -> Value
Aeson.object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$
[ Text
"minFeeA" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Natural
x | Natural
x <- StrictMaybe Natural -> [Natural]
forall a. StrictMaybe a -> [a]
mbfield (PParamsUpdate era -> HKD StrictMaybe Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Sophie._minfeeA PParamsUpdate era
pp) ]
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ [ Text
"minFeeB" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Natural
x | Natural
x <- StrictMaybe Natural -> [Natural]
forall a. StrictMaybe a -> [a]
mbfield (PParamsUpdate era -> HKD StrictMaybe Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Sophie._minfeeB PParamsUpdate era
pp) ]
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ [ Text
"maxBlockBodySize" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Natural
x | Natural
x <- StrictMaybe Natural -> [Natural]
forall a. StrictMaybe a -> [a]
mbfield (PParamsUpdate era -> HKD StrictMaybe Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Sophie._maxBBSize PParamsUpdate era
pp) ]
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ [ Text
"maxTxSize" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Natural
x | Natural
x <- StrictMaybe Natural -> [Natural]
forall a. StrictMaybe a -> [a]
mbfield (PParamsUpdate era -> HKD StrictMaybe Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Sophie._maxTxSize PParamsUpdate era
pp) ]
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ [ Text
"maxBlockHeaderSize" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Natural
x | Natural
x <- StrictMaybe Natural -> [Natural]
forall a. StrictMaybe a -> [a]
mbfield (PParamsUpdate era -> HKD StrictMaybe Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Sophie._maxBHSize PParamsUpdate era
pp) ]
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ [ Text
"keyDeposit" Text -> Coin -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Coin
x | Coin
x <- StrictMaybe Coin -> [Coin]
forall a. StrictMaybe a -> [a]
mbfield (PParamsUpdate era -> HKD StrictMaybe Coin
forall (f :: * -> *) era. PParams' f era -> HKD f Coin
Sophie._keyDeposit PParamsUpdate era
pp) ]
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ [ Text
"poolDeposit" Text -> Coin -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Coin
x | Coin
x <- StrictMaybe Coin -> [Coin]
forall a. StrictMaybe a -> [a]
mbfield (PParamsUpdate era -> HKD StrictMaybe Coin
forall (f :: * -> *) era. PParams' f era -> HKD f Coin
Sophie._poolDeposit PParamsUpdate era
pp) ]
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ [ Text
"eMax" Text -> EpochNo -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= EpochNo
x | EpochNo
x <- StrictMaybe EpochNo -> [EpochNo]
forall a. StrictMaybe a -> [a]
mbfield (PParamsUpdate era -> HKD StrictMaybe EpochNo
forall (f :: * -> *) era. PParams' f era -> HKD f EpochNo
Sophie._eMax PParamsUpdate era
pp) ]
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ [ Text
"nOpt" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Natural
x | Natural
x <- StrictMaybe Natural -> [Natural]
forall a. StrictMaybe a -> [a]
mbfield (PParamsUpdate era -> HKD StrictMaybe Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Sophie._nOpt PParamsUpdate era
pp) ]
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ [ Text
"a0" Text -> NonNegativeInterval -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= NonNegativeInterval
x | NonNegativeInterval
x <- StrictMaybe NonNegativeInterval -> [NonNegativeInterval]
forall a. StrictMaybe a -> [a]
mbfield (PParamsUpdate era -> HKD StrictMaybe NonNegativeInterval
forall (f :: * -> *) era.
PParams' f era -> HKD f NonNegativeInterval
Sophie._a0 PParamsUpdate era
pp) ]
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ [ Text
"rho" Text -> UnitInterval -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= UnitInterval
x | UnitInterval
x <- StrictMaybe UnitInterval -> [UnitInterval]
forall a. StrictMaybe a -> [a]
mbfield (PParamsUpdate era -> HKD StrictMaybe UnitInterval
forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
Sophie._rho PParamsUpdate era
pp) ]
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ [ Text
"tau" Text -> UnitInterval -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= UnitInterval
x | UnitInterval
x <- StrictMaybe UnitInterval -> [UnitInterval]
forall a. StrictMaybe a -> [a]
mbfield (PParamsUpdate era -> HKD StrictMaybe UnitInterval
forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
Sophie._tau PParamsUpdate era
pp) ]
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ [ Text
"decentralisationParam" Text -> UnitInterval -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= UnitInterval
x | UnitInterval
x <- StrictMaybe UnitInterval -> [UnitInterval]
forall a. StrictMaybe a -> [a]
mbfield (PParamsUpdate era -> HKD StrictMaybe UnitInterval
forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
Sophie._d PParamsUpdate era
pp) ]
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ [ Text
"extraEntropy" Text -> Nonce -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Nonce
x | Nonce
x <- StrictMaybe Nonce -> [Nonce]
forall a. StrictMaybe a -> [a]
mbfield (PParamsUpdate era -> HKD StrictMaybe Nonce
forall (f :: * -> *) era. PParams' f era -> HKD f Nonce
Sophie._extraEntropy PParamsUpdate era
pp) ]
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ [ Text
"protocolVersion" Text -> ProtVer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= ProtVer
x | ProtVer
x <- StrictMaybe ProtVer -> [ProtVer]
forall a. StrictMaybe a -> [a]
mbfield (PParamsUpdate era -> HKD StrictMaybe ProtVer
forall (f :: * -> *) era. PParams' f era -> HKD f ProtVer
Sophie._protocolVersion PParamsUpdate era
pp) ]
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ [ Text
"minUTxOValue" Text -> Coin -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Coin
x | Coin
x <- StrictMaybe Coin -> [Coin]
forall a. StrictMaybe a -> [a]
mbfield (PParamsUpdate era -> HKD StrictMaybe Coin
forall (f :: * -> *) era. PParams' f era -> HKD f Coin
Sophie._minUTxOValue PParamsUpdate era
pp) ]
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ [ Text
"minPoolCost" Text -> Coin -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Coin
x | Coin
x <- StrictMaybe Coin -> [Coin]
forall a. StrictMaybe a -> [a]
mbfield (PParamsUpdate era -> HKD StrictMaybe Coin
forall (f :: * -> *) era. PParams' f era -> HKD f Coin
Sophie._minPoolCost PParamsUpdate era
pp) ]
where
mbfield :: StrictMaybe a -> [a]
mbfield StrictMaybe a
SNothing = []
mbfield (SJust a
x) = [a
x]
instance Crypto.Crypto crypto => ToJSON (Sophie.DPState crypto) where
toJSON :: DPState crypto -> Value
toJSON DPState crypto
dpState = [Pair] -> Value
object [ Text
"dstate" Text -> DState crypto -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= DPState crypto -> DState crypto
forall crypto. DPState crypto -> DState crypto
Sophie._dstate DPState crypto
dpState
, Text
"pstate" Text -> PState crypto -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= DPState crypto -> PState crypto
forall crypto. DPState crypto -> PState crypto
Sophie._pstate DPState crypto
dpState
]
instance Crypto.Crypto crypto => ToJSON (Sophie.DState crypto) where
toJSON :: DState crypto -> Value
toJSON DState crypto
dState = [Pair] -> Value
object [ Text
"rewards" Text -> RewardAccounts crypto -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= DState crypto -> RewardAccounts crypto
forall crypto. DState crypto -> RewardAccounts crypto
Sophie._rewards DState crypto
dState
, Text
"delegations" Text
-> Map (Credential 'Staking crypto) (KeyHash 'StakePool crypto)
-> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= DState crypto
-> Map (Credential 'Staking crypto) (KeyHash 'StakePool crypto)
forall crypto.
DState crypto
-> Map (Credential 'Staking crypto) (KeyHash 'StakePool crypto)
SophieLedger._delegations DState crypto
dState
, Text
"ptrs" Text -> Bimap Ptr (Credential 'Staking crypto) -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= DState crypto -> Bimap Ptr (Credential 'Staking crypto)
forall crypto.
DState crypto -> Bimap Ptr (Credential 'Staking crypto)
Sophie._ptrs DState crypto
dState
, Text
"fGenDelegs" Text -> [(FutureGenDeleg crypto, GenDelegPair crypto)] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Map (FutureGenDeleg crypto) (GenDelegPair crypto)
-> [(FutureGenDeleg crypto, GenDelegPair crypto)]
forall k a. Map k a -> [(k, a)]
Map.toList (DState crypto -> Map (FutureGenDeleg crypto) (GenDelegPair crypto)
forall crypto.
DState crypto -> Map (FutureGenDeleg crypto) (GenDelegPair crypto)
Sophie._fGenDelegs DState crypto
dState)
, Text
"genDelegs" Text -> GenDelegs crypto -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= DState crypto -> GenDelegs crypto
forall crypto. DState crypto -> GenDelegs crypto
Sophie._genDelegs DState crypto
dState
, Text
"irwd" Text -> InstantaneousRewards crypto -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= DState crypto -> InstantaneousRewards crypto
forall crypto. DState crypto -> InstantaneousRewards crypto
Sophie._irwd DState crypto
dState
]
instance Crypto.Crypto crypto => ToJSON (SophieLedger.FutureGenDeleg crypto) where
toJSON :: FutureGenDeleg crypto -> Value
toJSON FutureGenDeleg crypto
fGenDeleg =
[Pair] -> Value
object [ Text
"fGenDelegSlot" Text -> SlotNo -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= FutureGenDeleg crypto -> SlotNo
forall crypto. FutureGenDeleg crypto -> SlotNo
SophieLedger.fGenDelegSlot FutureGenDeleg crypto
fGenDeleg
, Text
"fGenDelegGenKeyHash" Text -> KeyHash 'Genesis crypto -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= FutureGenDeleg crypto -> KeyHash 'Genesis crypto
forall crypto. FutureGenDeleg crypto -> KeyHash 'Genesis crypto
SophieLedger.fGenDelegGenKeyHash FutureGenDeleg crypto
fGenDeleg
]
instance Crypto.Crypto crypto => ToJSON (Sophie.GenDelegs crypto) where
toJSON :: GenDelegs crypto -> Value
toJSON (Sophie.GenDelegs Map (KeyHash 'Genesis crypto) (GenDelegPair crypto)
delegs) = Map (KeyHash 'Genesis crypto) (GenDelegPair crypto) -> Value
forall a. ToJSON a => a -> Value
toJSON Map (KeyHash 'Genesis crypto) (GenDelegPair crypto)
delegs
instance Crypto.Crypto crypto => ToJSON (Sophie.InstantaneousRewards crypto) where
toJSON :: InstantaneousRewards crypto -> Value
toJSON InstantaneousRewards crypto
iRwds = [Pair] -> Value
object [ Text
"iRReserves" Text -> Map (Credential 'Staking crypto) Coin -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= InstantaneousRewards crypto
-> Map (Credential 'Staking crypto) Coin
forall crypto.
InstantaneousRewards crypto
-> Map (Credential 'Staking crypto) Coin
Sophie.iRReserves InstantaneousRewards crypto
iRwds
, Text
"iRTreasury" Text -> Map (Credential 'Staking crypto) Coin -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= InstantaneousRewards crypto
-> Map (Credential 'Staking crypto) Coin
forall crypto.
InstantaneousRewards crypto
-> Map (Credential 'Staking crypto) Coin
Sophie.iRTreasury InstantaneousRewards crypto
iRwds
]
instance
Crypto.Crypto crypto =>
ToJSON (Bimap Sophie.Ptr (Sophie.Credential Sophie.Staking crypto))
where
toJSON :: Bimap Ptr (Credential 'Staking crypto) -> Value
toJSON (MkBiMap Map Ptr (Credential 'Staking crypto)
ptsStakeM Map (Credential 'Staking crypto) (Set Ptr)
stakePtrSetM) =
[Pair] -> Value
object [ Text
"stakedCreds" Text -> [(Ptr, Credential 'Staking crypto)] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Map Ptr (Credential 'Staking crypto)
-> [(Ptr, Credential 'Staking crypto)]
forall k a. Map k a -> [(k, a)]
Map.toList Map Ptr (Credential 'Staking crypto)
ptsStakeM
, Text
"credPtrR" Text -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Map (Credential 'Staking crypto) (Set Ptr) -> Value
forall a. ToJSON a => a -> Value
toJSON Map (Credential 'Staking crypto) (Set Ptr)
stakePtrSetM
]
instance ToJSON Sophie.Ptr where
toJSON :: Ptr -> Value
toJSON (Sophie.Ptr SlotNo
slotNo Ix
txIndex Ix
certIndex) =
[Pair] -> Value
object [ Text
"slot" Text -> Ix -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= SlotNo -> Ix
unSlotNo SlotNo
slotNo
, Text
"txIndex" Text -> Ix -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Ix
txIndex
, Text
"certIndex" Text -> Ix -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Ix
certIndex
]
instance Crypto.Crypto crypto => ToJSON (Sophie.PState crypto) where
toJSON :: PState crypto -> Value
toJSON PState crypto
pState = [Pair] -> Value
object [ Text
"pParams pState" Text -> Map (KeyHash 'StakePool crypto) (PoolParams crypto) -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PState crypto
-> Map (KeyHash 'StakePool crypto) (PoolParams crypto)
forall crypto.
PState crypto
-> Map (KeyHash 'StakePool crypto) (PoolParams crypto)
Sophie._pParams PState crypto
pState
, Text
"fPParams pState" Text -> Map (KeyHash 'StakePool crypto) (PoolParams crypto) -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PState crypto
-> Map (KeyHash 'StakePool crypto) (PoolParams crypto)
forall crypto.
PState crypto
-> Map (KeyHash 'StakePool crypto) (PoolParams crypto)
Sophie._fPParams PState crypto
pState
, Text
"retiring pState" Text -> Map (KeyHash 'StakePool crypto) EpochNo -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PState crypto -> Map (KeyHash 'StakePool crypto) EpochNo
forall crypto.
PState crypto -> Map (KeyHash 'StakePool crypto) EpochNo
Sophie._retiring PState crypto
pState
]
instance ( Consensus.SophieBasedEra era
, ToJSON (Core.TxOut era)
) => ToJSON (Sophie.UTxO era) where
toJSON :: UTxO era -> Value
toJSON (Sophie.UTxO Map (TxIn (Crypto era)) (TxOut era)
utxo) = Map (TxIn (Crypto era)) (TxOut era) -> Value
forall a. ToJSON a => a -> Value
toJSON Map (TxIn (Crypto era)) (TxOut era)
utxo
instance ( Consensus.SophieBasedEra era
, ToJSON (Core.Value era)
) => ToJSON (Sophie.TxOut era) where
toJSON :: TxOut era -> Value
toJSON (Sophie.TxOut Addr (Crypto era)
addr Value era
amount) =
[Pair] -> Value
object
[ Text
"address" Text -> Addr (Crypto era) -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Addr (Crypto era)
addr
, Text
"amount" Text -> Value era -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Value era
amount
]
instance Crypto.Crypto crypto => ToJSON (Sophie.TxIn crypto) where
toJSON :: TxIn crypto -> Value
toJSON = Text -> Value
forall a. ToJSON a => a -> Value
toJSON (Text -> Value) -> (TxIn crypto -> Text) -> TxIn crypto -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxIn crypto -> Text
forall crypto. Crypto crypto => TxIn crypto -> Text
txInToText
instance Crypto.Crypto crypto => ToJSONKey (Sophie.TxIn crypto) where
toJSONKey :: ToJSONKeyFunction (TxIn crypto)
toJSONKey = (TxIn crypto -> Text) -> ToJSONKeyFunction (TxIn crypto)
forall a. (a -> Text) -> ToJSONKeyFunction a
toJSONKeyText TxIn crypto -> Text
forall crypto. Crypto crypto => TxIn crypto -> Text
txInToText
txInToText :: Crypto.Crypto crypto => Sophie.TxIn crypto -> Text
txInToText :: TxIn crypto -> Text
txInToText (Sophie.TxIn (Sophie.TxId SafeHash crypto EraIndependentTxBody
txidHash) Natural
ix) =
Hash (HASH crypto) EraIndependentTxBody -> Text
forall crypto a. Hash crypto a -> Text
hashToText (SafeHash crypto EraIndependentTxBody
-> Hash (HASH crypto) EraIndependentTxBody
forall crypto i. SafeHash crypto i -> Hash (HASH crypto) i
SafeHash.extractHash SafeHash crypto EraIndependentTxBody
txidHash)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
Text.pack String
"#"
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
Text.pack (Natural -> String
forall a. Show a => a -> String
show Natural
ix)
hashToText :: Crypto.Hash crypto a -> Text
hashToText :: Hash crypto a -> Text
hashToText = ByteString -> Text
Text.decodeLatin1 (ByteString -> Text)
-> (Hash crypto a -> ByteString) -> Hash crypto a -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash crypto a -> ByteString
forall h a. Hash h a -> ByteString
Crypto.hashToBytesAsHex
instance Crypto.Crypto crypto => ToJSON (Sophie.NonMyopic crypto) where
toJSON :: NonMyopic crypto -> Value
toJSON NonMyopic crypto
nonMy = [Pair] -> Value
object [ Text
"likelihoodsNM" Text -> Map (KeyHash 'StakePool crypto) Likelihood -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= NonMyopic crypto -> Map (KeyHash 'StakePool crypto) Likelihood
forall crypto.
NonMyopic crypto -> Map (KeyHash 'StakePool crypto) Likelihood
Sophie.likelihoodsNM NonMyopic crypto
nonMy
, Text
"rewardPotNM" Text -> Coin -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= NonMyopic crypto -> Coin
forall crypto. NonMyopic crypto -> Coin
Sophie.rewardPotNM NonMyopic crypto
nonMy
]
instance ToJSON Sophie.Likelihood where
toJSON :: Likelihood -> Value
toJSON (Sophie.Likelihood StrictSeq LogWeight
llhd) =
StrictSeq Double -> Value
forall a. ToJSON a => a -> Value
toJSON (StrictSeq Double -> Value) -> StrictSeq Double -> Value
forall a b. (a -> b) -> a -> b
$ (LogWeight -> Double) -> StrictSeq LogWeight -> StrictSeq Double
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(Sophie.LogWeight Float
f) -> Double -> Double
forall a. Floating a => a -> a
exp (Double -> Double) -> Double -> Double
forall a b. (a -> b) -> a -> b
$ Float -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac Float
f :: Double) StrictSeq LogWeight
llhd
instance Crypto.Crypto crypto => ToJSON (Sophie.SnapShots crypto) where
toJSON :: SnapShots crypto -> Value
toJSON SnapShots crypto
ss = [Pair] -> Value
object [ Text
"pstakeMark" Text -> SnapShot crypto -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= SnapShots crypto -> SnapShot crypto
forall crypto. SnapShots crypto -> SnapShot crypto
Sophie._pstakeMark SnapShots crypto
ss
, Text
"pstakeSet" Text -> SnapShot crypto -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= SnapShots crypto -> SnapShot crypto
forall crypto. SnapShots crypto -> SnapShot crypto
Sophie._pstakeSet SnapShots crypto
ss
, Text
"pstakeGo" Text -> SnapShot crypto -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= SnapShots crypto -> SnapShot crypto
forall crypto. SnapShots crypto -> SnapShot crypto
Sophie._pstakeGo SnapShots crypto
ss
, Text
"feeSS" Text -> Coin -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= SnapShots crypto -> Coin
forall crypto. SnapShots crypto -> Coin
Sophie._feeSS SnapShots crypto
ss
]
instance Crypto.Crypto crypto => ToJSON (Sophie.SnapShot crypto) where
toJSON :: SnapShot crypto -> Value
toJSON SnapShot crypto
ss = [Pair] -> Value
object [ Text
"stake" Text -> Stake crypto -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= SnapShot crypto -> Stake crypto
forall crypto. SnapShot crypto -> Stake crypto
Sophie._stake SnapShot crypto
ss
, Text
"delegations" Text
-> Map (Credential 'Staking crypto) (KeyHash 'StakePool crypto)
-> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= SnapShot crypto
-> Map (Credential 'Staking crypto) (KeyHash 'StakePool crypto)
forall crypto.
SnapShot crypto
-> Map (Credential 'Staking crypto) (KeyHash 'StakePool crypto)
SophieEpoch._delegations SnapShot crypto
ss
, Text
"poolParams" Text -> Map (KeyHash 'StakePool crypto) (PoolParams crypto) -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= SnapShot crypto
-> Map (KeyHash 'StakePool crypto) (PoolParams crypto)
forall crypto.
SnapShot crypto
-> Map (KeyHash 'StakePool crypto) (PoolParams crypto)
Sophie._poolParams SnapShot crypto
ss
]
instance Crypto.Crypto crypto => ToJSON (Sophie.Stake crypto) where
toJSON :: Stake crypto -> Value
toJSON (Sophie.Stake Map (Credential 'Staking crypto) Coin
s) = Map (Credential 'Staking crypto) Coin -> Value
forall a. ToJSON a => a -> Value
toJSON Map (Credential 'Staking crypto) Coin
s
instance Crypto.Crypto crypto => ToJSON (Sophie.RewardUpdate crypto) where
toJSON :: RewardUpdate crypto -> Value
toJSON RewardUpdate crypto
rUpdate = [Pair] -> Value
object [ Text
"deltaT" Text -> DeltaCoin -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= RewardUpdate crypto -> DeltaCoin
forall crypto. RewardUpdate crypto -> DeltaCoin
Sophie.deltaT RewardUpdate crypto
rUpdate
, Text
"deltaR" Text -> DeltaCoin -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= RewardUpdate crypto -> DeltaCoin
forall crypto. RewardUpdate crypto -> DeltaCoin
Sophie.deltaR RewardUpdate crypto
rUpdate
, Text
"rs" Text
-> Map (Credential 'Staking crypto) (Set (Reward crypto)) -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= RewardUpdate crypto
-> Map (Credential 'Staking crypto) (Set (Reward crypto))
forall crypto.
RewardUpdate crypto
-> Map (Credential 'Staking crypto) (Set (Reward crypto))
Sophie.rs RewardUpdate crypto
rUpdate
, Text
"deltaF" Text -> DeltaCoin -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= RewardUpdate crypto -> DeltaCoin
forall crypto. RewardUpdate crypto -> DeltaCoin
Sophie.deltaF RewardUpdate crypto
rUpdate
, Text
"nonMyopic" Text -> NonMyopic crypto -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= RewardUpdate crypto -> NonMyopic crypto
forall crypto. RewardUpdate crypto -> NonMyopic crypto
Sophie.nonMyopic RewardUpdate crypto
rUpdate
]
instance Crypto.Crypto crypto => ToJSON (Sophie.PulsingRewUpdate crypto) where
toJSON :: PulsingRewUpdate crypto -> Value
toJSON (Sophie.Pulsing RewardSnapShot crypto
_ Pulser crypto
_) = Value
Aeson.Null
toJSON (Sophie.Complete RewardUpdate crypto
ru) = RewardUpdate crypto -> Value
forall a. ToJSON a => a -> Value
toJSON RewardUpdate crypto
ru
instance ToJSON Sophie.DeltaCoin where
toJSON :: DeltaCoin -> Value
toJSON (Sophie.DeltaCoin Integer
i) = Integer -> Value
forall a. ToJSON a => a -> Value
toJSON Integer
i
instance Crypto.Crypto crypto => ToJSON (Optimum.PoolDistr crypto) where
toJSON :: PoolDistr crypto -> Value
toJSON (Optimum.PoolDistr Map (KeyHash 'StakePool crypto) (IndividualPoolStake crypto)
m) = Map (KeyHash 'StakePool crypto) (IndividualPoolStake crypto)
-> Value
forall a. ToJSON a => a -> Value
toJSON Map (KeyHash 'StakePool crypto) (IndividualPoolStake crypto)
m
instance Crypto.Crypto crypto => ToJSON (Optimum.IndividualPoolStake crypto) where
toJSON :: IndividualPoolStake crypto -> Value
toJSON IndividualPoolStake crypto
indivPoolStake =
[Pair] -> Value
object [ Text
"individualPoolStake" Text -> Rational -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= IndividualPoolStake crypto -> Rational
forall crypto. IndividualPoolStake crypto -> Rational
Optimum.individualPoolStake IndividualPoolStake crypto
indivPoolStake
, Text
"individualPoolStakeVrf" Text -> Hash (HASH crypto) (VerKeyVRF (VRF crypto)) -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= IndividualPoolStake crypto
-> Hash (HASH crypto) (VerKeyVRF (VRF crypto))
forall crypto.
IndividualPoolStake crypto -> Hash crypto (VerKeyVRF crypto)
Optimum.individualPoolStakeVrf IndividualPoolStake crypto
indivPoolStake
]
instance Crypto.Crypto crypto => ToJSON (Sophie.Reward crypto) where
toJSON :: Reward crypto -> Value
toJSON Reward crypto
reward =
[Pair] -> Value
object [ Text
"rewardType" Text -> RewardType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reward crypto -> RewardType
forall crypto. Reward crypto -> RewardType
Sophie.rewardType Reward crypto
reward
, Text
"rewardPool" Text -> KeyHash 'StakePool crypto -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reward crypto -> KeyHash 'StakePool crypto
forall crypto. Reward crypto -> KeyHash 'StakePool crypto
Sophie.rewardPool Reward crypto
reward
, Text
"rewardAmount" Text -> Coin -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Reward crypto -> Coin
forall crypto. Reward crypto -> Coin
Sophie.rewardAmount Reward crypto
reward
]
instance ToJSON Sophie.RewardType where
toJSON :: RewardType -> Value
toJSON RewardType
Sophie.MemberReward = Value
"MemberReward"
toJSON RewardType
Sophie.LeaderReward = Value
"LeaderReward"
instance Crypto.Crypto c => ToJSON (SafeHash.SafeHash c a) where
toJSON :: SafeHash c a -> Value
toJSON = Hash (HASH c) a -> Value
forall a. ToJSON a => a -> Value
toJSON (Hash (HASH c) a -> Value)
-> (SafeHash c a -> Hash (HASH c) a) -> SafeHash c a -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SafeHash c a -> Hash (HASH c) a
forall crypto i. SafeHash crypto i -> Hash (HASH crypto) i
SafeHash.extractHash
instance ToJSON Aurum.ExUnits
deriving instance FromJSON Aurum.ExUnits
instance ToJSON Aurum.Prices where
toJSON :: Prices -> Value
toJSON Aurum.Prices { NonNegativeInterval
prSteps :: Prices -> NonNegativeInterval
prSteps :: NonNegativeInterval
Aurum.prSteps, NonNegativeInterval
prMem :: Prices -> NonNegativeInterval
prMem :: NonNegativeInterval
Aurum.prMem } =
[Pair] -> Value
object [ Text
"prSteps" Text -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Rational -> Value
toRationalJSON (NonNegativeInterval -> Rational
forall r. BoundedRational r => r -> Rational
Ledger.unboundRational NonNegativeInterval
prSteps)
, Text
"prMem" Text -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Rational -> Value
toRationalJSON (NonNegativeInterval -> Rational
forall r. BoundedRational r => r -> Rational
Ledger.unboundRational NonNegativeInterval
prMem)
]
instance FromJSON Aurum.Prices where
parseJSON :: Value -> Parser Prices
parseJSON =
String -> (Object -> Parser Prices) -> Value -> Parser Prices
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"prices" ((Object -> Parser Prices) -> Value -> Parser Prices)
-> (Object -> Parser Prices) -> Value -> Parser Prices
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Rational
steps <- Object
o Object -> Text -> Parser Rational
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"prSteps"
Rational
mem <- Object
o Object -> Text -> Parser Rational
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"prMem"
NonNegativeInterval
prSteps <- Rational -> Parser NonNegativeInterval
forall a (m :: * -> *).
(BoundedRational a, MonadFail m) =>
Rational -> m a
checkBoundedRational Rational
steps
NonNegativeInterval
prMem <- Rational -> Parser NonNegativeInterval
forall a (m :: * -> *).
(BoundedRational a, MonadFail m) =>
Rational -> m a
checkBoundedRational Rational
mem
Prices -> Parser Prices
forall (m :: * -> *) a. Monad m => a -> m a
return Prices :: NonNegativeInterval -> NonNegativeInterval -> Prices
Aurum.Prices { NonNegativeInterval
prSteps :: NonNegativeInterval
prSteps :: NonNegativeInterval
Aurum.prSteps, NonNegativeInterval
prMem :: NonNegativeInterval
prMem :: NonNegativeInterval
Aurum.prMem }
where
checkBoundedRational :: Rational -> m a
checkBoundedRational Rational
r =
case Rational -> Maybe a
forall r. BoundedRational r => Rational -> Maybe r
Ledger.boundRational Rational
r of
Maybe a
Nothing -> String -> m a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String
"too much precision for bounded rational: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Rational -> String
forall a. Show a => a -> String
show Rational
r)
Just a
s -> a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
s
deriving newtype instance FromJSON Aurum.CostModel
deriving newtype instance ToJSON Aurum.CostModel
languageToText :: Aurum.Language -> Text
languageToText :: Language -> Text
languageToText Language
Aurum.ZerepochV1 = Text
"ZerepochV1"
languageFromText :: MonadFail m => Text -> m Aurum.Language
languageFromText :: Text -> m Language
languageFromText Text
"ZerepochV1" = Language -> m Language
forall (f :: * -> *) a. Applicative f => a -> f a
pure Language
Aurum.ZerepochV1
languageFromText Text
lang = String -> m Language
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> m Language) -> String -> m Language
forall a b. (a -> b) -> a -> b
$ String
"Error decoding Language: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Text -> String
forall a. Show a => a -> String
show Text
lang
instance FromJSON Aurum.Language where
parseJSON :: Value -> Parser Language
parseJSON = String -> (Text -> Parser Language) -> Value -> Parser Language
forall a. String -> (Text -> Parser a) -> Value -> Parser a
Aeson.withText String
"Language" Text -> Parser Language
forall (m :: * -> *). MonadFail m => Text -> m Language
languageFromText
instance ToJSON Aurum.Language where
toJSON :: Language -> Value
toJSON = Text -> Value
Aeson.String (Text -> Value) -> (Language -> Text) -> Language -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Language -> Text
languageToText
instance ToJSONKey Aurum.Language where
toJSONKey :: ToJSONKeyFunction Language
toJSONKey = (Language -> Text) -> ToJSONKeyFunction Language
forall a. (a -> Text) -> ToJSONKeyFunction a
toJSONKeyText Language -> Text
languageToText
instance FromJSONKey Aurum.Language where
fromJSONKey :: FromJSONKeyFunction Language
fromJSONKey = (Text -> Parser Language) -> FromJSONKeyFunction Language
forall a. (Text -> Parser a) -> FromJSONKeyFunction a
Aeson.FromJSONKeyTextParser Text -> Parser Language
forall (m :: * -> *). MonadFail m => Text -> m Language
languageFromText
instance FromJSON Aurum.AurumGenesis where
parseJSON :: Value -> Parser AurumGenesis
parseJSON = String
-> (Object -> Parser AurumGenesis) -> Value -> Parser AurumGenesis
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"Aurum Genesis" ((Object -> Parser AurumGenesis) -> Value -> Parser AurumGenesis)
-> (Object -> Parser AurumGenesis) -> Value -> Parser AurumGenesis
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Coin
coinsPerUTxOWord <- Object
o Object -> Text -> Parser Coin
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"entropicPerUTxOWord"
Parser Coin -> Parser Coin -> Parser Coin
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Object
o Object -> Text -> Parser Coin
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"bccPerUTxOWord"
Maybe (Map Language CostModel)
cModels <- Object
o Object -> Text -> Parser (Maybe (Map Language CostModel))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? Text
"costModels"
Prices
prices <- Object
o Object -> Text -> Parser Prices
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"executionPrices"
ExUnits
maxTxExUnits <- Object
o Object -> Text -> Parser ExUnits
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"maxTxExUnits"
ExUnits
maxBlockExUnits <- Object
o Object -> Text -> Parser ExUnits
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"maxBlockExUnits"
Natural
maxValSize <- Object
o Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"maxValueSize"
Natural
collateralPercentage <- Object
o Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"collateralPercentage"
Natural
maxCollateralInputs <- Object
o Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"maxCollateralInputs"
case Maybe (Map Language CostModel)
cModels of
Maybe (Map Language CostModel)
Nothing -> case Map Text Integer -> CostModel
Aurum.CostModel (Map Text Integer -> CostModel)
-> Maybe (Map Text Integer) -> Maybe CostModel
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (Map Text Integer)
defaultCostModelParams of
Just CostModel
m -> AurumGenesis -> Parser AurumGenesis
forall (m :: * -> *) a. Monad m => a -> m a
return AurumGenesis :: Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> AurumGenesis
Aurum.AurumGenesis
{ Coin
coinsPerUTxOWord :: Coin
coinsPerUTxOWord :: Coin
Aurum.coinsPerUTxOWord
, costmdls :: Map Language CostModel
Aurum.costmdls = Language -> CostModel -> Map Language CostModel
forall k a. k -> a -> Map k a
Map.singleton Language
Aurum.ZerepochV1 CostModel
m
, Prices
prices :: Prices
prices :: Prices
Aurum.prices
, ExUnits
maxTxExUnits :: ExUnits
maxTxExUnits :: ExUnits
Aurum.maxTxExUnits
, ExUnits
maxBlockExUnits :: ExUnits
maxBlockExUnits :: ExUnits
Aurum.maxBlockExUnits
, Natural
maxValSize :: Natural
maxValSize :: Natural
Aurum.maxValSize
, Natural
collateralPercentage :: Natural
collateralPercentage :: Natural
Aurum.collateralPercentage
, Natural
maxCollateralInputs :: Natural
maxCollateralInputs :: Natural
Aurum.maxCollateralInputs
}
Maybe CostModel
Nothing -> String -> Parser AurumGenesis
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Failed to extract the cost model params from defaultCostModel"
Just Map Language CostModel
costmdls -> AurumGenesis -> Parser AurumGenesis
forall (m :: * -> *) a. Monad m => a -> m a
return AurumGenesis :: Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> AurumGenesis
Aurum.AurumGenesis
{ Coin
coinsPerUTxOWord :: Coin
coinsPerUTxOWord :: Coin
Aurum.coinsPerUTxOWord
, Map Language CostModel
costmdls :: Map Language CostModel
costmdls :: Map Language CostModel
Aurum.costmdls
, Prices
prices :: Prices
prices :: Prices
Aurum.prices
, ExUnits
maxTxExUnits :: ExUnits
maxTxExUnits :: ExUnits
Aurum.maxTxExUnits
, ExUnits
maxBlockExUnits :: ExUnits
maxBlockExUnits :: ExUnits
Aurum.maxBlockExUnits
, Natural
maxValSize :: Natural
maxValSize :: Natural
Aurum.maxValSize
, Natural
collateralPercentage :: Natural
collateralPercentage :: Natural
Aurum.collateralPercentage
, Natural
maxCollateralInputs :: Natural
maxCollateralInputs :: Natural
Aurum.maxCollateralInputs
}
instance ToJSON Aurum.AurumGenesis where
toJSON :: AurumGenesis -> Value
toJSON AurumGenesis
v = [Pair] -> Value
object
[ Text
"entropicPerUTxOWord" Text -> Coin -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= AurumGenesis -> Coin
Aurum.coinsPerUTxOWord AurumGenesis
v
, Text
"costModels" Text -> Map Language CostModel -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= AurumGenesis -> Map Language CostModel
Aurum.costmdls AurumGenesis
v
, Text
"executionPrices" Text -> Prices -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= AurumGenesis -> Prices
Aurum.prices AurumGenesis
v
, Text
"maxTxExUnits" Text -> ExUnits -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= AurumGenesis -> ExUnits
Aurum.maxTxExUnits AurumGenesis
v
, Text
"maxBlockExUnits" Text -> ExUnits -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= AurumGenesis -> ExUnits
Aurum.maxBlockExUnits AurumGenesis
v
, Text
"maxValueSize" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= AurumGenesis -> Natural
Aurum.maxValSize AurumGenesis
v
, Text
"collateralPercentage" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= AurumGenesis -> Natural
Aurum.collateralPercentage AurumGenesis
v
, Text
"maxCollateralInputs" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= AurumGenesis -> Natural
Aurum.maxCollateralInputs AurumGenesis
v
]
instance ToJSON (Aurum.PParams era) where
toJSON :: PParams era -> Value
toJSON PParams era
pp =
[Pair] -> Value
Aeson.object
[ Text
"minFeeA" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PParams era -> HKD Identity Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Aurum._minfeeA PParams era
pp
, Text
"minFeeB" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PParams era -> HKD Identity Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Aurum._minfeeB PParams era
pp
, Text
"maxBlockBodySize" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PParams era -> HKD Identity Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Aurum._maxBBSize PParams era
pp
, Text
"maxTxSize" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PParams era -> HKD Identity Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Aurum._maxTxSize PParams era
pp
, Text
"maxBlockHeaderSize" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PParams era -> HKD Identity Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Aurum._maxBHSize PParams era
pp
, Text
"keyDeposit" Text -> Coin -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PParams era -> HKD Identity Coin
forall (f :: * -> *) era. PParams' f era -> HKD f Coin
Aurum._keyDeposit PParams era
pp
, Text
"poolDeposit" Text -> Coin -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PParams era -> HKD Identity Coin
forall (f :: * -> *) era. PParams' f era -> HKD f Coin
Aurum._poolDeposit PParams era
pp
, Text
"eMax" Text -> EpochNo -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PParams era -> HKD Identity EpochNo
forall (f :: * -> *) era. PParams' f era -> HKD f EpochNo
Aurum._eMax PParams era
pp
, Text
"nOpt" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PParams era -> HKD Identity Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Aurum._nOpt PParams era
pp
, Text
"a0" Text -> NonNegativeInterval -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PParams era -> HKD Identity NonNegativeInterval
forall (f :: * -> *) era.
PParams' f era -> HKD f NonNegativeInterval
Aurum._a0 PParams era
pp
, Text
"rho" Text -> UnitInterval -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PParams era -> HKD Identity UnitInterval
forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
Aurum._rho PParams era
pp
, Text
"tau" Text -> UnitInterval -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PParams era -> HKD Identity UnitInterval
forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
Aurum._tau PParams era
pp
, Text
"decentralisationParam" Text -> UnitInterval -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PParams era -> HKD Identity UnitInterval
forall (f :: * -> *) era. PParams' f era -> HKD f UnitInterval
Aurum._d PParams era
pp
, Text
"extraEntropy" Text -> Nonce -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PParams era -> HKD Identity Nonce
forall (f :: * -> *) era. PParams' f era -> HKD f Nonce
Aurum._extraEntropy PParams era
pp
, Text
"protocolVersion" Text -> ProtVer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PParams era -> HKD Identity ProtVer
forall (f :: * -> *) era. PParams' f era -> HKD f ProtVer
Aurum._protocolVersion PParams era
pp
, Text
"minPoolCost" Text -> Coin -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PParams era -> HKD Identity Coin
forall (f :: * -> *) era. PParams' f era -> HKD f Coin
Aurum._minPoolCost PParams era
pp
, Text
"entropicPerUTxOWord" Text -> Coin -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PParams era -> HKD Identity Coin
forall (f :: * -> *) era. PParams' f era -> HKD f Coin
Aurum._coinsPerUTxOWord PParams era
pp
, Text
"costmdls" Text -> Map Language CostModel -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PParams era -> HKD Identity (Map Language CostModel)
forall (f :: * -> *) era.
PParams' f era -> HKD f (Map Language CostModel)
Aurum._costmdls PParams era
pp
, Text
"prices" Text -> Prices -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PParams era -> HKD Identity Prices
forall (f :: * -> *) era. PParams' f era -> HKD f Prices
Aurum._prices PParams era
pp
, Text
"maxTxExUnits" Text -> ExUnits -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PParams era -> HKD Identity ExUnits
forall (f :: * -> *) era. PParams' f era -> HKD f ExUnits
Aurum._maxTxExUnits PParams era
pp
, Text
"maxBlockExUnits" Text -> ExUnits -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PParams era -> HKD Identity ExUnits
forall (f :: * -> *) era. PParams' f era -> HKD f ExUnits
Aurum._maxBlockExUnits PParams era
pp
, Text
"maxValSize" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PParams era -> HKD Identity Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Aurum._maxValSize PParams era
pp
, Text
"collateralPercentage" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PParams era -> HKD Identity Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Aurum._collateralPercentage PParams era
pp
, Text
"maxCollateralInputs " Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= PParams era -> HKD Identity Natural
forall (f :: * -> *) era. PParams' f era -> HKD f Natural
Aurum._maxCollateralInputs PParams era
pp
]
instance FromJSON (Aurum.PParams era) where
parseJSON :: Value -> Parser (PParams era)
parseJSON =
String
-> (Object -> Parser (PParams era))
-> Value
-> Parser (PParams era)
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"PParams" ((Object -> Parser (PParams era)) -> Value -> Parser (PParams era))
-> (Object -> Parser (PParams era))
-> Value
-> Parser (PParams era)
forall a b. (a -> b) -> a -> b
$ \Object
obj ->
Natural
-> Natural
-> Natural
-> Natural
-> Natural
-> Coin
-> Coin
-> EpochNo
-> Natural
-> NonNegativeInterval
-> UnitInterval
-> UnitInterval
-> UnitInterval
-> Nonce
-> ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era
forall (f :: * -> *) era.
HKD f Natural
-> HKD f Natural
-> HKD f Natural
-> HKD f Natural
-> HKD f Natural
-> HKD f Coin
-> HKD f Coin
-> HKD f EpochNo
-> HKD f Natural
-> HKD f NonNegativeInterval
-> HKD f UnitInterval
-> HKD f UnitInterval
-> HKD f UnitInterval
-> HKD f Nonce
-> HKD f ProtVer
-> HKD f Coin
-> HKD f Coin
-> HKD f (Map Language CostModel)
-> HKD f Prices
-> HKD f ExUnits
-> HKD f ExUnits
-> HKD f Natural
-> HKD f Natural
-> HKD f Natural
-> PParams' f era
Aurum.PParams
(Natural
-> Natural
-> Natural
-> Natural
-> Natural
-> Coin
-> Coin
-> EpochNo
-> Natural
-> NonNegativeInterval
-> UnitInterval
-> UnitInterval
-> UnitInterval
-> Nonce
-> ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
-> Parser Natural
-> Parser
(Natural
-> Natural
-> Natural
-> Natural
-> Coin
-> Coin
-> EpochNo
-> Natural
-> NonNegativeInterval
-> UnitInterval
-> UnitInterval
-> UnitInterval
-> Nonce
-> ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
obj Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"minFeeA"
Parser
(Natural
-> Natural
-> Natural
-> Natural
-> Coin
-> Coin
-> EpochNo
-> Natural
-> NonNegativeInterval
-> UnitInterval
-> UnitInterval
-> UnitInterval
-> Nonce
-> ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
-> Parser Natural
-> Parser
(Natural
-> Natural
-> Natural
-> Coin
-> Coin
-> EpochNo
-> Natural
-> NonNegativeInterval
-> UnitInterval
-> UnitInterval
-> UnitInterval
-> Nonce
-> ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"minFeeB"
Parser
(Natural
-> Natural
-> Natural
-> Coin
-> Coin
-> EpochNo
-> Natural
-> NonNegativeInterval
-> UnitInterval
-> UnitInterval
-> UnitInterval
-> Nonce
-> ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
-> Parser Natural
-> Parser
(Natural
-> Natural
-> Coin
-> Coin
-> EpochNo
-> Natural
-> NonNegativeInterval
-> UnitInterval
-> UnitInterval
-> UnitInterval
-> Nonce
-> ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"maxBlockBodySize"
Parser
(Natural
-> Natural
-> Coin
-> Coin
-> EpochNo
-> Natural
-> NonNegativeInterval
-> UnitInterval
-> UnitInterval
-> UnitInterval
-> Nonce
-> ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
-> Parser Natural
-> Parser
(Natural
-> Coin
-> Coin
-> EpochNo
-> Natural
-> NonNegativeInterval
-> UnitInterval
-> UnitInterval
-> UnitInterval
-> Nonce
-> ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"maxTxSize"
Parser
(Natural
-> Coin
-> Coin
-> EpochNo
-> Natural
-> NonNegativeInterval
-> UnitInterval
-> UnitInterval
-> UnitInterval
-> Nonce
-> ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
-> Parser Natural
-> Parser
(Coin
-> Coin
-> EpochNo
-> Natural
-> NonNegativeInterval
-> UnitInterval
-> UnitInterval
-> UnitInterval
-> Nonce
-> ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"maxBlockHeaderSize"
Parser
(Coin
-> Coin
-> EpochNo
-> Natural
-> NonNegativeInterval
-> UnitInterval
-> UnitInterval
-> UnitInterval
-> Nonce
-> ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
-> Parser Coin
-> Parser
(Coin
-> EpochNo
-> Natural
-> NonNegativeInterval
-> UnitInterval
-> UnitInterval
-> UnitInterval
-> Nonce
-> ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Text -> Parser Coin
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"keyDeposit"
Parser
(Coin
-> EpochNo
-> Natural
-> NonNegativeInterval
-> UnitInterval
-> UnitInterval
-> UnitInterval
-> Nonce
-> ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
-> Parser Coin
-> Parser
(EpochNo
-> Natural
-> NonNegativeInterval
-> UnitInterval
-> UnitInterval
-> UnitInterval
-> Nonce
-> ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Text -> Parser Coin
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"poolDeposit"
Parser
(EpochNo
-> Natural
-> NonNegativeInterval
-> UnitInterval
-> UnitInterval
-> UnitInterval
-> Nonce
-> ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
-> Parser EpochNo
-> Parser
(Natural
-> NonNegativeInterval
-> UnitInterval
-> UnitInterval
-> UnitInterval
-> Nonce
-> ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Text -> Parser EpochNo
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"eMax"
Parser
(Natural
-> NonNegativeInterval
-> UnitInterval
-> UnitInterval
-> UnitInterval
-> Nonce
-> ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
-> Parser Natural
-> Parser
(NonNegativeInterval
-> UnitInterval
-> UnitInterval
-> UnitInterval
-> Nonce
-> ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"nOpt"
Parser
(NonNegativeInterval
-> UnitInterval
-> UnitInterval
-> UnitInterval
-> Nonce
-> ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
-> Parser NonNegativeInterval
-> Parser
(UnitInterval
-> UnitInterval
-> UnitInterval
-> Nonce
-> ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Text -> Parser NonNegativeInterval
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"a0"
Parser
(UnitInterval
-> UnitInterval
-> UnitInterval
-> Nonce
-> ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
-> Parser UnitInterval
-> Parser
(UnitInterval
-> UnitInterval
-> Nonce
-> ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Text -> Parser UnitInterval
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"rho"
Parser
(UnitInterval
-> UnitInterval
-> Nonce
-> ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
-> Parser UnitInterval
-> Parser
(UnitInterval
-> Nonce
-> ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Text -> Parser UnitInterval
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"tau"
Parser
(UnitInterval
-> Nonce
-> ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
-> Parser UnitInterval
-> Parser
(Nonce
-> ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Text -> Parser UnitInterval
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"decentralisationParam"
Parser
(Nonce
-> ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
-> Parser Nonce
-> Parser
(ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Text -> Parser Nonce
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"extraEntropy"
Parser
(ProtVer
-> Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
-> Parser ProtVer
-> Parser
(Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Text -> Parser ProtVer
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"protocolVersion"
Parser
(Coin
-> Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
-> Parser Coin
-> Parser
(Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Text -> Parser (Maybe Coin)
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"minPoolCost" Parser (Maybe Coin) -> Coin -> Parser Coin
forall a. Parser (Maybe a) -> a -> Parser a
.!= Coin
forall a. Monoid a => a
mempty
Parser
(Coin
-> Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
-> Parser Coin
-> Parser
(Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Text -> Parser Coin
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"entropicPerUTxOWord"
Parser
(Map Language CostModel
-> Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
-> Parser (Map Language CostModel)
-> Parser
(Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Text -> Parser (Map Language CostModel)
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"costmdls"
Parser
(Prices
-> ExUnits
-> ExUnits
-> Natural
-> Natural
-> Natural
-> PParams era)
-> Parser Prices
-> Parser
(ExUnits
-> ExUnits -> Natural -> Natural -> Natural -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Text -> Parser Prices
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"prices"
Parser
(ExUnits
-> ExUnits -> Natural -> Natural -> Natural -> PParams era)
-> Parser ExUnits
-> Parser (ExUnits -> Natural -> Natural -> Natural -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Text -> Parser ExUnits
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"maxTxExUnits"
Parser (ExUnits -> Natural -> Natural -> Natural -> PParams era)
-> Parser ExUnits
-> Parser (Natural -> Natural -> Natural -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Text -> Parser ExUnits
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"maxBlockExUnits"
Parser (Natural -> Natural -> Natural -> PParams era)
-> Parser Natural -> Parser (Natural -> Natural -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"maxValSize"
Parser (Natural -> Natural -> PParams era)
-> Parser Natural -> Parser (Natural -> PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"collateralPercentage"
Parser (Natural -> PParams era)
-> Parser Natural -> Parser (PParams era)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"maxCollateralInputs"
deriving instance ToJSON (Aurum.PParamsUpdate (Aurum.AurumEra StandardCrypto))
instance (Ledger.Era era, Show (Ledger.Value era), ToJSON (Ledger.Value era))
=> ToJSON (Aurum.TxOut era) where
toJSON :: TxOut era -> Value
toJSON (Aurum.TxOut Addr (Crypto era)
addr Value era
v StrictMaybe (DataHash (Crypto era))
dataHash) =
[Pair] -> Value
object [ Text
"address" Text -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Addr (Crypto era) -> Value
forall a. ToJSON a => a -> Value
toJSON Addr (Crypto era)
addr
, Text
"value" Text -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= Value era -> Value
forall a. ToJSON a => a -> Value
toJSON Value era
v
, Text
"datahash" Text -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
.= case StrictMaybe (DataHash (Crypto era))
-> Maybe (DataHash (Crypto era))
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe StrictMaybe (DataHash (Crypto era))
dataHash of
Maybe (DataHash (Crypto era))
Nothing -> Value
Aeson.Null
Just DataHash (Crypto era)
dHash ->
Text -> Value
Aeson.String (Text -> Value)
-> (Hash (HASH (Crypto era)) EraIndependentData -> Text)
-> Hash (HASH (Crypto era)) EraIndependentData
-> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash (HASH (Crypto era)) EraIndependentData -> Text
forall crypto a. Hash crypto a -> Text
Crypto.hashToTextAsHex
(Hash (HASH (Crypto era)) EraIndependentData -> Value)
-> Hash (HASH (Crypto era)) EraIndependentData -> Value
forall a b. (a -> b) -> a -> b
$ DataHash (Crypto era)
-> Hash (HASH (Crypto era)) EraIndependentData
forall crypto i. SafeHash crypto i -> Hash (HASH crypto) i
SafeHash.extractHash DataHash (Crypto era)
dHash
]
deriving instance Show Aurum.AurumGenesis
deriving newtype instance ToJSON SystemStart
deriving newtype instance FromJSON SystemStart