diff --git a/cardano-api/internal/Cardano/Api/ReexposeLedger.hs b/cardano-api/internal/Cardano/Api/ReexposeLedger.hs index 01e243ccd..92a008cdf 100644 --- a/cardano-api/internal/Cardano/Api/ReexposeLedger.hs +++ b/cardano-api/internal/Cardano/Api/ReexposeLedger.hs @@ -128,6 +128,7 @@ module Cardano.Api.ReexposeLedger , EraGov , EraTx (witsTxL, bodyTxL) , Tx + , TxDats (..) , ppPricesL , unData , unRedeemers @@ -173,6 +174,7 @@ import Cardano.Ledger.Alonzo.Core (AlonzoEraScript (..), AlonzoEraTxBo import Cardano.Ledger.Alonzo.Genesis (AlonzoGenesis) import Cardano.Ledger.Alonzo.Scripts (AlonzoPlutusPurpose (..), CostModels, ExUnits (..), Prices (..)) +import Cardano.Ledger.Alonzo.TxWits (TxDats (..)) import Cardano.Ledger.Api (Constitution (..), GovAction (..), unRedeemers) import Cardano.Ledger.Api.Tx.Cert (pattern AuthCommitteeHotKeyTxCert, pattern DelegStakeTxCert, pattern DelegTxCert, pattern GenesisDelegTxCert, diff --git a/cardano-api/internal/Cardano/Api/ScriptData.hs b/cardano-api/internal/Cardano/Api/ScriptData.hs index fd48a8bef..df8ed04b3 100644 --- a/cardano-api/internal/Cardano/Api/ScriptData.hs +++ b/cardano-api/internal/Cardano/Api/ScriptData.hs @@ -17,6 +17,7 @@ module Cardano.Api.ScriptData , unsafeHashableScriptData , ScriptData (..) , friendlyScript + , friendlyDatum -- * Validating metadata , validateScriptData @@ -65,6 +66,7 @@ import qualified Cardano.Crypto.Hash.Class as Crypto import Cardano.Ledger.Allegra.Scripts (showTimelock) import Cardano.Ledger.Alonzo.Core (AlonzoEraScript (..)) import Cardano.Ledger.Alonzo.Scripts (plutusScriptLanguage) +import qualified Cardano.Ledger.Api as Alonzo import Cardano.Ledger.Binary.Plain (serializeAsHexText) import Cardano.Ledger.Core (Era, EraScript (..), Script) import Cardano.Ledger.Plutus (Language) @@ -279,6 +281,11 @@ friendlyScript script = Aeson.Object $ , ("script", Aeson.String $ serializeAsHexText $ plutusBinary plutusScript) ] +-- | Friendly dats JSON +friendlyDatum + :: AlonzoEraOnwardsConstraints era => Alonzo.Data (ShelleyLedgerEra era) -> Aeson.Value +friendlyDatum (Alonzo.Data datum) = Aeson.String (T.pack $ show datum) + -- ---------------------------------------------------------------------------- -- Validate script data -- diff --git a/cardano-api/src/Cardano/Api.hs b/cardano-api/src/Cardano/Api.hs index 3d4a80167..ac527d887 100644 --- a/cardano-api/src/Cardano/Api.hs +++ b/cardano-api/src/Cardano/Api.hs @@ -548,6 +548,7 @@ module Cardano.Api , ScriptWitnessIndex (..) , renderScriptWitnessIndex , collectTxBodyScriptWitnesses + , friendlyDatum , friendlyScript -- ** Languages supported in each era