Skip to content

Commit

Permalink
Introduce AlonzoEraTxAuxData with plutusScriptsTxAuxDataL
Browse files Browse the repository at this point in the history
  • Loading branch information
lehins committed Apr 16, 2024
1 parent b9768c9 commit 546c7e0
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 4 deletions.
3 changes: 2 additions & 1 deletion eras/alonzo/impl/CHANGELOG.md
Expand Up @@ -5,7 +5,8 @@
* Change the type of the balance field in `InsufficientCollateral` to `DeltaCoin`
* Add `ToJSON` instances for `FailureDescription` and `TagMismatchDescription`
* Undeprecate `redeemerPointer`.
* Add `metadataAlonzoTxAuxDataL`, `timelockScriptsAlonzoTxAuxDataL`.
* Add `AlonzoEraTxAuxData` with `plutusScriptsTxAuxDataL`
* Add `metadataAlonzoTxAuxDataL`, `timelockScriptsAlonzoTxAuxDataL` and `plutusScriptsAllegraTxAuxDataL`

## 1.7.0.0

Expand Down
2 changes: 2 additions & 0 deletions eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Core.hs
Expand Up @@ -32,6 +32,7 @@ module Cardano.Ledger.Alonzo.Core (
ppuMaxValSizeL,
ppuCollateralPercentageL,
ppuMaxCollateralInputsL,
AlonzoEraTxAuxData (..),
module Cardano.Ledger.Mary.Core,
)
where
Expand Down Expand Up @@ -67,6 +68,7 @@ import Cardano.Ledger.Alonzo.Scripts (
pattern SpendingPurpose,
)
import Cardano.Ledger.Alonzo.Tx (AlonzoEraTx (..))
import Cardano.Ledger.Alonzo.TxAuxData (AlonzoEraTxAuxData (..))
import Cardano.Ledger.Alonzo.TxBody (AlonzoEraTxBody (..), ScriptIntegrityHash)
import Cardano.Ledger.Alonzo.TxOut (AlonzoEraTxOut (..))
import Cardano.Ledger.Alonzo.TxWits (AlonzoEraTxWits (..))
Expand Down
15 changes: 13 additions & 2 deletions eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxAuxData.hs
Expand Up @@ -15,6 +15,7 @@
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE UndecidableSuperClasses #-}
{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}

