{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
{-# HLINT ignore "Redundant bracket" #-}
module Cardano.CLI.Json.Friendly
(
friendlyTx
, friendlyTxBody
, friendlyProposal
, friendlyBS
, friendlyTxImpl
, friendlyTxBodyImpl
, friendlyProposalImpl
, FriendlyFormat (..)
, viewOutputFormatToFriendlyFormat
)
where
import Cardano.Api as Api
import Cardano.Api.Byron (KeyWitness (ByronKeyWitness))
import Cardano.Api.Ledger (ExUnits (..), extractHash, strictMaybeToMaybe)
import qualified Cardano.Api.Ledger as L
import qualified Cardano.Api.Ledger as Ledger
import Cardano.Api.Shelley (Hash (..),
KeyWitness (ShelleyBootstrapWitness, ShelleyKeyWitness), Proposal (..),
ShelleyLedgerEra, StakeAddress (..), Tx (ShelleyTx),
fromShelleyPaymentCredential, fromShelleyStakeReference,
toShelleyStakeCredential)
import Cardano.CLI.Orphans ()
import Cardano.CLI.Types.Common (ViewOutputFormat (..))
import Cardano.CLI.Types.MonadWarning (MonadWarning, runWarningIO)
import Cardano.Crypto.Hash (hashToTextAsHex)
import Data.Aeson (Value (..), object, toJSON, (.=))
import qualified Data.Aeson as Aeson
import qualified Data.Aeson.Encode.Pretty as Aeson
import qualified Data.Aeson.Key as Aeson
import qualified Data.Aeson.Types as Aeson
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BSC
import qualified Data.ByteString.Lazy as LBS
import Data.Char (isAscii)
import Data.Function ((&))
import Data.Functor ((<&>))
import qualified Data.Map.Strict as Map
import Data.Maybe
import Data.Ratio (numerator)
import qualified Data.Text as T
import qualified Data.Text as Text
import qualified Data.Vector as Vector
import Data.Yaml (array)
import Data.Yaml.Pretty (setConfCompare)
import qualified Data.Yaml.Pretty as Yaml
import GHC.Exts (IsList (..))
import GHC.Real (denominator)
import GHC.Unicode (isAlphaNum)
import Lens.Micro ((^.))
data FriendlyFormat = FriendlyJson | FriendlyYaml
viewOutputFormatToFriendlyFormat :: ViewOutputFormat -> FriendlyFormat
viewOutputFormatToFriendlyFormat :: ViewOutputFormat -> FriendlyFormat
viewOutputFormatToFriendlyFormat = \case
ViewOutputFormat
ViewOutputFormatJson -> FriendlyFormat
FriendlyJson
ViewOutputFormat
ViewOutputFormatYaml -> FriendlyFormat
FriendlyYaml
friendly
:: (MonadIO m, Aeson.ToJSON a)
=> FriendlyFormat
-> Maybe (File () Out)
-> a
-> m (Either (FileError e) ())
friendly :: forall (m :: * -> *) a e.
(MonadIO m, ToJSON a) =>
FriendlyFormat
-> Maybe (File () 'Out) -> a -> m (Either (FileError e) ())
friendly FriendlyFormat
FriendlyJson Maybe (File () 'Out)
mOutFile = Maybe (File () 'Out) -> ByteString -> m (Either (FileError e) ())
forall (m :: * -> *) content e.
MonadIO m =>
Maybe (File content 'Out)
-> ByteString -> m (Either (FileError e) ())
writeLazyByteStringOutput Maybe (File () 'Out)
mOutFile (ByteString -> m (Either (FileError e) ()))
-> (a -> ByteString) -> a -> m (Either (FileError e) ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Config -> a -> ByteString
forall a. ToJSON a => Config -> a -> ByteString
Aeson.encodePretty' Config
jsonConfig
friendly FriendlyFormat
FriendlyYaml Maybe (File () 'Out)
mOutFile = Maybe (File () 'Out) -> ByteString -> m (Either (FileError e) ())
forall (m :: * -> *) content e.
MonadIO m =>
Maybe (File content 'Out)
-> ByteString -> m (Either (FileError e) ())
writeByteStringOutput Maybe (File () 'Out)
mOutFile (ByteString -> m (Either (FileError e) ()))
-> (a -> ByteString) -> a -> m (Either (FileError e) ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Config -> a -> ByteString
forall a. ToJSON a => Config -> a -> ByteString
Yaml.encodePretty Config
yamlConfig
friendlyBS
:: ()
=> Aeson.ToJSON a
=> FriendlyFormat
-> a
-> BS.ByteString
friendlyBS :: forall a. ToJSON a => FriendlyFormat -> a -> ByteString
friendlyBS FriendlyFormat
FriendlyJson a
a = [ByteString] -> ByteString
BS.concat ([ByteString] -> ByteString)
-> (ByteString -> [ByteString]) -> ByteString -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> [ByteString]
LBS.toChunks (ByteString -> ByteString) -> ByteString -> ByteString
forall a b. (a -> b) -> a -> b
$ Config -> a -> ByteString
forall a. ToJSON a => Config -> a -> ByteString
Aeson.encodePretty' Config
jsonConfig a
a
friendlyBS FriendlyFormat
FriendlyYaml a
a = Config -> a -> ByteString
forall a. ToJSON a => Config -> a -> ByteString
Yaml.encodePretty Config
yamlConfig a
a
jsonConfig :: Aeson.Config
jsonConfig :: Config
jsonConfig = Config
Aeson.defConfig{Aeson.confCompare = compare}
yamlConfig :: Yaml.Config
yamlConfig :: Config
yamlConfig = Config
Yaml.defConfig Config -> (Config -> Config) -> Config
forall a b. a -> (a -> b) -> b
& (Text -> Text -> Ordering) -> Config -> Config
setConfCompare Text -> Text -> Ordering
forall a. Ord a => a -> a -> Ordering
compare
friendlyTx
:: MonadIO m
=> FriendlyFormat
-> Maybe (File () Out)
-> CardanoEra era
-> Tx era
-> m (Either (FileError e) ())
friendlyTx :: forall (m :: * -> *) era e.
MonadIO m =>
FriendlyFormat
-> Maybe (File () 'Out)
-> CardanoEra era
-> Tx era
-> m (Either (FileError e) ())
friendlyTx FriendlyFormat
format Maybe (File () 'Out)
mOutFile CardanoEra era
era =
CardanoEra era
-> (CardanoEraConstraints era =>
Tx era -> m (Either (FileError e) ()))
-> Tx era
-> m (Either (FileError e) ())
forall era a.
CardanoEra era -> (CardanoEraConstraints era => a) -> a
cardanoEraConstraints
CardanoEra era
era
( \Tx era
tx -> do
[Pair]
pairs <- WarningIO m [Pair] -> m [Pair]
forall (m :: * -> *) a. WarningIO m a -> m a
runWarningIO (WarningIO m [Pair] -> m [Pair]) -> WarningIO m [Pair] -> m [Pair]
forall a b. (a -> b) -> a -> b
$ CardanoEra era -> Tx era -> WarningIO m [Pair]
forall (m :: * -> *) era.
MonadWarning m =>
CardanoEra era -> Tx era -> m [Pair]
friendlyTxImpl CardanoEra era
era Tx era
tx
FriendlyFormat
-> Maybe (File () 'Out) -> Value -> m (Either (FileError e) ())
forall (m :: * -> *) a e.
(MonadIO m, ToJSON a) =>
FriendlyFormat
-> Maybe (File () 'Out) -> a -> m (Either (FileError e) ())
friendly FriendlyFormat
format Maybe (File () 'Out)
mOutFile (Value -> m (Either (FileError e) ()))
-> Value -> m (Either (FileError e) ())
forall a b. (a -> b) -> a -> b
$ [Pair] -> Value
object [Pair]
pairs
)
friendlyTxBody
:: MonadIO m
=> FriendlyFormat
-> Maybe (File () Out)
-> CardanoEra era
-> TxBody era
-> m (Either (FileError e) ())
friendlyTxBody :: forall (m :: * -> *) era e.
MonadIO m =>
FriendlyFormat
-> Maybe (File () 'Out)
-> CardanoEra era
-> TxBody era
-> m (Either (FileError e) ())
friendlyTxBody FriendlyFormat
format Maybe (File () 'Out)
mOutFile CardanoEra era
era =
CardanoEra era
-> (CardanoEraConstraints era =>
TxBody era -> m (Either (FileError e) ()))
-> TxBody era
-> m (Either (FileError e) ())
forall era a.
CardanoEra era -> (CardanoEraConstraints era => a) -> a
cardanoEraConstraints
CardanoEra era
era
( \TxBody era
tx -> do
[Pair]
pairs <- WarningIO m [Pair] -> m [Pair]
forall (m :: * -> *) a. WarningIO m a -> m a
runWarningIO (WarningIO m [Pair] -> m [Pair]) -> WarningIO m [Pair] -> m [Pair]
forall a b. (a -> b) -> a -> b
$ CardanoEra era -> TxBody era -> WarningIO m [Pair]
forall (m :: * -> *) era.
MonadWarning m =>
CardanoEra era -> TxBody era -> m [Pair]
friendlyTxBodyImpl CardanoEra era
era TxBody era
tx
FriendlyFormat
-> Maybe (File () 'Out) -> Value -> m (Either (FileError e) ())
forall (m :: * -> *) a e.
(MonadIO m, ToJSON a) =>
FriendlyFormat
-> Maybe (File () 'Out) -> a -> m (Either (FileError e) ())
friendly FriendlyFormat
format Maybe (File () 'Out)
mOutFile (Value -> m (Either (FileError e) ()))
-> Value -> m (Either (FileError e) ())
forall a b. (a -> b) -> a -> b
$ [Pair] -> Value
object [Pair]
pairs
)
friendlyProposal
:: MonadIO m
=> FriendlyFormat
-> Maybe (File () Out)
-> ConwayEraOnwards era
-> Proposal era
-> m (Either (FileError e) ())
friendlyProposal :: forall (m :: * -> *) era e.
MonadIO m =>
FriendlyFormat
-> Maybe (File () 'Out)
-> ConwayEraOnwards era
-> Proposal era
-> m (Either (FileError e) ())
friendlyProposal FriendlyFormat
format Maybe (File () 'Out)
mOutFile ConwayEraOnwards era
era =
ConwayEraOnwards era
-> (ConwayEraOnwardsConstraints era =>
Proposal era -> m (Either (FileError e) ()))
-> Proposal era
-> m (Either (FileError e) ())
forall era a.
ConwayEraOnwards era -> (ConwayEraOnwardsConstraints era => a) -> a
conwayEraOnwardsConstraints ConwayEraOnwards era
era ((ConwayEraOnwardsConstraints era =>
Proposal era -> m (Either (FileError e) ()))
-> Proposal era -> m (Either (FileError e) ()))
-> (ConwayEraOnwardsConstraints era =>
Proposal era -> m (Either (FileError e) ()))
-> Proposal era
-> m (Either (FileError e) ())
forall a b. (a -> b) -> a -> b
$
FriendlyFormat
-> Maybe (File () 'Out) -> Value -> m (Either (FileError e) ())
forall (m :: * -> *) a e.
(MonadIO m, ToJSON a) =>
FriendlyFormat
-> Maybe (File () 'Out) -> a -> m (Either (FileError e) ())
friendly FriendlyFormat
format Maybe (File () 'Out)
mOutFile (Value -> m (Either (FileError e) ()))
-> (Proposal era -> Value)
-> Proposal era
-> m (Either (FileError e) ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Pair] -> Value
object ([Pair] -> Value)
-> (Proposal era -> [Pair]) -> Proposal era -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ConwayEraOnwards era -> Proposal era -> [Pair]
forall era. ConwayEraOnwards era -> Proposal era -> [Pair]
friendlyProposalImpl ConwayEraOnwards era
era
friendlyProposalImpl :: ConwayEraOnwards era -> Proposal era -> [Aeson.Pair]
friendlyProposalImpl :: forall era. ConwayEraOnwards era -> Proposal era -> [Pair]
friendlyProposalImpl
ConwayEraOnwards era
era
( Proposal
( L.ProposalProcedure
{ Lovelace
pProcDeposit :: Lovelace
pProcDeposit :: forall era. ProposalProcedure era -> Lovelace
L.pProcDeposit
, RewardAccount (EraCrypto (ShelleyLedgerEra era))
pProcReturnAddr :: RewardAccount (EraCrypto (ShelleyLedgerEra era))
pProcReturnAddr :: forall era. ProposalProcedure era -> RewardAccount (EraCrypto era)
L.pProcReturnAddr
, GovAction (ShelleyLedgerEra era)
pProcGovAction :: GovAction (ShelleyLedgerEra era)
pProcGovAction :: forall era. ProposalProcedure era -> GovAction era
L.pProcGovAction
, Anchor (EraCrypto (ShelleyLedgerEra era))
pProcAnchor :: Anchor (EraCrypto (ShelleyLedgerEra era))
pProcAnchor :: forall era. ProposalProcedure era -> Anchor (EraCrypto era)
L.pProcAnchor
}
)
) =
ConwayEraOnwards era
-> (ConwayEraOnwardsConstraints era => [Pair]) -> [Pair]
forall era a.
ConwayEraOnwards era -> (ConwayEraOnwardsConstraints era => a) -> a
conwayEraOnwardsConstraints
ConwayEraOnwards era
era
[ Key
"deposit" Key -> Lovelace -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Lovelace
pProcDeposit
, Key
"return address" Key -> RewardAccount StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= RewardAccount (EraCrypto (ShelleyLedgerEra era))
RewardAccount StandardCrypto
pProcReturnAddr
, Key
"governance action" Key -> GovAction (ShelleyLedgerEra era) -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= GovAction (ShelleyLedgerEra era)
pProcGovAction
, Key
"anchor" Key -> Anchor StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Anchor (EraCrypto (ShelleyLedgerEra era))
Anchor StandardCrypto
pProcAnchor
]
friendlyTxImpl
:: MonadWarning m
=> CardanoEra era
-> Tx era
-> m [Aeson.Pair]
friendlyTxImpl :: forall (m :: * -> *) era.
MonadWarning m =>
CardanoEra era -> Tx era -> m [Pair]
friendlyTxImpl CardanoEra era
era (Tx TxBody era
body [KeyWitness era]
witnesses) =
((Key
"witnesses" Key -> [Value] -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (KeyWitness era -> Value) -> [KeyWitness era] -> [Value]
forall a b. (a -> b) -> [a] -> [b]
map KeyWitness era -> Value
forall era. KeyWitness era -> Value
friendlyKeyWitness [KeyWitness era]
witnesses) Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
:) ([Pair] -> [Pair]) -> m [Pair] -> m [Pair]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CardanoEra era -> TxBody era -> m [Pair]
forall (m :: * -> *) era.
MonadWarning m =>
CardanoEra era -> TxBody era -> m [Pair]
friendlyTxBodyImpl CardanoEra era
era TxBody era
body
friendlyKeyWitness :: KeyWitness era -> Aeson.Value
friendlyKeyWitness :: forall era. KeyWitness era -> Value
friendlyKeyWitness =
[Pair] -> Value
object
([Pair] -> Value)
-> (KeyWitness era -> [Pair]) -> KeyWitness era -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. \case
ByronKeyWitness TxInWitness
txInWitness -> [Key
"Byron witness" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TxInWitness -> Text
forall a. Show a => a -> Text
textShow TxInWitness
txInWitness]
ShelleyBootstrapWitness ShelleyBasedEra era
_era BootstrapWitness StandardCrypto
bootstrapWitness ->
[Key
"bootstrap witness" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= BootstrapWitness StandardCrypto -> Text
forall a. Show a => a -> Text
textShow BootstrapWitness StandardCrypto
bootstrapWitness]
ShelleyKeyWitness ShelleyBasedEra era
_era (L.WitVKey VKey 'Witness StandardCrypto
key SignedDSIGN
StandardCrypto (Hash StandardCrypto EraIndependentTxBody)
signature) ->
[Key
"key" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= VKey 'Witness StandardCrypto -> Text
forall a. Show a => a -> Text
textShow VKey 'Witness StandardCrypto
key, Key
"signature" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= SignedDSIGN Ed25519DSIGN (Hash Blake2b_256 EraIndependentTxBody)
-> Text
forall a. Show a => a -> Text
textShow SignedDSIGN Ed25519DSIGN (Hash Blake2b_256 EraIndependentTxBody)
SignedDSIGN
StandardCrypto (Hash StandardCrypto EraIndependentTxBody)
signature]
friendlyTxBodyImpl
:: MonadWarning m
=> CardanoEra era
-> TxBody era
-> m [Aeson.Pair]
friendlyTxBodyImpl :: forall (m :: * -> *) era.
MonadWarning m =>
CardanoEra era -> TxBody era -> m [Pair]
friendlyTxBodyImpl
CardanoEra era
era
tb :: TxBody era
tb@( TxBody
( TxBodyContent
TxIns ViewTx era
txIns
TxInsCollateral era
txInsCollateral
TxInsReference era
txInsReference
[TxOut CtxTx era]
txOuts
TxTotalCollateral era
txTotalCollateral
TxReturnCollateral CtxTx era
txReturnCollateral
TxFee era
txFee
TxValidityLowerBound era
txValidityLowerBound
TxValidityUpperBound era
txValidityUpperBound
TxMetadataInEra era
txMetadata
TxAuxScripts era
txAuxScripts
TxExtraKeyWitnesses era
txExtraKeyWits
BuildTxWith ViewTx (Maybe (LedgerProtocolParameters era))
_txProtocolParams
TxWithdrawals ViewTx era
txWithdrawals
TxCertificates ViewTx era
txCertificates
TxUpdateProposal era
txUpdateProposal
TxMintValue ViewTx era
txMintValue
TxScriptValidity era
_txScriptValidity
Maybe
(Featured ConwayEraOnwards era (TxProposalProcedures ViewTx era))
txProposalProcedures
Maybe
(Featured ConwayEraOnwards era (TxVotingProcedures ViewTx era))
txVotingProcedures
Maybe (Featured ConwayEraOnwards era (Maybe Lovelace))
txCurrentTreasuryValue
Maybe (Featured ConwayEraOnwards era Lovelace)
txTreasuryDonation
)
) =
do
[Pair] -> m [Pair]
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return ([Pair] -> m [Pair]) -> [Pair] -> m [Pair]
forall a b. (a -> b) -> a -> b
$
CardanoEra era -> (CardanoEraConstraints era => [Pair]) -> [Pair]
forall era a.
CardanoEra era -> (CardanoEraConstraints era => a) -> a
cardanoEraConstraints
CardanoEra era
era
( [ Key
"auxiliary scripts" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TxAuxScripts era -> Value
forall era. TxAuxScripts era -> Value
friendlyAuxScripts TxAuxScripts era
txAuxScripts
, Key
"certificates" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= CardanoEra era -> Value -> (ShelleyBasedEra era -> Value) -> Value
forall (eon :: * -> *) era a.
Eon eon =>
CardanoEra era -> a -> (eon era -> a) -> a
forEraInEon CardanoEra era
era Value
Null (ShelleyBasedEra era -> TxCertificates ViewTx era -> Value
forall era.
ShelleyBasedEra era -> TxCertificates ViewTx era -> Value
`friendlyCertificates` TxCertificates ViewTx era
txCertificates)
, Key
"collateral inputs" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TxInsCollateral era -> Value
forall era. TxInsCollateral era -> Value
friendlyCollateralInputs TxInsCollateral era
txInsCollateral
, Key
"era" Key -> CardanoEra era -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= CardanoEra era
era
, Key
"fee" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TxFee era -> Value
forall era. TxFee era -> Value
friendlyFee TxFee era
txFee
, Key
"inputs" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TxIns ViewTx era -> Value
forall build. [(TxIn, build)] -> Value
friendlyInputs TxIns ViewTx era
txIns
, Key
"metadata" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TxMetadataInEra era -> Value
forall era. TxMetadataInEra era -> Value
friendlyMetadata TxMetadataInEra era
txMetadata
, Key
"mint" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TxMintValue ViewTx era -> Value
forall era. TxMintValue ViewTx era -> Value
friendlyMintValue TxMintValue ViewTx era
txMintValue
, Key
"outputs" Key -> [Value] -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (TxOut CtxTx era -> Value) -> [TxOut CtxTx era] -> [Value]
forall a b. (a -> b) -> [a] -> [b]
map (CardanoEra era -> TxOut CtxTx era -> Value
forall era. CardanoEra era -> TxOut CtxTx era -> Value
friendlyTxOut CardanoEra era
era) [TxOut CtxTx era]
txOuts
, Key
"reference inputs" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TxInsReference era -> Value
forall era. TxInsReference era -> Value
friendlyReferenceInputs TxInsReference era
txInsReference
, Key
"total collateral" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TxTotalCollateral era -> Value
forall era. TxTotalCollateral era -> Value
friendlyTotalCollateral TxTotalCollateral era
txTotalCollateral
, Key
"return collateral" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= CardanoEra era -> TxReturnCollateral CtxTx era -> Value
forall era. CardanoEra era -> TxReturnCollateral CtxTx era -> Value
friendlyReturnCollateral CardanoEra era
era TxReturnCollateral CtxTx era
txReturnCollateral
, Key
"required signers (payment key hashes needed for scripts)"
Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TxExtraKeyWitnesses era -> Value
forall era. TxExtraKeyWitnesses era -> Value
friendlyExtraKeyWits TxExtraKeyWitnesses era
txExtraKeyWits
, Key
"update proposal" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TxUpdateProposal era -> Value
forall era. TxUpdateProposal era -> Value
friendlyUpdateProposal TxUpdateProposal era
txUpdateProposal
, Key
"validity range" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= CardanoEra era
-> (TxValidityLowerBound era, TxValidityUpperBound era) -> Value
forall era.
CardanoEra era
-> (TxValidityLowerBound era, TxValidityUpperBound era) -> Value
friendlyValidityRange CardanoEra era
era (TxValidityLowerBound era
txValidityLowerBound, TxValidityUpperBound era
txValidityUpperBound)
, Key
"withdrawals" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TxWithdrawals ViewTx era -> Value
forall era. TxWithdrawals ViewTx era -> Value
friendlyWithdrawals TxWithdrawals ViewTx era
txWithdrawals
]
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ ( forall (eon :: * -> *) a era.
(Eon eon, Monoid a) =>
CardanoEra era -> (eon era -> a) -> a
monoidForEraInEon @AlonzoEraOnwards
CardanoEra era
era
(AlonzoEraOnwards era -> TxBody era -> [Pair]
forall era. AlonzoEraOnwards era -> TxBody era -> [Pair]
`getRedeemerDetails` TxBody era
tb)
)
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ ( forall (eon :: * -> *) a era.
(Eon eon, Monoid a) =>
CardanoEra era -> (eon era -> a) -> a
monoidForEraInEon @ConwayEraOnwards
CardanoEra era
era
( \ConwayEraOnwards era
cOnwards ->
ConwayEraOnwards era
-> (ConwayEraOnwardsConstraints era => [Pair]) -> [Pair]
forall era a.
ConwayEraOnwards era -> (ConwayEraOnwardsConstraints era => a) -> a
conwayEraOnwardsConstraints ConwayEraOnwards era
cOnwards ((ConwayEraOnwardsConstraints era => [Pair]) -> [Pair])
-> (ConwayEraOnwardsConstraints era => [Pair]) -> [Pair]
forall a b. (a -> b) -> a -> b
$
case Maybe
(Featured ConwayEraOnwards era (TxProposalProcedures ViewTx era))
txProposalProcedures of
Maybe
(Featured ConwayEraOnwards era (TxProposalProcedures ViewTx era))
Nothing -> []
Just (Featured ConwayEraOnwards era
_ TxProposalProcedures ViewTx era
TxProposalProceduresNone) -> []
Just (Featured ConwayEraOnwards era
_ TxProposalProcedures ViewTx era
pp) -> do
let lProposals :: [Item (OSet (ProposalProcedure (ShelleyLedgerEra era)))]
lProposals = OSet (ProposalProcedure (ShelleyLedgerEra era))
-> [Item (OSet (ProposalProcedure (ShelleyLedgerEra era)))]
forall l. IsList l => l -> [Item l]
toList (OSet (ProposalProcedure (ShelleyLedgerEra era))
-> [Item (OSet (ProposalProcedure (ShelleyLedgerEra era)))])
-> OSet (ProposalProcedure (ShelleyLedgerEra era))
-> [Item (OSet (ProposalProcedure (ShelleyLedgerEra era)))]
forall a b. (a -> b) -> a -> b
$ TxProposalProcedures ViewTx era
-> OSet (ProposalProcedure (ShelleyLedgerEra era))
forall build era.
TxProposalProcedures build era
-> OSet (ProposalProcedure (ShelleyLedgerEra era))
convProposalProcedures TxProposalProcedures ViewTx era
pp
[Key
"governance actions" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (ConwayEraOnwards era
-> [ProposalProcedure (ShelleyLedgerEra era)] -> Value
forall era.
ConwayEraOnwards era
-> [ProposalProcedure (ShelleyLedgerEra era)] -> Value
friendlyLedgerProposals ConwayEraOnwards era
cOnwards [Item (OSet (ProposalProcedure (ShelleyLedgerEra era)))]
[ProposalProcedure (ShelleyLedgerEra era)]
lProposals)]
)
)
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ ( forall (eon :: * -> *) a era.
(Eon eon, Monoid a) =>
CardanoEra era -> (eon era -> a) -> a
monoidForEraInEon @ConwayEraOnwards
CardanoEra era
era
( \ConwayEraOnwards era
cOnwards ->
case Maybe
(Featured ConwayEraOnwards era (TxVotingProcedures ViewTx era))
txVotingProcedures of
Maybe
(Featured ConwayEraOnwards era (TxVotingProcedures ViewTx era))
Nothing -> []
Just (Featured ConwayEraOnwards era
_ TxVotingProcedures ViewTx era
TxVotingProceduresNone) -> []
Just (Featured ConwayEraOnwards era
_ (TxVotingProcedures VotingProcedures (ShelleyLedgerEra era)
votes BuildTxWith
ViewTx
(Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era))
_witnesses)) ->
[Key
"voters" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ConwayEraOnwards era
-> VotingProcedures (ShelleyLedgerEra era) -> Value
forall era.
ConwayEraOnwards era
-> VotingProcedures (ShelleyLedgerEra era) -> Value
friendlyVotingProcedures ConwayEraOnwards era
cOnwards VotingProcedures (ShelleyLedgerEra era)
votes]
)
)
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ ( forall (eon :: * -> *) a era.
(Eon eon, Monoid a) =>
CardanoEra era -> (eon era -> a) -> a
monoidForEraInEon @ConwayEraOnwards
CardanoEra era
era
([Pair] -> ConwayEraOnwards era -> [Pair]
forall a b. a -> b -> a
const [Key
"currentTreasuryValue" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe (Maybe Lovelace) -> Value
forall a. ToJSON a => a -> Value
toJSON (Featured ConwayEraOnwards era (Maybe Lovelace) -> Maybe Lovelace
forall (eon :: * -> *) era a. Featured eon era a -> a
unFeatured (Featured ConwayEraOnwards era (Maybe Lovelace) -> Maybe Lovelace)
-> Maybe (Featured ConwayEraOnwards era (Maybe Lovelace))
-> Maybe (Maybe Lovelace)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (Featured ConwayEraOnwards era (Maybe Lovelace))
txCurrentTreasuryValue)])
)
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ ( forall (eon :: * -> *) a era.
(Eon eon, Monoid a) =>
CardanoEra era -> (eon era -> a) -> a
monoidForEraInEon @ConwayEraOnwards
CardanoEra era
era
([Pair] -> ConwayEraOnwards era -> [Pair]
forall a b. a -> b -> a
const [Key
"treasuryDonation" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Lovelace -> Value
forall a. ToJSON a => a -> Value
toJSON (Featured ConwayEraOnwards era Lovelace -> Lovelace
forall (eon :: * -> *) era a. Featured eon era a -> a
unFeatured (Featured ConwayEraOnwards era Lovelace -> Lovelace)
-> Maybe (Featured ConwayEraOnwards era Lovelace) -> Maybe Lovelace
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (Featured ConwayEraOnwards era Lovelace)
txTreasuryDonation)])
)
)
where
friendlyLedgerProposals
:: ConwayEraOnwards era -> [L.ProposalProcedure (ShelleyLedgerEra era)] -> Aeson.Value
friendlyLedgerProposals :: forall era.
ConwayEraOnwards era
-> [ProposalProcedure (ShelleyLedgerEra era)] -> Value
friendlyLedgerProposals ConwayEraOnwards era
cOnwards [ProposalProcedure (ShelleyLedgerEra era)]
proposalProcedures =
Array -> Value
Array (Array -> Value) -> Array -> Value
forall a b. (a -> b) -> a -> b
$ [Item Array] -> Array
forall l. IsList l => [Item l] -> l
fromList ([Item Array] -> Array) -> [Item Array] -> Array
forall a b. (a -> b) -> a -> b
$ (ProposalProcedure (ShelleyLedgerEra era) -> Value)
-> [ProposalProcedure (ShelleyLedgerEra era)] -> [Value]
forall a b. (a -> b) -> [a] -> [b]
map (ConwayEraOnwards era
-> ProposalProcedure (ShelleyLedgerEra era) -> Value
forall era.
ConwayEraOnwards era
-> ProposalProcedure (ShelleyLedgerEra era) -> Value
friendlyLedgerProposal ConwayEraOnwards era
cOnwards) [ProposalProcedure (ShelleyLedgerEra era)]
proposalProcedures
friendlyLedgerProposal
:: ConwayEraOnwards era -> L.ProposalProcedure (ShelleyLedgerEra era) -> Aeson.Value
friendlyLedgerProposal :: forall era.
ConwayEraOnwards era
-> ProposalProcedure (ShelleyLedgerEra era) -> Value
friendlyLedgerProposal ConwayEraOnwards era
cOnwards ProposalProcedure (ShelleyLedgerEra era)
proposalProcedure = [Pair] -> Value
object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$ ConwayEraOnwards era -> Proposal era -> [Pair]
forall era. ConwayEraOnwards era -> Proposal era -> [Pair]
friendlyProposalImpl ConwayEraOnwards era
cOnwards (ProposalProcedure (ShelleyLedgerEra era) -> Proposal era
forall era.
ProposalProcedure (ShelleyLedgerEra era) -> Proposal era
Proposal ProposalProcedure (ShelleyLedgerEra era)
proposalProcedure)
friendlyVotingProcedures
:: ConwayEraOnwards era -> L.VotingProcedures (ShelleyLedgerEra era) -> Aeson.Value
friendlyVotingProcedures :: forall era.
ConwayEraOnwards era
-> VotingProcedures (ShelleyLedgerEra era) -> Value
friendlyVotingProcedures ConwayEraOnwards era
cOnwards VotingProcedures (ShelleyLedgerEra era)
x = ConwayEraOnwards era
-> (ConwayEraOnwardsConstraints era => Value) -> Value
forall era a.
ConwayEraOnwards era -> (ConwayEraOnwardsConstraints era => a) -> a
conwayEraOnwardsConstraints ConwayEraOnwards era
cOnwards ((ConwayEraOnwardsConstraints era => Value) -> Value)
-> (ConwayEraOnwardsConstraints era => Value) -> Value
forall a b. (a -> b) -> a -> b
$ VotingProcedures (ShelleyLedgerEra era) -> Value
forall a. ToJSON a => a -> Value
toJSON VotingProcedures (ShelleyLedgerEra era)
x
data EraIndependentPlutusScriptPurpose
= Spending
| Minting
| Certifying
| Rewarding
| Voting
| Proposing
getRedeemerDetails
:: forall era. AlonzoEraOnwards era -> TxBody era -> [Aeson.Pair]
getRedeemerDetails :: forall era. AlonzoEraOnwards era -> TxBody era -> [Pair]
getRedeemerDetails AlonzoEraOnwards era
aeo TxBody era
tb =
let ShelleyTx ShelleyBasedEra era
_ Tx (ShelleyLedgerEra era)
ledgerTx = [KeyWitness era] -> TxBody era -> Tx era
forall era. [KeyWitness era] -> TxBody era -> Tx era
makeSignedTransaction [] TxBody era
tb
in [Key
"redeemers" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Tx (ShelleyLedgerEra era) -> Value
friendlyRedeemers Tx (ShelleyLedgerEra era)
ledgerTx]
where
friendlyRedeemers
:: Ledger.Tx (ShelleyLedgerEra era)
-> Aeson.Value
friendlyRedeemers :: Tx (ShelleyLedgerEra era) -> Value
friendlyRedeemers Tx (ShelleyLedgerEra era)
tx =
AlonzoEraOnwards era
-> (AlonzoEraOnwardsConstraints era => Value) -> Value
forall era a.
AlonzoEraOnwards era -> (AlonzoEraOnwardsConstraints era => a) -> a
alonzoEraOnwardsConstraints AlonzoEraOnwards era
aeo ((AlonzoEraOnwardsConstraints era => Value) -> Value)
-> (AlonzoEraOnwardsConstraints era => Value) -> Value
forall a b. (a -> b) -> a -> b
$ do
let plutusScriptPurposeAndExUnits :: [(PlutusPurpose AsIx (ShelleyLedgerEra era),
(Data (ShelleyLedgerEra era), ExUnits))]
plutusScriptPurposeAndExUnits = Map
(PlutusPurpose AsIx (ShelleyLedgerEra era))
(Data (ShelleyLedgerEra era), ExUnits)
-> [(PlutusPurpose AsIx (ShelleyLedgerEra era),
(Data (ShelleyLedgerEra era), ExUnits))]
forall k a. Map k a -> [(k, a)]
Map.toList (Map
(PlutusPurpose AsIx (ShelleyLedgerEra era))
(Data (ShelleyLedgerEra era), ExUnits)
-> [(PlutusPurpose AsIx (ShelleyLedgerEra era),
(Data (ShelleyLedgerEra era), ExUnits))])
-> Map
(PlutusPurpose AsIx (ShelleyLedgerEra era))
(Data (ShelleyLedgerEra era), ExUnits)
-> [(PlutusPurpose AsIx (ShelleyLedgerEra era),
(Data (ShelleyLedgerEra era), ExUnits))]
forall a b. (a -> b) -> a -> b
$ Redeemers (ShelleyLedgerEra era)
-> Map
(PlutusPurpose AsIx (ShelleyLedgerEra era))
(Data (ShelleyLedgerEra era), ExUnits)
forall era.
Redeemers era -> Map (PlutusPurpose AsIx era) (Data era, ExUnits)
Ledger.unRedeemers (Redeemers (ShelleyLedgerEra era)
-> Map
(PlutusPurpose AsIx (ShelleyLedgerEra era))
(Data (ShelleyLedgerEra era), ExUnits))
-> Redeemers (ShelleyLedgerEra era)
-> Map
(PlutusPurpose AsIx (ShelleyLedgerEra era))
(Data (ShelleyLedgerEra era), ExUnits)
forall a b. (a -> b) -> a -> b
$ Tx (ShelleyLedgerEra era)
tx Tx (ShelleyLedgerEra era)
-> Getting
(Redeemers (ShelleyLedgerEra era))
(Tx (ShelleyLedgerEra era))
(Redeemers (ShelleyLedgerEra era))
-> Redeemers (ShelleyLedgerEra era)
forall s a. s -> Getting a s a -> a
^. (TxWits (ShelleyLedgerEra era)
-> Const
(Redeemers (ShelleyLedgerEra era)) (TxWits (ShelleyLedgerEra era)))
-> Tx (ShelleyLedgerEra era)
-> Const
(Redeemers (ShelleyLedgerEra era)) (Tx (ShelleyLedgerEra era))
forall era. EraTx era => Lens' (Tx era) (TxWits era)
Lens' (Tx (ShelleyLedgerEra era)) (TxWits (ShelleyLedgerEra era))
Ledger.witsTxL ((TxWits (ShelleyLedgerEra era)
-> Const
(Redeemers (ShelleyLedgerEra era)) (TxWits (ShelleyLedgerEra era)))
-> Tx (ShelleyLedgerEra era)
-> Const
(Redeemers (ShelleyLedgerEra era)) (Tx (ShelleyLedgerEra era)))
-> ((Redeemers (ShelleyLedgerEra era)
-> Const
(Redeemers (ShelleyLedgerEra era))
(Redeemers (ShelleyLedgerEra era)))
-> TxWits (ShelleyLedgerEra era)
-> Const
(Redeemers (ShelleyLedgerEra era)) (TxWits (ShelleyLedgerEra era)))
-> Getting
(Redeemers (ShelleyLedgerEra era))
(Tx (ShelleyLedgerEra era))
(Redeemers (ShelleyLedgerEra era))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Redeemers (ShelleyLedgerEra era)
-> Const
(Redeemers (ShelleyLedgerEra era))
(Redeemers (ShelleyLedgerEra era)))
-> TxWits (ShelleyLedgerEra era)
-> Const
(Redeemers (ShelleyLedgerEra era)) (TxWits (ShelleyLedgerEra era))
forall era.
AlonzoEraTxWits era =>
Lens' (TxWits era) (Redeemers era)
Lens'
(TxWits (ShelleyLedgerEra era)) (Redeemers (ShelleyLedgerEra era))
Ledger.rdmrsTxWitsL
redeemerList :: [Value]
redeemerList = ((PlutusPurpose AsIx (ShelleyLedgerEra era),
(Data (ShelleyLedgerEra era), ExUnits))
-> Value)
-> [(PlutusPurpose AsIx (ShelleyLedgerEra era),
(Data (ShelleyLedgerEra era), ExUnits))]
-> [Value]
forall a b. (a -> b) -> [a] -> [b]
map ((PlutusPurpose AsIx (ShelleyLedgerEra era)
-> (Data (ShelleyLedgerEra era), ExUnits) -> Value)
-> (PlutusPurpose AsIx (ShelleyLedgerEra era),
(Data (ShelleyLedgerEra era), ExUnits))
-> Value
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry ((PlutusPurpose AsIx (ShelleyLedgerEra era)
-> (Data (ShelleyLedgerEra era), ExUnits) -> Value)
-> (PlutusPurpose AsIx (ShelleyLedgerEra era),
(Data (ShelleyLedgerEra era), ExUnits))
-> Value)
-> (PlutusPurpose AsIx (ShelleyLedgerEra era)
-> (Data (ShelleyLedgerEra era), ExUnits) -> Value)
-> (PlutusPurpose AsIx (ShelleyLedgerEra era),
(Data (ShelleyLedgerEra era), ExUnits))
-> Value
forall a b. (a -> b) -> a -> b
$ Tx (ShelleyLedgerEra era)
-> PlutusPurpose AsIx (ShelleyLedgerEra era)
-> (Data (ShelleyLedgerEra era), ExUnits)
-> Value
friendlyRedeemerInfo Tx (ShelleyLedgerEra era)
tx) [(PlutusPurpose AsIx (ShelleyLedgerEra era),
(Data (ShelleyLedgerEra era), ExUnits))]
plutusScriptPurposeAndExUnits
Array -> Value
Aeson.Array (Array -> Value) -> Array -> Value
forall a b. (a -> b) -> a -> b
$ [Value] -> Array
forall a. [a] -> Vector a
Vector.fromList [Value]
redeemerList
friendlyRedeemerInfo
:: Ledger.Tx (ShelleyLedgerEra era)
-> Ledger.PlutusPurpose Ledger.AsIx (ShelleyLedgerEra era)
-> (Ledger.Data (ShelleyLedgerEra era), ExUnits)
-> Aeson.Value
friendlyRedeemerInfo :: Tx (ShelleyLedgerEra era)
-> PlutusPurpose AsIx (ShelleyLedgerEra era)
-> (Data (ShelleyLedgerEra era), ExUnits)
-> Value
friendlyRedeemerInfo Tx (ShelleyLedgerEra era)
tx PlutusPurpose AsIx (ShelleyLedgerEra era)
redeemerPurpose (Data (ShelleyLedgerEra era)
redeemerData, ExUnits
exUnits) =
AlonzoEraOnwards era
-> (AlonzoEraOnwardsConstraints era => Value) -> Value
forall era a.
AlonzoEraOnwards era -> (AlonzoEraOnwardsConstraints era => a) -> a
alonzoEraOnwardsConstraints AlonzoEraOnwards era
aeo ((AlonzoEraOnwardsConstraints era => Value) -> Value)
-> (AlonzoEraOnwardsConstraints era => Value) -> Value
forall a b. (a -> b) -> a -> b
$ do
let inputNotFoundError :: Value
inputNotFoundError =
[Pair] -> Value
Aeson.object
[ Key
"error" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
Aeson.String ([Char] -> Text
T.pack ([Char] -> Text) -> [Char] -> Text
forall a b. (a -> b) -> a -> b
$ [Char]
"Could not find corresponding input to " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ PlutusPurpose AsIx (ShelleyLedgerEra era) -> [Char]
forall a. Show a => a -> [Char]
show PlutusPurpose AsIx (ShelleyLedgerEra era)
redeemerPurpose)
]
mCorrespondingInput :: Maybe (PlutusPurpose AsIxItem (ShelleyLedgerEra era))
mCorrespondingInput = StrictMaybe (PlutusPurpose AsIxItem (ShelleyLedgerEra era))
-> Maybe (PlutusPurpose AsIxItem (ShelleyLedgerEra era))
forall a. StrictMaybe a -> Maybe a
strictMaybeToMaybe (StrictMaybe (PlutusPurpose AsIxItem (ShelleyLedgerEra era))
-> Maybe (PlutusPurpose AsIxItem (ShelleyLedgerEra era)))
-> StrictMaybe (PlutusPurpose AsIxItem (ShelleyLedgerEra era))
-> Maybe (PlutusPurpose AsIxItem (ShelleyLedgerEra era))
forall a b. (a -> b) -> a -> b
$ TxBody (ShelleyLedgerEra era)
-> PlutusPurpose AsIx (ShelleyLedgerEra era)
-> StrictMaybe (PlutusPurpose AsIxItem (ShelleyLedgerEra era))
forall era.
AlonzoEraTxBody era =>
TxBody era
-> PlutusPurpose AsIx era
-> StrictMaybe (PlutusPurpose AsIxItem era)
Ledger.redeemerPointerInverse (Tx (ShelleyLedgerEra era)
tx Tx (ShelleyLedgerEra era)
-> Getting
(TxBody (ShelleyLedgerEra era))
(Tx (ShelleyLedgerEra era))
(TxBody (ShelleyLedgerEra era))
-> TxBody (ShelleyLedgerEra era)
forall s a. s -> Getting a s a -> a
^. Getting
(TxBody (ShelleyLedgerEra era))
(Tx (ShelleyLedgerEra era))
(TxBody (ShelleyLedgerEra era))
forall era. EraTx era => Lens' (Tx era) (TxBody era)
Lens' (Tx (ShelleyLedgerEra era)) (TxBody (ShelleyLedgerEra era))
Ledger.bodyTxL) PlutusPurpose AsIx (ShelleyLedgerEra era)
redeemerPurpose
mFriendlyPurposeResult :: Maybe Value
mFriendlyPurposeResult = AlonzoEraOnwards era
-> PlutusPurpose AsIxItem (ShelleyLedgerEra era) -> Value
friendlyPurpose AlonzoEraOnwards era
aeo (PlutusPurpose AsIxItem (ShelleyLedgerEra era) -> Value)
-> Maybe (PlutusPurpose AsIxItem (ShelleyLedgerEra era))
-> Maybe Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (PlutusPurpose AsIxItem (ShelleyLedgerEra era))
mCorrespondingInput
in [Pair] -> Value
object
[ Key
"purpose" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Value -> Maybe Value -> Value
forall a. a -> Maybe a -> a
fromMaybe Value
inputNotFoundError Maybe Value
mFriendlyPurposeResult
, Key
"redeemer" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Data (ShelleyLedgerEra era) -> ExUnits -> Value
friendlyRedeemer Data (ShelleyLedgerEra era)
redeemerData ExUnits
exUnits
]
friendlyRedeemer :: Ledger.Data (ShelleyLedgerEra era) -> ExUnits -> Aeson.Value
friendlyRedeemer :: Data (ShelleyLedgerEra era) -> ExUnits -> Value
friendlyRedeemer Data (ShelleyLedgerEra era)
scriptData ExUnits{exUnitsSteps :: ExUnits -> Natural
exUnitsSteps = Natural
exSteps, exUnitsMem :: ExUnits -> Natural
exUnitsMem = Natural
exMemUnits} =
[Pair] -> Value
object
[ Key
"data" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
Aeson.String ([Char] -> Text
T.pack ([Char] -> Text) -> [Char] -> Text
forall a b. (a -> b) -> a -> b
$ Data -> [Char]
forall a. Show a => a -> [Char]
show (Data -> [Char]) -> Data -> [Char]
forall a b. (a -> b) -> a -> b
$ Data (ShelleyLedgerEra era) -> Data
forall era. Data era -> Data
Ledger.unData Data (ShelleyLedgerEra era)
scriptData)
, Key
"execution units"
Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object
[ Key
"steps" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Scientific -> Value
Aeson.Number (Natural -> Scientific
forall a b. (Integral a, Num b) => a -> b
fromIntegral Natural
exSteps)
, Key
"memory" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Scientific -> Value
Aeson.Number (Natural -> Scientific
forall a b. (Integral a, Num b) => a -> b
fromIntegral Natural
exMemUnits)
]
]
friendlyPurpose
:: AlonzoEraOnwards era -> Ledger.PlutusPurpose L.AsIxItem (ShelleyLedgerEra era) -> Aeson.Value
friendlyPurpose :: AlonzoEraOnwards era
-> PlutusPurpose AsIxItem (ShelleyLedgerEra era) -> Value
friendlyPurpose AlonzoEraOnwards era
AlonzoEraOnwardsAlonzo PlutusPurpose AsIxItem (ShelleyLedgerEra era)
purpose =
case PlutusPurpose AsIxItem (ShelleyLedgerEra era)
purpose of
Ledger.AlonzoSpending (L.AsIxItem Word32
_ TxIn StandardCrypto
sp) -> EraIndependentPlutusScriptPurpose -> Value -> Value
forall v.
ToJSON v =>
EraIndependentPlutusScriptPurpose -> v -> Value
addLabelToPurpose EraIndependentPlutusScriptPurpose
Spending (TxIn StandardCrypto -> Value
friendlyInput TxIn StandardCrypto
sp)
Ledger.AlonzoMinting (L.AsIxItem Word32
_ PolicyID StandardCrypto
mp) -> EraIndependentPlutusScriptPurpose
-> PolicyID StandardCrypto -> Value
forall v.
ToJSON v =>
EraIndependentPlutusScriptPurpose -> v -> Value
addLabelToPurpose EraIndependentPlutusScriptPurpose
Minting PolicyID StandardCrypto
mp
Ledger.AlonzoCertifying (L.AsIxItem Word32
_ ShelleyTxCert (AlonzoEra StandardCrypto)
cp) -> EraIndependentPlutusScriptPurpose
-> ShelleyTxCert (AlonzoEra StandardCrypto) -> Value
forall v.
ToJSON v =>
EraIndependentPlutusScriptPurpose -> v -> Value
addLabelToPurpose EraIndependentPlutusScriptPurpose
Certifying ShelleyTxCert (AlonzoEra StandardCrypto)
cp
Ledger.AlonzoRewarding (L.AsIxItem Word32
_ RewardAccount StandardCrypto
rp) -> EraIndependentPlutusScriptPurpose
-> RewardAccount StandardCrypto -> Value
forall v.
ToJSON v =>
EraIndependentPlutusScriptPurpose -> v -> Value
addLabelToPurpose EraIndependentPlutusScriptPurpose
Rewarding RewardAccount StandardCrypto
rp
friendlyPurpose AlonzoEraOnwards era
AlonzoEraOnwardsBabbage PlutusPurpose AsIxItem (ShelleyLedgerEra era)
purpose =
case PlutusPurpose AsIxItem (ShelleyLedgerEra era)
purpose of
Ledger.AlonzoSpending (L.AsIxItem Word32
_ TxIn StandardCrypto
sp) -> EraIndependentPlutusScriptPurpose -> Value -> Value
forall v.
ToJSON v =>
EraIndependentPlutusScriptPurpose -> v -> Value
addLabelToPurpose EraIndependentPlutusScriptPurpose
Spending (TxIn StandardCrypto -> Value
friendlyInput TxIn StandardCrypto
sp)
Ledger.AlonzoMinting (L.AsIxItem Word32
_ PolicyID StandardCrypto
mp) -> EraIndependentPlutusScriptPurpose
-> PolicyID StandardCrypto -> Value
forall v.
ToJSON v =>
EraIndependentPlutusScriptPurpose -> v -> Value
addLabelToPurpose EraIndependentPlutusScriptPurpose
Minting PolicyID StandardCrypto
mp
Ledger.AlonzoCertifying (L.AsIxItem Word32
_ ShelleyTxCert (BabbageEra StandardCrypto)
cp) -> EraIndependentPlutusScriptPurpose
-> ShelleyTxCert (BabbageEra StandardCrypto) -> Value
forall v.
ToJSON v =>
EraIndependentPlutusScriptPurpose -> v -> Value
addLabelToPurpose EraIndependentPlutusScriptPurpose
Certifying ShelleyTxCert (BabbageEra StandardCrypto)
cp
Ledger.AlonzoRewarding (L.AsIxItem Word32
_ RewardAccount StandardCrypto
rp) -> EraIndependentPlutusScriptPurpose
-> RewardAccount StandardCrypto -> Value
forall v.
ToJSON v =>
EraIndependentPlutusScriptPurpose -> v -> Value
addLabelToPurpose EraIndependentPlutusScriptPurpose
Rewarding RewardAccount StandardCrypto
rp
friendlyPurpose AlonzoEraOnwards era
AlonzoEraOnwardsConway PlutusPurpose AsIxItem (ShelleyLedgerEra era)
purpose =
case PlutusPurpose AsIxItem (ShelleyLedgerEra era)
purpose of
Ledger.ConwaySpending (L.AsIxItem Word32
_ TxIn StandardCrypto
sp) -> EraIndependentPlutusScriptPurpose -> Value -> Value
forall v.
ToJSON v =>
EraIndependentPlutusScriptPurpose -> v -> Value
addLabelToPurpose EraIndependentPlutusScriptPurpose
Spending (TxIn StandardCrypto -> Value
friendlyInput TxIn StandardCrypto
sp)
Ledger.ConwayMinting (L.AsIxItem Word32
_ PolicyID StandardCrypto
mp) -> EraIndependentPlutusScriptPurpose
-> PolicyID StandardCrypto -> Value
forall v.
ToJSON v =>
EraIndependentPlutusScriptPurpose -> v -> Value
addLabelToPurpose EraIndependentPlutusScriptPurpose
Minting PolicyID StandardCrypto
mp
Ledger.ConwayCertifying (L.AsIxItem Word32
_ ConwayTxCert (ConwayEra StandardCrypto)
cp) -> EraIndependentPlutusScriptPurpose
-> ConwayTxCert (ConwayEra StandardCrypto) -> Value
forall v.
ToJSON v =>
EraIndependentPlutusScriptPurpose -> v -> Value
addLabelToPurpose EraIndependentPlutusScriptPurpose
Certifying ConwayTxCert (ConwayEra StandardCrypto)
cp
Ledger.ConwayRewarding (L.AsIxItem Word32
_ RewardAccount StandardCrypto
rp) -> EraIndependentPlutusScriptPurpose
-> RewardAccount StandardCrypto -> Value
forall v.
ToJSON v =>
EraIndependentPlutusScriptPurpose -> v -> Value
addLabelToPurpose EraIndependentPlutusScriptPurpose
Rewarding RewardAccount StandardCrypto
rp
Ledger.ConwayVoting (L.AsIxItem Word32
_ Voter StandardCrypto
vp) -> EraIndependentPlutusScriptPurpose -> Voter StandardCrypto -> Value
forall v.
ToJSON v =>
EraIndependentPlutusScriptPurpose -> v -> Value
addLabelToPurpose EraIndependentPlutusScriptPurpose
Voting Voter StandardCrypto
vp
Ledger.ConwayProposing (L.AsIxItem Word32
_ ProposalProcedure (ConwayEra StandardCrypto)
pp) -> EraIndependentPlutusScriptPurpose
-> ProposalProcedure (ConwayEra StandardCrypto) -> Value
forall v.
ToJSON v =>
EraIndependentPlutusScriptPurpose -> v -> Value
addLabelToPurpose EraIndependentPlutusScriptPurpose
Proposing ProposalProcedure (ConwayEra StandardCrypto)
pp
friendlyInput :: Ledger.TxIn Ledger.StandardCrypto -> Aeson.Value
friendlyInput :: TxIn StandardCrypto -> Value
friendlyInput (Ledger.TxIn (Ledger.TxId SafeHash StandardCrypto EraIndependentTxBody
txidHash) TxIx
ix) =
Text -> Value
Aeson.String (Text -> Value) -> Text -> Value
forall a b. (a -> b) -> a -> b
$
[Char] -> Text
T.pack ([Char] -> Text) -> [Char] -> Text
forall a b. (a -> b) -> a -> b
$
Text -> [Char]
T.unpack (Hash Blake2b_256 EraIndependentTxBody -> Text
forall h a. Hash h a -> Text
hashToTextAsHex (SafeHash StandardCrypto EraIndependentTxBody
-> Hash StandardCrypto EraIndependentTxBody
forall c i. SafeHash c i -> Hash (HASH c) i
extractHash SafeHash StandardCrypto EraIndependentTxBody
txidHash)) [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
"#" [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ Int -> [Char]
forall a. Show a => a -> [Char]
show (TxIx -> Int
Ledger.txIxToInt TxIx
ix)
addLabelToPurpose :: ToJSON v => EraIndependentPlutusScriptPurpose -> v -> Aeson.Value
addLabelToPurpose :: forall v.
ToJSON v =>
EraIndependentPlutusScriptPurpose -> v -> Value
addLabelToPurpose EraIndependentPlutusScriptPurpose
Spending v
sp = [Pair] -> Value
Aeson.object [Key
"spending script witnessed input" Key -> v -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= v
sp]
addLabelToPurpose EraIndependentPlutusScriptPurpose
Minting v
mp = [Pair] -> Value
Aeson.object [Key
"minting currency with policy id" Key -> v -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= v
mp]
addLabelToPurpose EraIndependentPlutusScriptPurpose
Certifying v
cp = [Pair] -> Value
Aeson.object [Key
"validating certificate with script credentials" Key -> v -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= v
cp]
addLabelToPurpose EraIndependentPlutusScriptPurpose
Rewarding v
rp = [Pair] -> Value
Aeson.object [Key
"withdrawing reward from script address" Key -> v -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= v
rp]
addLabelToPurpose EraIndependentPlutusScriptPurpose
Voting v
vp = [Pair] -> Value
Aeson.object [Key
"voting using script protected voter credentials" Key -> v -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= v
vp]
addLabelToPurpose EraIndependentPlutusScriptPurpose
Proposing v
pp = [Pair] -> Value
Aeson.object [Key
"submitting a proposal following proposal policy" Key -> v -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= v
pp]
friendlyTotalCollateral :: TxTotalCollateral era -> Aeson.Value
friendlyTotalCollateral :: forall era. TxTotalCollateral era -> Value
friendlyTotalCollateral TxTotalCollateral era
TxTotalCollateralNone = Value
Aeson.Null
friendlyTotalCollateral (TxTotalCollateral BabbageEraOnwards era
_ Lovelace
coll) = Lovelace -> Value
forall a. ToJSON a => a -> Value
toJSON Lovelace
coll
friendlyReturnCollateral
:: ()
=> CardanoEra era
-> TxReturnCollateral CtxTx era
-> Aeson.Value
friendlyReturnCollateral :: forall era. CardanoEra era -> TxReturnCollateral CtxTx era -> Value
friendlyReturnCollateral CardanoEra era
era = \case
TxReturnCollateral CtxTx era
TxReturnCollateralNone -> Value
Aeson.Null
TxReturnCollateral BabbageEraOnwards era
_ TxOut CtxTx era
collOut -> CardanoEra era -> TxOut CtxTx era -> Value
forall era. CardanoEra era -> TxOut CtxTx era -> Value
friendlyTxOut CardanoEra era
era TxOut CtxTx era
collOut
friendlyExtraKeyWits :: TxExtraKeyWitnesses era -> Aeson.Value
= \case
TxExtraKeyWitnesses era
TxExtraKeyWitnessesNone -> Value
Null
TxExtraKeyWitnesses AlonzoEraOnwards era
_supported [Hash PaymentKey]
paymentKeyHashes -> [Hash PaymentKey] -> Value
forall a. ToJSON a => a -> Value
toJSON [Hash PaymentKey]
paymentKeyHashes
friendlyValidityRange
:: CardanoEra era
-> (TxValidityLowerBound era, TxValidityUpperBound era)
-> Aeson.Value
friendlyValidityRange :: forall era.
CardanoEra era
-> (TxValidityLowerBound era, TxValidityUpperBound era) -> Value
friendlyValidityRange CardanoEra era
era = \case
(TxValidityLowerBound era
lowerBound, TxValidityUpperBound era
upperBound)
| Bool
isLowerBoundSupported Bool -> Bool -> Bool
|| Bool
isUpperBoundSupported ->
[Pair] -> Value
object
[ Key
"lower bound"
Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= case TxValidityLowerBound era
lowerBound of
TxValidityLowerBound era
TxValidityNoLowerBound -> Value
Null
TxValidityLowerBound AllegraEraOnwards era
_ SlotNo
s -> SlotNo -> Value
forall a. ToJSON a => a -> Value
toJSON SlotNo
s
, Key
"upper bound"
Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= case TxValidityUpperBound era
upperBound of
TxValidityUpperBound ShelleyBasedEra era
_ Maybe SlotNo
s -> Maybe SlotNo -> Value
forall a. ToJSON a => a -> Value
toJSON Maybe SlotNo
s
]
| Bool
otherwise -> Value
Null
where
isLowerBoundSupported :: Bool
isLowerBoundSupported = Maybe (SlotNo -> TxValidityLowerBound era) -> Bool
forall a. Maybe a -> Bool
isJust (Maybe (SlotNo -> TxValidityLowerBound era) -> Bool)
-> Maybe (SlotNo -> TxValidityLowerBound era) -> Bool
forall a b. (a -> b) -> a -> b
$ (AllegraEraOnwards era -> SlotNo -> TxValidityLowerBound era)
-> CardanoEra era -> Maybe (SlotNo -> TxValidityLowerBound era)
forall (eon :: * -> *) era a.
Eon eon =>
(eon era -> a) -> CardanoEra era -> Maybe a
inEonForEraMaybe AllegraEraOnwards era -> SlotNo -> TxValidityLowerBound era
forall era.
AllegraEraOnwards era -> SlotNo -> TxValidityLowerBound era
TxValidityLowerBound CardanoEra era
era
isUpperBoundSupported :: Bool
isUpperBoundSupported = Maybe (Maybe SlotNo -> TxValidityUpperBound era) -> Bool
forall a. Maybe a -> Bool
isJust (Maybe (Maybe SlotNo -> TxValidityUpperBound era) -> Bool)
-> Maybe (Maybe SlotNo -> TxValidityUpperBound era) -> Bool
forall a b. (a -> b) -> a -> b
$ (ShelleyBasedEra era -> Maybe SlotNo -> TxValidityUpperBound era)
-> CardanoEra era
-> Maybe (Maybe SlotNo -> TxValidityUpperBound era)
forall (eon :: * -> *) era a.
Eon eon =>
(eon era -> a) -> CardanoEra era -> Maybe a
inEonForEraMaybe ShelleyBasedEra era -> Maybe SlotNo -> TxValidityUpperBound era
forall era.
ShelleyBasedEra era -> Maybe SlotNo -> TxValidityUpperBound era
TxValidityUpperBound CardanoEra era
era
friendlyWithdrawals :: TxWithdrawals ViewTx era -> Aeson.Value
friendlyWithdrawals :: forall era. TxWithdrawals ViewTx era -> Value
friendlyWithdrawals TxWithdrawals ViewTx era
TxWithdrawalsNone = Value
Null
friendlyWithdrawals (TxWithdrawals ShelleyBasedEra era
_ [(StakeAddress, Lovelace,
BuildTxWith ViewTx (Witness WitCtxStake era))]
withdrawals) =
[Value] -> Value
array
[ [Pair] -> Value
object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$
Key
"address" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= StakeAddress -> Text
forall addr. SerialiseAddress addr => addr -> Text
serialiseAddress StakeAddress
addr
Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Key
"amount" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Lovelace -> Value
friendlyLovelace Lovelace
amount
Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: StakeAddress -> [Pair]
friendlyStakeAddress StakeAddress
addr
| (StakeAddress
addr, Lovelace
amount, BuildTxWith ViewTx (Witness WitCtxStake era)
_) <- [(StakeAddress, Lovelace,
BuildTxWith ViewTx (Witness WitCtxStake era))]
withdrawals
]
friendlyStakeAddress :: StakeAddress -> [Aeson.Pair]
friendlyStakeAddress :: StakeAddress -> [Pair]
friendlyStakeAddress (StakeAddress Network
net StakeCredential StandardCrypto
cred) =
[ Key
"network" Key -> Network -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Network
net
, StakeCredential StandardCrypto -> Pair
friendlyStakeCredential StakeCredential StandardCrypto
cred
]
friendlyTxOut :: CardanoEra era -> TxOut CtxTx era -> Aeson.Value
friendlyTxOut :: forall era. CardanoEra era -> TxOut CtxTx era -> Value
friendlyTxOut CardanoEra era
era (TxOut AddressInEra era
addr TxOutValue era
amount TxOutDatum CtxTx era
mdatum ReferenceScript era
script) =
CardanoEra era -> (CardanoEraConstraints era => Value) -> Value
forall era a.
CardanoEra era -> (CardanoEraConstraints era => a) -> a
cardanoEraConstraints CardanoEra era
era ((CardanoEraConstraints era => Value) -> Value)
-> (CardanoEraConstraints era => Value) -> Value
forall a b. (a -> b) -> a -> b
$
[Pair] -> Value
object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$
case AddressInEra era
addr of
AddressInEra AddressTypeInEra addrtype era
ByronAddressInAnyEra Address addrtype
byronAdr ->
[ Key
"address era" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"Byron"
, Key
"address" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Address addrtype -> Text
forall addr. SerialiseAddress addr => addr -> Text
serialiseAddress Address addrtype
byronAdr
, Key
"amount" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TxOutValue era -> Value
forall era. TxOutValue era -> Value
friendlyTxOutValue TxOutValue era
amount
]
AddressInEra (ShelleyAddressInEra ShelleyBasedEra era
_) saddr :: Address addrtype
saddr@(ShelleyAddress Network
net PaymentCredential StandardCrypto
cred StakeReference StandardCrypto
stake) ->
let preAlonzo :: [Pair]
preAlonzo =
PaymentCredential -> Pair
friendlyPaymentCredential (PaymentCredential StandardCrypto -> PaymentCredential
fromShelleyPaymentCredential PaymentCredential StandardCrypto
cred)
Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [ Key
"address era" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
Aeson.String Text
"Shelley"
, Key
"network" Key -> Network -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Network
net
, Key
"address" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Address addrtype -> Text
forall addr. SerialiseAddress addr => addr -> Text
serialiseAddress Address addrtype
saddr
, Key
"amount" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TxOutValue era -> Value
forall era. TxOutValue era -> Value
friendlyTxOutValue TxOutValue era
amount
, Key
"stake reference" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= StakeAddressReference -> Value
friendlyStakeReference (StakeReference StandardCrypto -> StakeAddressReference
fromShelleyStakeReference StakeReference StandardCrypto
stake)
]
datum :: [Pair]
datum = [Key
"datum" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Value
d | Value
d <- Maybe Value -> [Value]
forall a. Maybe a -> [a]
maybeToList (Maybe Value -> [Value]) -> Maybe Value -> [Value]
forall a b. (a -> b) -> a -> b
$ TxOutDatum CtxTx era -> Maybe Value
forall era. TxOutDatum CtxTx era -> Maybe Value
renderDatum TxOutDatum CtxTx era
mdatum]
sinceAlonzo :: [Pair]
sinceAlonzo = [Key
"reference script" Key -> ReferenceScript era -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ReferenceScript era
script]
in [Pair]
preAlonzo [Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ [Pair]
datum [Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ [Pair]
sinceAlonzo
where
renderDatum :: TxOutDatum CtxTx era -> Maybe Aeson.Value
renderDatum :: forall era. TxOutDatum CtxTx era -> Maybe Value
renderDatum = \case
TxOutDatum CtxTx era
TxOutDatumNone -> Maybe Value
forall a. Maybe a
Nothing
TxOutDatumHash AlonzoEraOnwards era
_ Hash ScriptData
h -> Value -> Maybe Value
forall a. a -> Maybe a
Just (Value -> Maybe Value) -> Value -> Maybe Value
forall a b. (a -> b) -> a -> b
$ Hash ScriptData -> Value
forall a. ToJSON a => a -> Value
toJSON Hash ScriptData
h
TxOutSupplementalDatum AlonzoEraOnwards era
_ HashableScriptData
sData -> Value -> Maybe Value
forall a. a -> Maybe a
Just (Value -> Maybe Value) -> Value -> Maybe Value
forall a b. (a -> b) -> a -> b
$ ScriptDataJsonSchema -> HashableScriptData -> Value
scriptDataToJson ScriptDataJsonSchema
ScriptDataJsonDetailedSchema HashableScriptData
sData
TxOutDatumInline BabbageEraOnwards era
_ HashableScriptData
sData -> Value -> Maybe Value
forall a. a -> Maybe a
Just (Value -> Maybe Value) -> Value -> Maybe Value
forall a b. (a -> b) -> a -> b
$ ScriptDataJsonSchema -> HashableScriptData -> Value
scriptDataToJson ScriptDataJsonSchema
ScriptDataJsonDetailedSchema HashableScriptData
sData
friendlyStakeReference :: StakeAddressReference -> Aeson.Value
friendlyStakeReference :: StakeAddressReference -> Value
friendlyStakeReference = \case
StakeAddressReference
NoStakeAddress -> Value
Null
StakeAddressByPointer StakeAddressPointer
ptr -> Text -> Value
String (StakeAddressPointer -> Text
forall a. Show a => a -> Text
textShow StakeAddressPointer
ptr)
StakeAddressByValue StakeCredential
cred -> [Pair] -> Value
object [StakeCredential StandardCrypto -> Pair
friendlyStakeCredential (StakeCredential StandardCrypto -> Pair)
-> StakeCredential StandardCrypto -> Pair
forall a b. (a -> b) -> a -> b
$ StakeCredential -> StakeCredential StandardCrypto
toShelleyStakeCredential StakeCredential
cred]
friendlyUpdateProposal :: TxUpdateProposal era -> Aeson.Value
friendlyUpdateProposal :: forall era. TxUpdateProposal era -> Value
friendlyUpdateProposal = \case
TxUpdateProposal era
TxUpdateProposalNone -> Value
Null
TxUpdateProposal ShelleyToBabbageEra era
_ (UpdateProposal Map (Hash GenesisKey) ProtocolParametersUpdate
parameterUpdates EpochNo
epoch) ->
[Pair] -> Value
object
[ Key
"epoch" Key -> EpochNo -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= EpochNo
epoch
, Key
"updates"
Key -> [Value] -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [ [Pair] -> Value
object
[ Key
"genesis key hash" Key -> Hash GenesisKey -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Hash GenesisKey
genesisKeyHash
, Key
"update" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ProtocolParametersUpdate -> Value
friendlyProtocolParametersUpdate ProtocolParametersUpdate
parameterUpdate
]
| (Hash GenesisKey
genesisKeyHash, ProtocolParametersUpdate
parameterUpdate) <- Map (Hash GenesisKey) ProtocolParametersUpdate
-> [(Hash GenesisKey, ProtocolParametersUpdate)]
forall k a. Map k a -> [(k, a)]
Map.assocs Map (Hash GenesisKey) ProtocolParametersUpdate
parameterUpdates
]
]
friendlyProtocolParametersUpdate :: ProtocolParametersUpdate -> Aeson.Value
friendlyProtocolParametersUpdate :: ProtocolParametersUpdate -> Value
friendlyProtocolParametersUpdate
ProtocolParametersUpdate
{ Maybe (Natural, Natural)
protocolUpdateProtocolVersion :: Maybe (Natural, Natural)
protocolUpdateProtocolVersion :: ProtocolParametersUpdate -> Maybe (Natural, Natural)
protocolUpdateProtocolVersion
, Maybe Rational
protocolUpdateDecentralization :: Maybe Rational
protocolUpdateDecentralization :: ProtocolParametersUpdate -> Maybe Rational
protocolUpdateDecentralization
, Maybe (Maybe PraosNonce)
protocolUpdateExtraPraosEntropy :: Maybe (Maybe PraosNonce)
protocolUpdateExtraPraosEntropy :: ProtocolParametersUpdate -> Maybe (Maybe PraosNonce)
protocolUpdateExtraPraosEntropy
, Maybe Word16
protocolUpdateMaxBlockHeaderSize :: Maybe Word16
protocolUpdateMaxBlockHeaderSize :: ProtocolParametersUpdate -> Maybe Word16
protocolUpdateMaxBlockHeaderSize
, Maybe Word32
protocolUpdateMaxBlockBodySize :: Maybe Word32
protocolUpdateMaxBlockBodySize :: ProtocolParametersUpdate -> Maybe Word32
protocolUpdateMaxBlockBodySize
, Maybe Word32
protocolUpdateMaxTxSize :: Maybe Word32
protocolUpdateMaxTxSize :: ProtocolParametersUpdate -> Maybe Word32
protocolUpdateMaxTxSize
, Maybe Lovelace
protocolUpdateTxFeeFixed :: Maybe Lovelace
protocolUpdateTxFeeFixed :: ProtocolParametersUpdate -> Maybe Lovelace
protocolUpdateTxFeeFixed
, Maybe Lovelace
protocolUpdateTxFeePerByte :: Maybe Lovelace
protocolUpdateTxFeePerByte :: ProtocolParametersUpdate -> Maybe Lovelace
protocolUpdateTxFeePerByte
, Maybe Lovelace
protocolUpdateMinUTxOValue :: Maybe Lovelace
protocolUpdateMinUTxOValue :: ProtocolParametersUpdate -> Maybe Lovelace
protocolUpdateMinUTxOValue
, Maybe Lovelace
protocolUpdateStakeAddressDeposit :: Maybe Lovelace
protocolUpdateStakeAddressDeposit :: ProtocolParametersUpdate -> Maybe Lovelace
protocolUpdateStakeAddressDeposit
, Maybe Lovelace
protocolUpdateStakePoolDeposit :: Maybe Lovelace
protocolUpdateStakePoolDeposit :: ProtocolParametersUpdate -> Maybe Lovelace
protocolUpdateStakePoolDeposit
, Maybe Lovelace
protocolUpdateMinPoolCost :: Maybe Lovelace
protocolUpdateMinPoolCost :: ProtocolParametersUpdate -> Maybe Lovelace
protocolUpdateMinPoolCost
, Maybe EpochInterval
protocolUpdatePoolRetireMaxEpoch :: Maybe EpochInterval
protocolUpdatePoolRetireMaxEpoch :: ProtocolParametersUpdate -> Maybe EpochInterval
protocolUpdatePoolRetireMaxEpoch
, Maybe Natural
protocolUpdateStakePoolTargetNum :: Maybe Natural
protocolUpdateStakePoolTargetNum :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateStakePoolTargetNum
, Maybe Rational
protocolUpdatePoolPledgeInfluence :: Maybe Rational
protocolUpdatePoolPledgeInfluence :: ProtocolParametersUpdate -> Maybe Rational
protocolUpdatePoolPledgeInfluence
, Maybe Rational
protocolUpdateMonetaryExpansion :: Maybe Rational
protocolUpdateMonetaryExpansion :: ProtocolParametersUpdate -> Maybe Rational
protocolUpdateMonetaryExpansion
, Maybe Rational
protocolUpdateTreasuryCut :: Maybe Rational
protocolUpdateTreasuryCut :: ProtocolParametersUpdate -> Maybe Rational
protocolUpdateTreasuryCut
, Maybe Natural
protocolUpdateCollateralPercent :: Maybe Natural
protocolUpdateCollateralPercent :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateCollateralPercent
, Maybe ExecutionUnits
protocolUpdateMaxBlockExUnits :: Maybe ExecutionUnits
protocolUpdateMaxBlockExUnits :: ProtocolParametersUpdate -> Maybe ExecutionUnits
protocolUpdateMaxBlockExUnits
, Maybe Natural
protocolUpdateMaxCollateralInputs :: Maybe Natural
protocolUpdateMaxCollateralInputs :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxCollateralInputs
, Maybe ExecutionUnits
protocolUpdateMaxTxExUnits :: Maybe ExecutionUnits
protocolUpdateMaxTxExUnits :: ProtocolParametersUpdate -> Maybe ExecutionUnits
protocolUpdateMaxTxExUnits
, Maybe Natural
protocolUpdateMaxValueSize :: Maybe Natural
protocolUpdateMaxValueSize :: ProtocolParametersUpdate -> Maybe Natural
protocolUpdateMaxValueSize
, Maybe ExecutionUnitPrices
protocolUpdatePrices :: Maybe ExecutionUnitPrices
protocolUpdatePrices :: ProtocolParametersUpdate -> Maybe ExecutionUnitPrices
protocolUpdatePrices
, Maybe Lovelace
protocolUpdateUTxOCostPerByte :: Maybe Lovelace
protocolUpdateUTxOCostPerByte :: ProtocolParametersUpdate -> Maybe Lovelace
protocolUpdateUTxOCostPerByte
} =
[Pair] -> Value
object ([Pair] -> Value)
-> ([Maybe Pair] -> [Pair]) -> [Maybe Pair] -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
catMaybes ([Maybe Pair] -> Value) -> [Maybe Pair] -> Value
forall a b. (a -> b) -> a -> b
$
[ Maybe (Natural, Natural)
protocolUpdateProtocolVersion Maybe (Natural, Natural)
-> ((Natural, Natural) -> Pair) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \(Natural
major, Natural
minor) ->
Key
"protocol version" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (Natural -> Text
forall a. Show a => a -> Text
textShow Natural
major Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"." Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Natural -> Text
forall a. Show a => a -> Text
textShow Natural
minor)
, Maybe Rational
protocolUpdateDecentralization
Maybe Rational -> (Rational -> Pair) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> (Key
"decentralization parameter" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=) (Value -> Pair) -> (Rational -> Value) -> Rational -> Pair
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rational -> Value
friendlyRational
, Maybe (Maybe PraosNonce)
protocolUpdateExtraPraosEntropy
Maybe (Maybe PraosNonce)
-> (Maybe PraosNonce -> Pair) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> (Key
"extra entropy" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=) (Value -> Pair)
-> (Maybe PraosNonce -> Value) -> Maybe PraosNonce -> Pair
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> (PraosNonce -> Value) -> Maybe PraosNonce -> Value
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Value
"reset" PraosNonce -> Value
forall a. ToJSON a => a -> Value
toJSON
, Maybe Word16
protocolUpdateMaxBlockHeaderSize Maybe Word16 -> (Word16 -> Pair) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> (Key
"max block header size" Key -> Word16 -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=)
, Maybe Word32
protocolUpdateMaxBlockBodySize Maybe Word32 -> (Word32 -> Pair) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> (Key
"max block body size" Key -> Word32 -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=)
, Maybe Word32
protocolUpdateMaxTxSize Maybe Word32 -> (Word32 -> Pair) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> (Key
"max transaction size" Key -> Word32 -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=)
, Maybe Lovelace
protocolUpdateTxFeeFixed Maybe Lovelace -> (Lovelace -> Pair) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> (Key
"transaction fee constant" Key -> Lovelace -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=)
, Maybe Lovelace
protocolUpdateTxFeePerByte Maybe Lovelace -> (Lovelace -> Pair) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> (Key
"transaction fee linear per byte" Key -> Lovelace -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=)
, Maybe Lovelace
protocolUpdateMinUTxOValue Maybe Lovelace -> (Lovelace -> Pair) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> (Key
"min UTxO value" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=) (Value -> Pair) -> (Lovelace -> Value) -> Lovelace -> Pair
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Lovelace -> Value
friendlyLovelace
, Maybe Lovelace
protocolUpdateStakeAddressDeposit
Maybe Lovelace -> (Lovelace -> Pair) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> (Key
"key registration deposit" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=) (Value -> Pair) -> (Lovelace -> Value) -> Lovelace -> Pair
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Lovelace -> Value
friendlyLovelace
, Maybe Lovelace
protocolUpdateStakePoolDeposit
Maybe Lovelace -> (Lovelace -> Pair) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> (Key
"pool registration deposit" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=) (Value -> Pair) -> (Lovelace -> Value) -> Lovelace -> Pair
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Lovelace -> Value
friendlyLovelace
, Maybe Lovelace
protocolUpdateMinPoolCost Maybe Lovelace -> (Lovelace -> Pair) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> (Key
"min pool cost" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=) (Value -> Pair) -> (Lovelace -> Value) -> Lovelace -> Pair
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Lovelace -> Value
friendlyLovelace
, Maybe EpochInterval
protocolUpdatePoolRetireMaxEpoch Maybe EpochInterval -> (EpochInterval -> Pair) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> (Key
"pool retirement epoch boundary" Key -> EpochInterval -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=)
, Maybe Natural
protocolUpdateStakePoolTargetNum Maybe Natural -> (Natural -> Pair) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> (Key
"number of pools" Key -> Natural -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=)
, Maybe Rational
protocolUpdatePoolPledgeInfluence
Maybe Rational -> (Rational -> Pair) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> (Key
"pool influence" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=) (Value -> Pair) -> (Rational -> Value) -> Rational -> Pair
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rational -> Value
friendlyRational
, Maybe Rational
protocolUpdateMonetaryExpansion
Maybe Rational -> (Rational -> Pair) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> (Key
"monetary expansion" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=) (Value -> Pair) -> (Rational -> Value) -> Rational -> Pair
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rational -> Value
friendlyRational
, Maybe Rational
protocolUpdateTreasuryCut Maybe Rational -> (Rational -> Pair) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> (Key
"treasury expansion" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=) (Value -> Pair) -> (Rational -> Value) -> Rational -> Pair
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rational -> Value
friendlyRational
, Maybe Natural
protocolUpdateCollateralPercent
Maybe Natural -> (Natural -> Pair) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> (Key
"collateral inputs share" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=) (Text -> Pair) -> (Natural -> Text) -> Natural -> Pair
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"%") (Text -> Text) -> (Natural -> Text) -> Natural -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Natural -> Text
forall a. Show a => a -> Text
textShow
, Maybe ExecutionUnits
protocolUpdateMaxBlockExUnits Maybe ExecutionUnits -> (ExecutionUnits -> Pair) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> (Key
"max block execution units" Key -> ExecutionUnits -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=)
, Maybe Natural
protocolUpdateMaxCollateralInputs Maybe Natural -> (Natural -> Pair) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> (Key
"max collateral inputs" Key -> Natural -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=)
, Maybe ExecutionUnits
protocolUpdateMaxTxExUnits Maybe ExecutionUnits -> (ExecutionUnits -> Pair) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> (Key
"max transaction execution units" Key -> ExecutionUnits -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=)
, Maybe Natural
protocolUpdateMaxValueSize Maybe Natural -> (Natural -> Pair) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> (Key
"max value size" Key -> Natural -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=)
, Maybe ExecutionUnitPrices
protocolUpdatePrices Maybe ExecutionUnitPrices
-> (ExecutionUnitPrices -> Pair) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> (Key
"execution prices" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=) (Value -> Pair)
-> (ExecutionUnitPrices -> Value) -> ExecutionUnitPrices -> Pair
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ExecutionUnitPrices -> Value
friendlyPrices
, Maybe Lovelace
protocolUpdateUTxOCostPerByte
Maybe Lovelace -> (Lovelace -> Pair) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> (Key
"UTxO storage cost per byte" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=) (Value -> Pair) -> (Lovelace -> Value) -> Lovelace -> Pair
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Lovelace -> Value
friendlyLovelace
]
friendlyPrices :: ExecutionUnitPrices -> Aeson.Value
friendlyPrices :: ExecutionUnitPrices -> Value
friendlyPrices ExecutionUnitPrices{Rational
priceExecutionMemory :: Rational
priceExecutionMemory :: ExecutionUnitPrices -> Rational
priceExecutionMemory, Rational
priceExecutionSteps :: Rational
priceExecutionSteps :: ExecutionUnitPrices -> Rational
priceExecutionSteps} =
[Pair] -> Value
object
[ Key
"memory" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Rational -> Value
friendlyRational Rational
priceExecutionMemory
, Key
"steps" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Rational -> Value
friendlyRational Rational
priceExecutionSteps
]
friendlyCertificates :: ShelleyBasedEra era -> TxCertificates ViewTx era -> Aeson.Value
friendlyCertificates :: forall era.
ShelleyBasedEra era -> TxCertificates ViewTx era -> Value
friendlyCertificates ShelleyBasedEra era
sbe = \case
TxCertificates ViewTx era
TxCertificatesNone -> Value
Null
TxCertificates ShelleyBasedEra era
_ [Certificate era]
cs BuildTxWith ViewTx [(StakeCredential, Witness WitCtxStake era)]
_ -> [Value] -> Value
array ([Value] -> Value) -> [Value] -> Value
forall a b. (a -> b) -> a -> b
$ (Certificate era -> Value) -> [Certificate era] -> [Value]
forall a b. (a -> b) -> [a] -> [b]
map (ShelleyBasedEra era -> Certificate era -> Value
forall era. ShelleyBasedEra era -> Certificate era -> Value
friendlyCertificate ShelleyBasedEra era
sbe) [Certificate era]
cs
friendlyCertificate :: ShelleyBasedEra era -> Certificate era -> Aeson.Value
friendlyCertificate :: forall era. ShelleyBasedEra era -> Certificate era -> Value
friendlyCertificate ShelleyBasedEra era
sbe =
ShelleyBasedEra era
-> (ShelleyBasedEraConstraints era => Certificate era -> Value)
-> Certificate era
-> Value
forall era a.
ShelleyBasedEra era -> (ShelleyBasedEraConstraints era => a) -> a
shelleyBasedEraConstraints ShelleyBasedEra era
sbe ((ShelleyBasedEraConstraints era => Certificate era -> Value)
-> Certificate era -> Value)
-> (ShelleyBasedEraConstraints era => Certificate era -> Value)
-> Certificate era
-> Value
forall a b. (a -> b) -> a -> b
$
[Pair] -> Value
object ([Pair] -> Value)
-> (Certificate era -> [Pair]) -> Certificate era -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: []) (Pair -> [Pair])
-> (Certificate era -> Pair) -> Certificate era -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShelleyBasedEra era -> Certificate era -> Pair
forall era. ShelleyBasedEra era -> Certificate era -> Pair
renderCertificate ShelleyBasedEra era
sbe
renderCertificate :: ShelleyBasedEra era -> Certificate era -> (Aeson.Key, Aeson.Value)
renderCertificate :: forall era. ShelleyBasedEra era -> Certificate era -> Pair
renderCertificate ShelleyBasedEra era
sbe = \case
ShelleyRelatedCertificate ShelleyToBabbageEra era
_ ShelleyTxCert (ShelleyLedgerEra era)
c ->
ShelleyBasedEra era
-> (ShelleyBasedEraConstraints era => Pair) -> Pair
forall era a.
ShelleyBasedEra era -> (ShelleyBasedEraConstraints era => a) -> a
shelleyBasedEraConstraints ShelleyBasedEra era
sbe ((ShelleyBasedEraConstraints era => Pair) -> Pair)
-> (ShelleyBasedEraConstraints era => Pair) -> Pair
forall a b. (a -> b) -> a -> b
$
case ShelleyTxCert (ShelleyLedgerEra era)
c of
L.ShelleyTxCertDelegCert (L.ShelleyRegCert StakeCredential (EraCrypto (ShelleyLedgerEra era))
cred) ->
Key
"stake address registration" Key -> StakeCredential StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= StakeCredential (EraCrypto (ShelleyLedgerEra era))
StakeCredential StandardCrypto
cred
L.ShelleyTxCertDelegCert (L.ShelleyUnRegCert StakeCredential (EraCrypto (ShelleyLedgerEra era))
cred) ->
Key
"stake address deregistration" Key -> StakeCredential StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= StakeCredential (EraCrypto (ShelleyLedgerEra era))
StakeCredential StandardCrypto
cred
L.ShelleyTxCertDelegCert (L.ShelleyDelegCert StakeCredential (EraCrypto (ShelleyLedgerEra era))
cred KeyHash 'StakePool (EraCrypto (ShelleyLedgerEra era))
poolId) ->
Key
"stake address delegation"
Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object
[ Key
"credential" Key -> StakeCredential StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= StakeCredential (EraCrypto (ShelleyLedgerEra era))
StakeCredential StandardCrypto
cred
, Key
"pool" Key -> KeyHash 'StakePool StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= KeyHash 'StakePool (EraCrypto (ShelleyLedgerEra era))
KeyHash 'StakePool StandardCrypto
poolId
]
L.ShelleyTxCertPool (L.RetirePool KeyHash 'StakePool (EraCrypto (ShelleyLedgerEra era))
poolId EpochNo
retirementEpoch) ->
Key
"stake pool retirement"
Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object
[ Key
"pool" Key -> Hash StakePoolKey -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= KeyHash 'StakePool StandardCrypto -> Hash StakePoolKey
StakePoolKeyHash KeyHash 'StakePool (EraCrypto (ShelleyLedgerEra era))
KeyHash 'StakePool StandardCrypto
poolId
, Key
"epoch" Key -> EpochNo -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= EpochNo
retirementEpoch
]
L.ShelleyTxCertPool (L.RegPool PoolParams (EraCrypto (ShelleyLedgerEra era))
poolParams) ->
Key
"stake pool registration" Key -> PoolParams StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= PoolParams (EraCrypto (ShelleyLedgerEra era))
PoolParams StandardCrypto
poolParams
L.ShelleyTxCertGenesisDeleg (L.GenesisDelegCert KeyHash 'Genesis (EraCrypto (ShelleyLedgerEra era))
genesisKeyHash KeyHash 'GenesisDelegate (EraCrypto (ShelleyLedgerEra era))
delegateKeyHash Hash
(EraCrypto (ShelleyLedgerEra era))
(VerKeyVRF (EraCrypto (ShelleyLedgerEra era)))
vrfKeyHash) ->
Key
"genesis key delegation"
Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object
[ Key
"genesis key hash" Key -> KeyHash 'Genesis StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= KeyHash 'Genesis (EraCrypto (ShelleyLedgerEra era))
KeyHash 'Genesis StandardCrypto
genesisKeyHash
, Key
"delegate key hash" Key -> KeyHash 'GenesisDelegate StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= KeyHash 'GenesisDelegate (EraCrypto (ShelleyLedgerEra era))
KeyHash 'GenesisDelegate StandardCrypto
delegateKeyHash
, Key
"VRF key hash" Key -> Hash Blake2b_256 (VerKeyVRF PraosVRF) -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Hash Blake2b_256 (VerKeyVRF PraosVRF)
Hash
(EraCrypto (ShelleyLedgerEra era))
(VerKeyVRF (EraCrypto (ShelleyLedgerEra era)))
vrfKeyHash
]
L.ShelleyTxCertMir (L.MIRCert MIRPot
pot MIRTarget (EraCrypto (ShelleyLedgerEra era))
target) ->
Key
"MIR"
Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object
[ Key
"pot" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= MIRPot -> Value
friendlyMirPot MIRPot
pot
, ShelleyBasedEra era
-> MIRTarget (EraCrypto (ShelleyLedgerEra era)) -> Pair
forall era.
ShelleyBasedEra era
-> MIRTarget (EraCrypto (ShelleyLedgerEra era)) -> Pair
friendlyMirTarget ShelleyBasedEra era
sbe MIRTarget (EraCrypto (ShelleyLedgerEra era))
target
]
ConwayCertificate ConwayEraOnwards era
w ConwayTxCert (ShelleyLedgerEra era)
cert ->
ConwayEraOnwards era
-> (ConwayEraOnwardsConstraints era => Pair) -> Pair
forall era a.
ConwayEraOnwards era -> (ConwayEraOnwardsConstraints era => a) -> a
conwayEraOnwardsConstraints ConwayEraOnwards era
w ((ConwayEraOnwardsConstraints era => Pair) -> Pair)
-> (ConwayEraOnwardsConstraints era => Pair) -> Pair
forall a b. (a -> b) -> a -> b
$
case ConwayTxCert (ShelleyLedgerEra era)
cert of
L.RegDRepTxCert Credential 'DRepRole (EraCrypto (ShelleyLedgerEra era))
credential Lovelace
coin StrictMaybe (Anchor (EraCrypto (ShelleyLedgerEra era)))
mAnchor ->
Key
"Drep registration certificate"
Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object
[ Key
"deposit" Key -> Lovelace -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Lovelace
coin
, Key
"certificate" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ConwayEraOnwards era
-> Credential 'DRepRole (EraCrypto (ShelleyLedgerEra era)) -> Value
forall era.
ConwayEraOnwards era
-> Credential 'DRepRole (EraCrypto (ShelleyLedgerEra era)) -> Value
conwayToObject ConwayEraOnwards era
w Credential 'DRepRole (EraCrypto (ShelleyLedgerEra era))
credential
, Key
"anchor" Key -> StrictMaybe (Anchor StandardCrypto) -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= StrictMaybe (Anchor (EraCrypto (ShelleyLedgerEra era)))
StrictMaybe (Anchor StandardCrypto)
mAnchor
]
L.UnRegDRepTxCert Credential 'DRepRole (EraCrypto (ShelleyLedgerEra era))
credential Lovelace
coin ->
Key
"Drep unregistration certificate"
Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object
[ Key
"refund" Key -> Lovelace -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Lovelace
coin
, Key
"certificate" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ConwayEraOnwards era
-> Credential 'DRepRole (EraCrypto (ShelleyLedgerEra era)) -> Value
forall era.
ConwayEraOnwards era
-> Credential 'DRepRole (EraCrypto (ShelleyLedgerEra era)) -> Value
conwayToObject ConwayEraOnwards era
w Credential 'DRepRole (EraCrypto (ShelleyLedgerEra era))
credential
]
L.AuthCommitteeHotKeyTxCert Credential 'ColdCommitteeRole (EraCrypto (ShelleyLedgerEra era))
coldCred Credential 'HotCommitteeRole (EraCrypto (ShelleyLedgerEra era))
hotCred
| L.ScriptHashObj ScriptHash (EraCrypto (ShelleyLedgerEra era))
sh <- Credential 'ColdCommitteeRole (EraCrypto (ShelleyLedgerEra era))
coldCred ->
Key
"Cold committee authorization"
Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object
[Key
"script hash" Key -> ScriptHash StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ScriptHash (EraCrypto (ShelleyLedgerEra era))
ScriptHash StandardCrypto
sh]
| L.ScriptHashObj ScriptHash (EraCrypto (ShelleyLedgerEra era))
sh <- Credential 'HotCommitteeRole (EraCrypto (ShelleyLedgerEra era))
hotCred ->
Key
"Hot committee authorization"
Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object
[Key
"script hash" Key -> ScriptHash StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ScriptHash (EraCrypto (ShelleyLedgerEra era))
ScriptHash StandardCrypto
sh]
| L.KeyHashObj ck :: KeyHash 'ColdCommitteeRole (EraCrypto (ShelleyLedgerEra era))
ck@L.KeyHash{} <- Credential 'ColdCommitteeRole (EraCrypto (ShelleyLedgerEra era))
coldCred
, L.KeyHashObj hk :: KeyHash 'HotCommitteeRole (EraCrypto (ShelleyLedgerEra era))
hk@L.KeyHash{} <- Credential 'HotCommitteeRole (EraCrypto (ShelleyLedgerEra era))
hotCred ->
Key
"Constitutional committee member hot key registration"
Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object
[ Key
"cold key hash" Key -> KeyHash 'ColdCommitteeRole StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= KeyHash 'ColdCommitteeRole (EraCrypto (ShelleyLedgerEra era))
KeyHash 'ColdCommitteeRole StandardCrypto
ck
, Key
"hot key hash" Key -> KeyHash 'HotCommitteeRole StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= KeyHash 'HotCommitteeRole (EraCrypto (ShelleyLedgerEra era))
KeyHash 'HotCommitteeRole StandardCrypto
hk
]
L.ResignCommitteeColdTxCert Credential 'ColdCommitteeRole (EraCrypto (ShelleyLedgerEra era))
cred StrictMaybe (Anchor (EraCrypto (ShelleyLedgerEra era)))
anchor -> case Credential 'ColdCommitteeRole (EraCrypto (ShelleyLedgerEra era))
cred of
L.ScriptHashObj ScriptHash (EraCrypto (ShelleyLedgerEra era))
sh ->
Key
"Cold committee resignation"
Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object
[ Key
"script hash" Key -> ScriptHash StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ScriptHash (EraCrypto (ShelleyLedgerEra era))
ScriptHash StandardCrypto
sh
, Key
"anchor" Key -> StrictMaybe (Anchor StandardCrypto) -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= StrictMaybe (Anchor (EraCrypto (ShelleyLedgerEra era)))
StrictMaybe (Anchor StandardCrypto)
anchor
]
L.KeyHashObj ck :: KeyHash 'ColdCommitteeRole (EraCrypto (ShelleyLedgerEra era))
ck@L.KeyHash{} ->
Key
"Constitutional committee cold key resignation"
Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object
[ Key
"cold key hash" Key -> KeyHash 'ColdCommitteeRole StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= KeyHash 'ColdCommitteeRole (EraCrypto (ShelleyLedgerEra era))
KeyHash 'ColdCommitteeRole StandardCrypto
ck
]
L.RegTxCert StakeCredential (EraCrypto (ShelleyLedgerEra era))
stakeCredential ->
Key
"Stake address registration"
Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object
[ Key
"stake credential" Key -> StakeCredential StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= StakeCredential (EraCrypto (ShelleyLedgerEra era))
StakeCredential StandardCrypto
stakeCredential
]
L.UnRegTxCert StakeCredential (EraCrypto (ShelleyLedgerEra era))
stakeCredential ->
Key
"Stake address deregistration"
Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object
[ Key
"stake credential" Key -> StakeCredential StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= StakeCredential (EraCrypto (ShelleyLedgerEra era))
StakeCredential StandardCrypto
stakeCredential
]
L.RegDepositTxCert StakeCredential (EraCrypto (ShelleyLedgerEra era))
stakeCredential Lovelace
deposit ->
Key
"Stake address registration"
Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object
[ Key
"stake credential" Key -> StakeCredential StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= StakeCredential (EraCrypto (ShelleyLedgerEra era))
StakeCredential StandardCrypto
stakeCredential
, Key
"deposit" Key -> Lovelace -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Lovelace
deposit
]
L.UnRegDepositTxCert StakeCredential (EraCrypto (ShelleyLedgerEra era))
stakeCredential Lovelace
refund ->
Key
"Stake address deregistration"
Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object
[ Key
"stake credential" Key -> StakeCredential StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= StakeCredential (EraCrypto (ShelleyLedgerEra era))
StakeCredential StandardCrypto
stakeCredential
, Key
"refund" Key -> Lovelace -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Lovelace
refund
]
L.DelegTxCert StakeCredential (EraCrypto (ShelleyLedgerEra era))
stakeCredential Delegatee (EraCrypto (ShelleyLedgerEra era))
delegatee ->
Key
"Stake address delegation"
Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object
[ Key
"stake credential" Key -> StakeCredential StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= StakeCredential (EraCrypto (ShelleyLedgerEra era))
StakeCredential StandardCrypto
stakeCredential
, Key
"delegatee" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ShelleyBasedEra era
-> Delegatee (EraCrypto (ShelleyLedgerEra era)) -> Value
forall era.
(EraCrypto (ShelleyLedgerEra era) ~ StandardCrypto) =>
ShelleyBasedEra era
-> Delegatee (EraCrypto (ShelleyLedgerEra era)) -> Value
delegateeJson ShelleyBasedEra era
sbe Delegatee (EraCrypto (ShelleyLedgerEra era))
delegatee
]
L.RegDepositDelegTxCert StakeCredential (EraCrypto (ShelleyLedgerEra era))
stakeCredential Delegatee (EraCrypto (ShelleyLedgerEra era))
delegatee Lovelace
deposit ->
Key
"Stake address registration and delegation"
Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object
[ Key
"stake credential" Key -> StakeCredential StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= StakeCredential (EraCrypto (ShelleyLedgerEra era))
StakeCredential StandardCrypto
stakeCredential
, Key
"delegatee" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ShelleyBasedEra era
-> Delegatee (EraCrypto (ShelleyLedgerEra era)) -> Value
forall era.
(EraCrypto (ShelleyLedgerEra era) ~ StandardCrypto) =>
ShelleyBasedEra era
-> Delegatee (EraCrypto (ShelleyLedgerEra era)) -> Value
delegateeJson ShelleyBasedEra era
sbe Delegatee (EraCrypto (ShelleyLedgerEra era))
delegatee
, Key
"deposit" Key -> Lovelace -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Lovelace
deposit
]
L.RegPoolTxCert PoolParams (EraCrypto (ShelleyLedgerEra era))
poolParams ->
Key
"Pool registration"
Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object
[ Key
"pool params" Key -> PoolParams StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= PoolParams (EraCrypto (ShelleyLedgerEra era))
PoolParams StandardCrypto
poolParams
]
L.RetirePoolTxCert kh :: KeyHash 'StakePool (EraCrypto (ShelleyLedgerEra era))
kh@L.KeyHash{} EpochNo
epoch ->
Key
"Pool retirement"
Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object
[ Key
"stake pool key hash" Key -> KeyHash 'StakePool StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= KeyHash 'StakePool (EraCrypto (ShelleyLedgerEra era))
KeyHash 'StakePool StandardCrypto
kh
, Key
"epoch" Key -> EpochNo -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= EpochNo
epoch
]
L.UpdateDRepTxCert Credential 'DRepRole (EraCrypto (ShelleyLedgerEra era))
drepCredential StrictMaybe (Anchor (EraCrypto (ShelleyLedgerEra era)))
mbAnchor ->
Key
"Drep certificate update"
Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object
[ Key
"Drep credential" Key -> Credential 'DRepRole StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Credential 'DRepRole (EraCrypto (ShelleyLedgerEra era))
Credential 'DRepRole StandardCrypto
drepCredential
, Key
"anchor " Key -> StrictMaybe (Anchor StandardCrypto) -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= StrictMaybe (Anchor (EraCrypto (ShelleyLedgerEra era)))
StrictMaybe (Anchor StandardCrypto)
mbAnchor
]
where
conwayToObject
:: ()
=> ConwayEraOnwards era
-> L.Credential 'L.DRepRole (L.EraCrypto (ShelleyLedgerEra era))
-> Aeson.Value
conwayToObject :: forall era.
ConwayEraOnwards era
-> Credential 'DRepRole (EraCrypto (ShelleyLedgerEra era)) -> Value
conwayToObject ConwayEraOnwards era
w' =
ConwayEraOnwards era
-> (ConwayEraOnwardsConstraints era =>
Credential 'DRepRole (EraCrypto (ShelleyLedgerEra era)) -> Value)
-> Credential 'DRepRole (EraCrypto (ShelleyLedgerEra era))
-> Value
forall era a.
ConwayEraOnwards era -> (ConwayEraOnwardsConstraints era => a) -> a
conwayEraOnwardsConstraints ConwayEraOnwards era
w' ((ConwayEraOnwardsConstraints era =>
Credential 'DRepRole (EraCrypto (ShelleyLedgerEra era)) -> Value)
-> Credential 'DRepRole (EraCrypto (ShelleyLedgerEra era))
-> Value)
-> (ConwayEraOnwardsConstraints era =>
Credential 'DRepRole (EraCrypto (ShelleyLedgerEra era)) -> Value)
-> Credential 'DRepRole (EraCrypto (ShelleyLedgerEra era))
-> Value
forall a b. (a -> b) -> a -> b
$
[Pair] -> Value
object ([Pair] -> Value)
-> (Credential 'DRepRole StandardCrypto -> [Pair])
-> Credential 'DRepRole StandardCrypto
-> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. \case
L.ScriptHashObj ScriptHash StandardCrypto
sHash -> [Key
"scriptHash" Key -> ScriptHash StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ScriptHash StandardCrypto
sHash]
L.KeyHashObj KeyHash 'DRepRole StandardCrypto
keyHash -> [Key
"keyHash" Key -> KeyHash 'DRepRole StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= KeyHash 'DRepRole StandardCrypto
keyHash]
delegateeJson
:: L.EraCrypto (ShelleyLedgerEra era) ~ L.StandardCrypto
=> ShelleyBasedEra era
-> L.Delegatee (L.EraCrypto (ShelleyLedgerEra era))
-> Aeson.Value
delegateeJson :: forall era.
(EraCrypto (ShelleyLedgerEra era) ~ StandardCrypto) =>
ShelleyBasedEra era
-> Delegatee (EraCrypto (ShelleyLedgerEra era)) -> Value
delegateeJson ShelleyBasedEra era
_ =
[Pair] -> Value
object ([Pair] -> Value)
-> (Delegatee StandardCrypto -> [Pair])
-> Delegatee StandardCrypto
-> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. \case
L.DelegStake hk :: KeyHash 'StakePool StandardCrypto
hk@L.KeyHash{} ->
[ Key
"delegatee type" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"stake"
, Key
"key hash" Key -> KeyHash 'StakePool StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= KeyHash 'StakePool StandardCrypto
hk
]
L.DelegVote DRep StandardCrypto
drep -> do
[Key
"delegatee type" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"vote", Key
"DRep" Key -> DRep StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= DRep StandardCrypto
drep]
L.DelegStakeVote KeyHash 'StakePool StandardCrypto
kh DRep StandardCrypto
drep ->
[ Key
"delegatee type" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"stake vote"
, Key
"key hash" Key -> KeyHash 'StakePool StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= KeyHash 'StakePool StandardCrypto
kh
, Key
"DRep" Key -> DRep StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= DRep StandardCrypto
drep
]
friendlyMirTarget
:: ShelleyBasedEra era -> L.MIRTarget (L.EraCrypto (ShelleyLedgerEra era)) -> Aeson.Pair
friendlyMirTarget :: forall era.
ShelleyBasedEra era
-> MIRTarget (EraCrypto (ShelleyLedgerEra era)) -> Pair
friendlyMirTarget ShelleyBasedEra era
sbe = \case
L.StakeAddressesMIR Map
(Credential 'Staking (EraCrypto (ShelleyLedgerEra era))) DeltaCoin
addresses ->
Key
"target stake addresses"
Key -> [Value] -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [ [Pair] -> Value
object
[ StakeCredential StandardCrypto -> Pair
friendlyStakeCredential StakeCredential StandardCrypto
credential
, Key
"amount" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Lovelace -> Value
friendlyLovelace (Integer -> Lovelace
L.Coin Integer
0 Lovelace -> DeltaCoin -> Lovelace
`L.addDeltaCoin` DeltaCoin
lovelace)
]
| (StakeCredential StandardCrypto
credential, DeltaCoin
lovelace) <- ShelleyBasedEra era
-> (ShelleyBasedEraConstraints era =>
[(StakeCredential StandardCrypto, DeltaCoin)])
-> [(StakeCredential StandardCrypto, DeltaCoin)]
forall era a.
ShelleyBasedEra era -> (ShelleyBasedEraConstraints era => a) -> a
shelleyBasedEraConstraints ShelleyBasedEra era
sbe ((ShelleyBasedEraConstraints era =>
[(StakeCredential StandardCrypto, DeltaCoin)])
-> [(StakeCredential StandardCrypto, DeltaCoin)])
-> (ShelleyBasedEraConstraints era =>
[(StakeCredential StandardCrypto, DeltaCoin)])
-> [(StakeCredential StandardCrypto, DeltaCoin)]
forall a b. (a -> b) -> a -> b
$ Map (StakeCredential StandardCrypto) DeltaCoin
-> [Item (Map (StakeCredential StandardCrypto) DeltaCoin)]
forall l. IsList l => l -> [Item l]
toList Map
(Credential 'Staking (EraCrypto (ShelleyLedgerEra era))) DeltaCoin
Map (StakeCredential StandardCrypto) DeltaCoin
addresses
]
L.SendToOppositePotMIR Lovelace
amount -> Key
"MIR amount" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Lovelace -> Value
friendlyLovelace Lovelace
amount
friendlyStakeCredential
:: L.Credential L.Staking L.StandardCrypto -> Aeson.Pair
friendlyStakeCredential :: StakeCredential StandardCrypto -> Pair
friendlyStakeCredential = \case
L.KeyHashObj KeyHash 'Staking StandardCrypto
keyHash ->
Key
"stake credential key hash" Key -> KeyHash 'Staking StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= KeyHash 'Staking StandardCrypto
keyHash
L.ScriptHashObj ScriptHash StandardCrypto
scriptHash ->
Key
"stake credential script hash" Key -> ScriptHash StandardCrypto -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ScriptHash StandardCrypto
scriptHash
friendlyPaymentCredential :: PaymentCredential -> Aeson.Pair
friendlyPaymentCredential :: PaymentCredential -> Pair
friendlyPaymentCredential = \case
PaymentCredentialByKey Hash PaymentKey
keyHash ->
Key
"payment credential key hash" Key -> Hash PaymentKey -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Hash PaymentKey
keyHash
PaymentCredentialByScript ScriptHash
scriptHash ->
Key
"payment credential script hash" Key -> ScriptHash -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ScriptHash
scriptHash
friendlyMirPot :: L.MIRPot -> Aeson.Value
friendlyMirPot :: MIRPot -> Value
friendlyMirPot = \case
MIRPot
L.ReservesMIR -> Value
"reserves"
MIRPot
L.TreasuryMIR -> Value
"treasury"
friendlyRational :: Rational -> Aeson.Value
friendlyRational :: Rational -> Value
friendlyRational Rational
r =
Text -> Value
String (Text -> Value) -> Text -> Value
forall a b. (a -> b) -> a -> b
$
case Integer
d of
Integer
1 -> Integer -> Text
forall a. Show a => a -> Text
textShow Integer
n
Integer
_ -> Integer -> Text
forall a. Show a => a -> Text
textShow Integer
n Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Integer -> Text
forall a. Show a => a -> Text
textShow Integer
d
where
n :: Integer
n = Rational -> Integer
forall a. Ratio a -> a
numerator Rational
r
d :: Integer
d = Rational -> Integer
forall a. Ratio a -> a
denominator Rational
r
friendlyFee :: TxFee era -> Aeson.Value
friendlyFee :: forall era. TxFee era -> Value
friendlyFee = \case
TxFeeExplicit ShelleyBasedEra era
_ Lovelace
fee -> Lovelace -> Value
friendlyLovelace Lovelace
fee
friendlyLovelace :: Lovelace -> Aeson.Value
friendlyLovelace :: Lovelace -> Value
friendlyLovelace Lovelace
value = Text -> Value
String (Text -> Value) -> Text -> Value
forall a b. (a -> b) -> a -> b
$ Doc AnsiStyle -> Text
docToText (Lovelace -> Doc AnsiStyle
forall a ann. Pretty a => a -> Doc ann
forall ann. Lovelace -> Doc ann
pretty Lovelace
value)
friendlyMintValue :: TxMintValue ViewTx era -> Aeson.Value
friendlyMintValue :: forall era. TxMintValue ViewTx era -> Value
friendlyMintValue = \case
TxMintValue ViewTx era
TxMintNone -> Value
Null
TxMintValue MaryEraOnwards era
sbe Value
v BuildTxWith ViewTx (Map PolicyId (ScriptWitness WitCtxMint era))
_ -> ShelleyBasedEra era -> Value -> Value
forall era. ShelleyBasedEra era -> Value -> Value
friendlyValue (MaryEraOnwards era -> ShelleyBasedEra era
forall era. MaryEraOnwards era -> ShelleyBasedEra era
maryEraOnwardsToShelleyBasedEra MaryEraOnwards era
sbe) Value
v
friendlyTxOutValue :: TxOutValue era -> Aeson.Value
friendlyTxOutValue :: forall era. TxOutValue era -> Value
friendlyTxOutValue = \case
TxOutValueByron Lovelace
lovelace -> Lovelace -> Value
friendlyLovelace Lovelace
lovelace
TxOutValueShelleyBased ShelleyBasedEra era
sbe Value (ShelleyLedgerEra era)
v -> ShelleyBasedEra era -> Value (ShelleyLedgerEra era) -> Value
forall era.
ShelleyBasedEra era -> Value (ShelleyLedgerEra era) -> Value
friendlyLedgerValue ShelleyBasedEra era
sbe Value (ShelleyLedgerEra era)
v
friendlyLedgerValue
:: ()
=> ShelleyBasedEra era
-> L.Value (ShelleyLedgerEra era)
-> Aeson.Value
friendlyLedgerValue :: forall era.
ShelleyBasedEra era -> Value (ShelleyLedgerEra era) -> Value
friendlyLedgerValue ShelleyBasedEra era
sbe Value (ShelleyLedgerEra era)
v = ShelleyBasedEra era -> Value -> Value
forall era. ShelleyBasedEra era -> Value -> Value
friendlyValue ShelleyBasedEra era
sbe (Value -> Value) -> Value -> Value
forall a b. (a -> b) -> a -> b
$ ShelleyBasedEra era -> Value (ShelleyLedgerEra era) -> Value
forall era.
ShelleyBasedEra era -> Value (ShelleyLedgerEra era) -> Value
Api.fromLedgerValue ShelleyBasedEra era
sbe Value (ShelleyLedgerEra era)
v
friendlyValue
:: ()
=> ShelleyBasedEra era
-> Api.Value
-> Aeson.Value
friendlyValue :: forall era. ShelleyBasedEra era -> Value -> Value
friendlyValue ShelleyBasedEra era
_ Value
v =
[Pair] -> Value
object
[ case ValueNestedBundle
bundle of
ValueNestedBundleAda Quantity
q -> Key
"lovelace" Key -> Quantity -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Quantity
q
ValueNestedBundle PolicyId
policy Map AssetName Quantity
assets ->
Text -> Key
Aeson.fromText (PolicyId -> Text
friendlyPolicyId PolicyId
policy) Key -> Map Text Quantity -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Map AssetName Quantity -> Map Text Quantity
forall {a}. Map AssetName a -> Map Text a
friendlyAssets Map AssetName Quantity
assets
| ValueNestedBundle
bundle <- [ValueNestedBundle]
bundles
]
where
ValueNestedRep [ValueNestedBundle]
bundles = Value -> ValueNestedRep
valueToNestedRep Value
v
friendlyPolicyId :: PolicyId -> Text
friendlyPolicyId = (Text
"policy " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>) (Text -> Text) -> (PolicyId -> Text) -> PolicyId -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PolicyId -> Text
forall a. SerialiseAsRawBytes a => a -> Text
serialiseToRawBytesHexText
friendlyAssets :: Map AssetName a -> Map Text a
friendlyAssets = (AssetName -> Text) -> Map AssetName a -> Map Text a
forall k2 k1 a. Ord k2 => (k1 -> k2) -> Map k1 a -> Map k2 a
Map.mapKeys AssetName -> Text
friendlyAssetName
friendlyAssetName :: AssetName -> Text
friendlyAssetName = \case
AssetName
"" -> Text
"default asset"
name :: AssetName
name@(AssetName ByteString
nameBS) ->
Text
"asset " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> AssetName -> Text
forall a. SerialiseAsRawBytes a => a -> Text
serialiseToRawBytesHexText AssetName
name Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
nameAsciiSuffix
where
nameAsciiSuffix :: Text
nameAsciiSuffix
| Bool
nameIsAscii = Text
" (" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
nameAscii Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
")"
| Bool
otherwise = Text
""
nameIsAscii :: Bool
nameIsAscii = (Char -> Bool) -> ByteString -> Bool
BSC.all (\Char
c -> Char -> Bool
isAscii Char
c Bool -> Bool -> Bool
&& Char -> Bool
isAlphaNum Char
c) ByteString
nameBS
nameAscii :: Text
nameAscii = [Char] -> Text
Text.pack ([Char] -> Text) -> [Char] -> Text
forall a b. (a -> b) -> a -> b
$ ByteString -> [Char]
BSC.unpack ByteString
nameBS
friendlyMetadata :: TxMetadataInEra era -> Aeson.Value
friendlyMetadata :: forall era. TxMetadataInEra era -> Value
friendlyMetadata = \case
TxMetadataInEra era
TxMetadataNone -> Value
Null
TxMetadataInEra ShelleyBasedEra era
_ (TxMetadata Map Word64 TxMetadataValue
m) -> Map Word64 Value -> Value
forall a. ToJSON a => a -> Value
toJSON (Map Word64 Value -> Value) -> Map Word64 Value -> Value
forall a b. (a -> b) -> a -> b
$ TxMetadataValue -> Value
friendlyMetadataValue (TxMetadataValue -> Value)
-> Map Word64 TxMetadataValue -> Map Word64 Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Map Word64 TxMetadataValue
m
friendlyMetadataValue :: TxMetadataValue -> Aeson.Value
friendlyMetadataValue :: TxMetadataValue -> Value
friendlyMetadataValue = \case
TxMetaNumber Integer
int -> Integer -> Value
forall a. ToJSON a => a -> Value
toJSON Integer
int
TxMetaBytes ByteString
bytes -> Text -> Value
String (Text -> Value) -> Text -> Value
forall a b. (a -> b) -> a -> b
$ ByteString -> Text
forall a. Show a => a -> Text
textShow ByteString
bytes
TxMetaList [TxMetadataValue]
lst -> [Value] -> Value
array ([Value] -> Value) -> [Value] -> Value
forall a b. (a -> b) -> a -> b
$ (TxMetadataValue -> Value) -> [TxMetadataValue] -> [Value]
forall a b. (a -> b) -> [a] -> [b]
map TxMetadataValue -> Value
friendlyMetadataValue [TxMetadataValue]
lst
TxMetaMap [(TxMetadataValue, TxMetadataValue)]
m ->
[Value] -> Value
array
[[Value] -> Value
array [TxMetadataValue -> Value
friendlyMetadataValue TxMetadataValue
k, TxMetadataValue -> Value
friendlyMetadataValue TxMetadataValue
v] | (TxMetadataValue
k, TxMetadataValue
v) <- [(TxMetadataValue, TxMetadataValue)]
m]
TxMetaText Text
text -> Text -> Value
forall a. ToJSON a => a -> Value
toJSON Text
text
friendlyAuxScripts :: TxAuxScripts era -> Aeson.Value
friendlyAuxScripts :: forall era. TxAuxScripts era -> Value
friendlyAuxScripts = \case
TxAuxScripts era
TxAuxScriptsNone -> Value
Null
TxAuxScripts AllegraEraOnwards era
_ [ScriptInEra era]
scripts -> Text -> Value
String (Text -> Value) -> Text -> Value
forall a b. (a -> b) -> a -> b
$ [ScriptInEra era] -> Text
forall a. Show a => a -> Text
textShow [ScriptInEra era]
scripts
friendlyReferenceInputs :: TxInsReference era -> Aeson.Value
friendlyReferenceInputs :: forall era. TxInsReference era -> Value
friendlyReferenceInputs TxInsReference era
TxInsReferenceNone = Value
Null
friendlyReferenceInputs (TxInsReference BabbageEraOnwards era
_ [TxIn]
txins) = [TxIn] -> Value
forall a. ToJSON a => a -> Value
toJSON [TxIn]
txins
friendlyInputs :: [(TxIn, build)] -> Aeson.Value
friendlyInputs :: forall build. [(TxIn, build)] -> Value
friendlyInputs = [TxIn] -> Value
forall a. ToJSON a => a -> Value
toJSON ([TxIn] -> Value)
-> ([(TxIn, build)] -> [TxIn]) -> [(TxIn, build)] -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((TxIn, build) -> TxIn) -> [(TxIn, build)] -> [TxIn]
forall a b. (a -> b) -> [a] -> [b]
map (TxIn, build) -> TxIn
forall a b. (a, b) -> a
fst
friendlyCollateralInputs :: TxInsCollateral era -> Aeson.Value
friendlyCollateralInputs :: forall era. TxInsCollateral era -> Value
friendlyCollateralInputs = \case
TxInsCollateral era
TxInsCollateralNone -> Value
Null
TxInsCollateral AlonzoEraOnwards era
_ [TxIn]
txins -> [TxIn] -> Value
forall a. ToJSON a => a -> Value
toJSON [TxIn]
txins