Expand All @@ -30,6 +31,7 @@ module Cardano.Ledger.Alonzo.TxAuxData (
atadTimelock',
atadPlutus'
),
AlonzoEraTxAuxData (..),
AlonzoTxAuxDataRaw,
mkAlonzoTxAuxData,
AuxiliaryDataHash (..),
Expand All @@ -39,6 +41,7 @@ module Cardano.Ledger.Alonzo.TxAuxData (
translateAlonzoTxAuxData,
metadataAlonzoTxAuxDataL,
timelockScriptsAlonzoTxAuxDataL,
plutusScriptsAllegraTxAuxDataL,

-- * Deprecated
AuxiliaryData,
Expand Down Expand Up @@ -99,8 +102,8 @@ import GHC.Stack
import Lens.Micro (Lens')
import NoThunks.Class (InspectHeapNamed (..), NoThunks)

-- =============================================================================
-- Version without serialized bytes
class AllegraEraTxAuxData era => AlonzoEraTxAuxData era where
plutusScriptsTxAuxDataL :: Lens' (TxAuxData era) (Map Language (NE.NonEmpty PlutusBinary))

data AlonzoTxAuxDataRaw era = AlonzoTxAuxDataRaw
{ atadrMetadata :: !(Map Word64 Metadatum)
Expand Down Expand Up @@ -301,6 +304,14 @@ timelockScriptsAlonzoTxAuxDataL ::
timelockScriptsAlonzoTxAuxDataL =
lensMemoRawType atadrTimelock $ \txAuxDataRaw ts -> txAuxDataRaw {atadrTimelock = ts}

instance Crypto c => AlonzoEraTxAuxData (AlonzoEra c) where
plutusScriptsTxAuxDataL = plutusScriptsAllegraTxAuxDataL

plutusScriptsAllegraTxAuxDataL ::
Era era => Lens' (AlonzoTxAuxData era) (Map Language (NE.NonEmpty PlutusBinary))
plutusScriptsAllegraTxAuxDataL =
lensMemoRawType atadrPlutus $ \txAuxDataRaw ts -> txAuxDataRaw {atadrPlutus = ts}

instance EraCrypto era ~ c => HashAnnotated (AuxiliaryData era) EraIndependentTxAuxData c where
hashAnnotated = getMemoSafeHash

Expand Down
4 changes: 4 additions & 0 deletions eras/babbage/impl/src/Cardano/Ledger/Babbage/TxAuxData.hs
Expand Up @@ -8,6 +8,7 @@ import Cardano.Ledger.Alonzo.TxAuxData (
AlonzoTxAuxData (..),
hashAlonzoTxAuxData,
metadataAlonzoTxAuxDataL,
plutusScriptsAllegraTxAuxDataL,
timelockScriptsAlonzoTxAuxDataL,
translateAlonzoTxAuxData,
validateAlonzoTxAuxData,
Expand All @@ -31,3 +32,6 @@ instance Crypto c => EraTxAuxData (BabbageEra c) where

instance Crypto c => AllegraEraTxAuxData (BabbageEra c) where
timelockScriptsTxAuxDataL = timelockScriptsAlonzoTxAuxDataL

instance Crypto c => AlonzoEraTxAuxData (BabbageEra c) where
plutusScriptsTxAuxDataL = plutusScriptsAllegraTxAuxDataL
4 changes: 4 additions & 0 deletions eras/conway/impl/src/Cardano/Ledger/Conway/TxAuxData.hs
Expand Up @@ -8,6 +8,7 @@ import Cardano.Ledger.Alonzo.TxAuxData (
AlonzoTxAuxData (..),
hashAlonzoTxAuxData,
metadataAlonzoTxAuxDataL,
plutusScriptsAllegraTxAuxDataL,
timelockScriptsAlonzoTxAuxDataL,
translateAlonzoTxAuxData,
validateAlonzoTxAuxData,
Expand All @@ -31,3 +32,6 @@ instance Crypto c => EraTxAuxData (ConwayEra c) where

instance Crypto c => AllegraEraTxAuxData (ConwayEra c) where
timelockScriptsTxAuxDataL = timelockScriptsAlonzoTxAuxDataL

instance Crypto c => AlonzoEraTxAuxData (ConwayEra c) where
plutusScriptsTxAuxDataL = plutusScriptsAllegraTxAuxDataL
4 changes: 3 additions & 1 deletion libs/cardano-ledger-api/CHANGELOG.md
Expand Up @@ -5,6 +5,7 @@
* Add `redeemerPointer` and `redeemerPointerInverse`.
* Export `mkBasicTxAuxData` and `metadataTxAuxDataL`.
* Export `AllegraEraTxAuxData` and `timelockScriptsTxAuxDataL`
* Export `AlonzoEraTxAuxData` and `plutusScriptsTxAuxDataL`

## 1.9.0.0

Expand All @@ -22,7 +23,8 @@
* Deprecate `deserialiseRewardAcnt` in favor of `deserialiseRewardAccount`
* Deprecate `serialiseRewardAcnt` in favor of `serialiseRewardAccount`
* Deprecate `RewardAcnt` in favor of `RewardAccount`
* Remove `registerInitialFunds`, `registerInitialStaking`, `registerInitialDReps`, and `registerDelegs` in favor of `injectIntoTestState`.
* Remove `registerInitialFunds`, `registerInitialStaking`, `registerInitialDReps`, and
`registerDelegs` in favor of `injectIntoTestState`.
* Change the semantics of `createInitialState` to not register any initial funds or delegates.

## 1.8.0.0
Expand Down
3 changes: 3 additions & 0 deletions libs/cardano-ledger-api/src/Cardano/Ledger/Api/Tx/AuxData.hs
Expand Up @@ -16,6 +16,8 @@ module Cardano.Ledger.Api.Tx.AuxData (
AllegraTxAuxData (..),

-- * Alonzo
AlonzoEraTxAuxData,
plutusScriptsTxAuxDataL,
AlonzoTxAuxData (..),
mkAlonzoTxAuxData,
getAlonzoTxAuxDataScripts,
Expand All @@ -24,6 +26,7 @@ where

import Cardano.Ledger.Allegra.TxAuxData (AllegraEraTxAuxData (..), AllegraTxAuxData (..))
import Cardano.Ledger.Alonzo.TxAuxData (
AlonzoEraTxAuxData (..),
AlonzoTxAuxData (..),
getAlonzoTxAuxDataScripts,
mkAlonzoTxAuxData,
Expand Down

0 comments on commit 546c7e0

Please sign in to comment.