{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE UndecidableSuperClasses #-}
{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}

module Cardano.Ledger.Alonzo.TxAuxData (
  -- * AlonzoTxAuxData
  AlonzoTxAuxData (
    AlonzoTxAuxData,
    AlonzoTxAuxData',
    atadMetadata,
    atadTimelock,
    atadPlutus,
    atadMetadata',
    atadTimelock',
    atadPlutus'
  ),
  AlonzoEraTxAuxData (..),
  AlonzoTxAuxDataRaw,
  mkAlonzoTxAuxData,
  hashAlonzoTxAuxData,
  validateAlonzoTxAuxData,
  getAlonzoTxAuxDataScripts,
  translateAlonzoTxAuxData,
  metadataAlonzoTxAuxDataL,
  timelockScriptsAlonzoTxAuxDataL,
  plutusScriptsAllegraTxAuxDataL,
)
where

import Cardano.Ledger.Allegra.Scripts (Timelock, translateTimelock)
import Cardano.Ledger.Allegra.TxAuxData (AllegraEraTxAuxData (..), AllegraTxAuxData (..))
import Cardano.Ledger.Alonzo.Era
import Cardano.Ledger.Alonzo.Scripts (
  AlonzoEraScript (..),
  AlonzoScript (..),
  mkBinaryPlutusScript,
  plutusScriptBinary,
  plutusScriptLanguage,
  validScript,
 )
import Cardano.Ledger.BaseTypes (ProtVer)
import Cardano.Ledger.Binary (
  Annotator (..),
  DecCBOR (..),
  EncCBOR (..),
  ToCBOR,
  TokenType (..),
  decodeStrictSeq,
  peekTokenType,
 )
import Cardano.Ledger.Binary.Coders
import Cardano.Ledger.Core
import Cardano.Ledger.MemoBytes (
  EqRaw,
  Mem,
  MemoBytes (..),
  MemoHashIndex,
  Memoized (RawType),
  getMemoRawType,
  getMemoSafeHash,
  lensMemoRawType,
  mkMemoized,
 )
import Cardano.Ledger.Plutus.Language (Language (..), PlutusBinary (..), guardPlutus)
import Cardano.Ledger.Shelley.TxAuxData (Metadatum, validMetadatum)
import Control.DeepSeq (NFData, deepseq)
import Data.List (intercalate)
import qualified Data.List.NonEmpty as NE
import Data.Map (Map)
import qualified Data.Map.Strict as Map
import Data.Maybe (isNothing, mapMaybe)
import Data.Sequence.Strict (StrictSeq ((:<|)))
import qualified Data.Sequence.Strict as StrictSeq
import Data.Word (Word64)
import GHC.Generics (Generic)
import GHC.Stack
import Lens.Micro (Lens')
import NoThunks.Class (InspectHeapNamed (..), NoThunks)

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

data AlonzoTxAuxDataRaw era = AlonzoTxAuxDataRaw
  { forall era. AlonzoTxAuxDataRaw era -> Map Word64 Metadatum
atadrMetadata :: !(Map Word64 Metadatum)
  , forall era. AlonzoTxAuxDataRaw era -> StrictSeq (Timelock era)
atadrTimelock :: !(StrictSeq (Timelock era))
  , forall era.
AlonzoTxAuxDataRaw era -> Map Language (NonEmpty PlutusBinary)
atadrPlutus :: !(Map Language (NE.NonEmpty PlutusBinary))
  }
  deriving (forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall era x.
Rep (AlonzoTxAuxDataRaw era) x -> AlonzoTxAuxDataRaw era
forall era x.
AlonzoTxAuxDataRaw era -> Rep (AlonzoTxAuxDataRaw era) x
$cto :: forall era x.
Rep (AlonzoTxAuxDataRaw era) x -> AlonzoTxAuxDataRaw era
$cfrom :: forall era x.
AlonzoTxAuxDataRaw era -> Rep (AlonzoTxAuxDataRaw era) x
Generic)

deriving instance Eq (Timelock era) => Eq (AlonzoTxAuxDataRaw era)

deriving instance Show (Timelock era) => Show (AlonzoTxAuxDataRaw era)

instance NFData (Timelock era) => NFData (AlonzoTxAuxDataRaw era)

deriving via
  InspectHeapNamed "AlonzoTxAuxDataRaw" (AlonzoTxAuxDataRaw era)
  instance
    NoThunks (AlonzoTxAuxDataRaw era)

-- | Encodes memoized bytes created upon construction.
instance Era era => EncCBOR (AlonzoTxAuxData era)

instance Era era => EncCBOR (AlonzoTxAuxDataRaw era) where
  encCBOR :: AlonzoTxAuxDataRaw era -> Encoding
encCBOR AlonzoTxAuxDataRaw {Map Word64 Metadatum
atadrMetadata :: Map Word64 Metadatum
atadrMetadata :: forall era. AlonzoTxAuxDataRaw era -> Map Word64 Metadatum
atadrMetadata, StrictSeq (Timelock era)
atadrTimelock :: StrictSeq (Timelock era)
atadrTimelock :: forall era. AlonzoTxAuxDataRaw era -> StrictSeq (Timelock era)
atadrTimelock, Map Language (NonEmpty PlutusBinary)
atadrPlutus :: Map Language (NonEmpty PlutusBinary)
atadrPlutus :: forall era.
AlonzoTxAuxDataRaw era -> Map Language (NonEmpty PlutusBinary)
atadrPlutus} =
    forall (w :: Wrapped) t. Encode w t -> Encoding
encode forall a b. (a -> b) -> a -> b
$
      forall (x :: Density) t.
Word -> Encode ('Closed x) t -> Encode ('Closed x) t
Tag Word
259 forall a b. (a -> b) -> a -> b
$
        forall t. t -> Encode ('Closed 'Sparse) t
Keyed
          ( \Map Word64 Metadatum
m StrictSeq (Timelock era)
ts Maybe (NonEmpty PlutusBinary)
mps1 Maybe (NonEmpty PlutusBinary)
mps2 Maybe (NonEmpty PlutusBinary)
mps3 ->
              forall era.
Map Word64 Metadatum
-> StrictSeq (Timelock era)
-> Map Language (NonEmpty PlutusBinary)
-> AlonzoTxAuxDataRaw era
AlonzoTxAuxDataRaw Map Word64 Metadatum
m StrictSeq (Timelock era)
ts forall a b. (a -> b) -> a -> b
$
                forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
                  [ (Language
pv, NonEmpty PlutusBinary
ps)
                  | (Language
pv, Just NonEmpty PlutusBinary
ps) <-
                      [ (Language
PlutusV1, Maybe (NonEmpty PlutusBinary)
mps1)
                      , (Language
PlutusV2, Maybe (NonEmpty PlutusBinary)
mps2)
                      , (Language
PlutusV3, Maybe (NonEmpty PlutusBinary)
mps3)
                      ]
                  ]
          )
          forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t.
(t -> Bool)
-> Encode ('Closed 'Sparse) t -> Encode ('Closed 'Sparse) t
Omit forall (t :: * -> *) a. Foldable t => t a -> Bool
null (forall t.
Word -> Encode ('Closed 'Dense) t -> Encode ('Closed 'Sparse) t
Key Word
0 forall a b. (a -> b) -> a -> b
$ forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To Map Word64 Metadatum
atadrMetadata)
          forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t.
(t -> Bool)
-> Encode ('Closed 'Sparse) t -> Encode ('Closed 'Sparse) t
Omit forall (t :: * -> *) a. Foldable t => t a -> Bool
null (forall t.
Word -> Encode ('Closed 'Dense) t -> Encode ('Closed 'Sparse) t
Key Word
1 forall a b. (a -> b) -> a -> b
$ forall t. EncCBOR t => t -> Encode ('Closed 'Dense) t
To StrictSeq (Timelock era)
atadrTimelock)
          forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t.
(t -> Bool)
-> Encode ('Closed 'Sparse) t -> Encode ('Closed 'Sparse) t
Omit forall a. Maybe a -> Bool
isNothing (forall t.
Word -> Encode ('Closed 'Dense) t -> Encode ('Closed 'Sparse) t
Key Word
2 forall a b. (a -> b) -> a -> b
$ forall t. (t -> Encoding) -> t -> Encode ('Closed 'Dense) t
E (forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall a. Monoid a => a
mempty forall a. EncCBOR a => a -> Encoding
encCBOR) (forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup Language
PlutusV1 Map Language (NonEmpty PlutusBinary)
atadrPlutus))
          forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t.
(t -> Bool)
-> Encode ('Closed 'Sparse) t -> Encode ('Closed 'Sparse) t
Omit forall a. Maybe a -> Bool
isNothing (forall t.
Word -> Encode ('Closed 'Dense) t -> Encode ('Closed 'Sparse) t
Key Word
3 forall a b. (a -> b) -> a -> b
$ forall t. (t -> Encoding) -> t -> Encode ('Closed 'Dense) t
E (forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall a. Monoid a => a
mempty forall a. EncCBOR a => a -> Encoding
encCBOR) (forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup Language
PlutusV2 Map Language (NonEmpty PlutusBinary)
atadrPlutus))
          forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode ('Closed r) a -> Encode w t
!> forall t.
(t -> Bool)
-> Encode ('Closed 'Sparse) t -> Encode ('Closed 'Sparse) t
Omit forall a. Maybe a -> Bool
isNothing (forall t.
Word -> Encode ('Closed 'Dense) t -> Encode ('Closed 'Sparse) t
Key Word
4 forall a b. (a -> b) -> a -> b
$ forall t. (t -> Encoding) -> t -> Encode ('Closed 'Dense) t
E (forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall a. Monoid a => a
mempty forall a. EncCBOR a => a -> Encoding
encCBOR) (forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup Language
PlutusV3 Map Language (NonEmpty PlutusBinary)
atadrPlutus))

-- | Helper function that will construct Auxiliary data from Metadatum map and a list of scripts.
--
-- Note that the relative order of same type scripts will be preserved.
mkAlonzoTxAuxData ::
  forall f era.
  (Foldable f, AlonzoEraScript era) =>
  Map Word64 Metadatum ->
  f (AlonzoScript era) ->
  AlonzoTxAuxData era
mkAlonzoTxAuxData :: forall (f :: * -> *) era.
(Foldable f, AlonzoEraScript era) =>
Map Word64 Metadatum -> f (AlonzoScript era) -> AlonzoTxAuxData era
mkAlonzoTxAuxData Map Word64 Metadatum
atadrMetadata f (AlonzoScript era)
allScripts =
  forall era (t :: * -> *).
(Era era, EncCBOR (RawType t era), Memoized t) =>
RawType t era -> t era
mkMemoized forall a b. (a -> b) -> a -> b
$ AlonzoTxAuxDataRaw {Map Word64 Metadatum
atadrMetadata :: Map Word64 Metadatum
atadrMetadata :: Map Word64 Metadatum
atadrMetadata, StrictSeq (Timelock era)
atadrTimelock :: StrictSeq (Timelock era)
atadrTimelock :: StrictSeq (Timelock era)
atadrTimelock, Map Language (NonEmpty PlutusBinary)
atadrPlutus :: Map Language (NonEmpty PlutusBinary)
atadrPlutus :: Map Language (NonEmpty PlutusBinary)
atadrPlutus}
  where
    partitionScripts :: (StrictSeq (Timelock era), Map Language (NonEmpty PlutusBinary))
-> AlonzoScript era
-> (StrictSeq (Timelock era), Map Language (NonEmpty PlutusBinary))
partitionScripts (StrictSeq (Timelock era)
tss, Map Language (NonEmpty PlutusBinary)
pss) =
      \case
        TimelockScript Timelock era
ts -> (Timelock era
ts forall a. a -> StrictSeq a -> StrictSeq a
:<| StrictSeq (Timelock era)
tss, Map Language (NonEmpty PlutusBinary)
pss)
        PlutusScript PlutusScript era
ps ->
          let lang :: Language
lang = forall era. AlonzoEraScript era => PlutusScript era -> Language
plutusScriptLanguage PlutusScript era
ps
              bs :: PlutusBinary
bs = forall era. AlonzoEraScript era => PlutusScript era -> PlutusBinary
plutusScriptBinary PlutusScript era
ps
           in (StrictSeq (Timelock era)
tss, forall k a.
Ord k =>
(Maybe a -> Maybe a) -> k -> Map k a -> Map k a
Map.alter (forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall b a. b -> (a -> b) -> Maybe a -> b
maybe (forall (f :: * -> *) a. Applicative f => a -> f a
pure PlutusBinary
bs) (forall a. a -> NonEmpty a -> NonEmpty a
NE.cons PlutusBinary
bs)) Language
lang Map Language (NonEmpty PlutusBinary)
pss)
    (StrictSeq (Timelock era)
atadrTimelock, Map Language (NonEmpty PlutusBinary)
atadrPlutus) =
      forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (forall a b c. (a -> b -> c) -> b -> a -> c
flip forall {era}.
AlonzoEraScript era =>
(StrictSeq (Timelock era), Map Language (NonEmpty PlutusBinary))
-> AlonzoScript era
-> (StrictSeq (Timelock era), Map Language (NonEmpty PlutusBinary))
partitionScripts) (forall a. Monoid a => a
mempty, forall k a. Map k a
Map.empty) f (AlonzoScript era)
allScripts

getAlonzoTxAuxDataScripts ::
  forall era.
  AlonzoEraScript era =>
  AlonzoTxAuxData era ->
  StrictSeq (AlonzoScript era)
getAlonzoTxAuxDataScripts :: forall era.
AlonzoEraScript era =>
AlonzoTxAuxData era -> StrictSeq (AlonzoScript era)
getAlonzoTxAuxDataScripts AlonzoTxAuxData {atadTimelock :: forall era.
(HasCallStack, AlonzoEraScript era) =>
AlonzoTxAuxData era -> StrictSeq (Timelock era)
atadTimelock = StrictSeq (Timelock era)
timelocks, atadPlutus :: forall era.
(HasCallStack, AlonzoEraScript era) =>
AlonzoTxAuxData era -> Map Language (NonEmpty PlutusBinary)
atadPlutus = Map Language (NonEmpty PlutusBinary)
plutus} =
  forall a. Monoid a => [a] -> a
mconcat forall a b. (a -> b) -> a -> b
$
    (forall era. Timelock era -> AlonzoScript era
TimelockScript forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> StrictSeq (Timelock era)
timelocks)
      forall a. a -> [a] -> [a]
: [ forall a. [a] -> StrictSeq a
StrictSeq.fromList forall a b. (a -> b) -> a -> b
$
            -- It is fine to filter out unsupported languages with mapMaybe, because the invariant for
            -- AlonzoTxAuxData is that it does not contain scripts with languages that are not
            -- supported in this era
            forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall era. PlutusScript era -> AlonzoScript era
PlutusScript forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall era.
AlonzoEraScript era =>
Language -> PlutusBinary -> Maybe (PlutusScript era)
mkBinaryPlutusScript Language
lang) forall a b. (a -> b) -> a -> b
$
              forall a. NonEmpty a -> [a]
NE.toList NonEmpty PlutusBinary
plutusScripts
        | Language
lang <- [Language
PlutusV1 .. forall era. AlonzoEraScript era => Language
eraMaxLanguage @era]
        , Just NonEmpty PlutusBinary
plutusScripts <- [forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup Language
lang Map Language (NonEmpty PlutusBinary)
plutus]
        ]

instance Era era => DecCBOR (Annotator (AlonzoTxAuxDataRaw era)) where
  decCBOR :: forall s. Decoder s (Annotator (AlonzoTxAuxDataRaw era))
decCBOR =
    forall s. Decoder s TokenType
peekTokenType forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
      TokenType
TypeMapLen -> forall {s} {era}. Decoder s (Annotator (AlonzoTxAuxDataRaw era))
decodeShelley
      TokenType
TypeMapLen64 -> forall {s} {era}. Decoder s (Annotator (AlonzoTxAuxDataRaw era))
decodeShelley
      TokenType
TypeMapLenIndef -> forall {s} {era}. Decoder s (Annotator (AlonzoTxAuxDataRaw era))
decodeShelley
      TokenType
TypeListLen -> forall s. Decoder s (Annotator (AlonzoTxAuxDataRaw era))
decodeShelleyMA
      TokenType
TypeListLen64 -> forall s. Decoder s (Annotator (AlonzoTxAuxDataRaw era))
decodeShelleyMA
      TokenType
TypeListLenIndef -> forall s. Decoder s (Annotator (AlonzoTxAuxDataRaw era))
decodeShelleyMA
      TokenType
TypeTag -> Decoder s (Annotator (AlonzoTxAuxDataRaw era))
decodeAlonzo
      TokenType
TypeTag64 -> Decoder s (Annotator (AlonzoTxAuxDataRaw era))
decodeAlonzo
      TokenType
_ -> forall (m :: * -> *) a. MonadFail m => [Char] -> m a
fail [Char]
"Failed to decode AlonzoTxAuxData"
    where
      decodeShelley :: Decoder s (Annotator (AlonzoTxAuxDataRaw era))
decodeShelley =
        forall (w :: Wrapped) t s. Decode w t -> Decoder s t
decode
          ( forall (w :: Wrapped) t1. Decode w t1 -> Decode w (Annotator t1)
Ann (forall t (w :: Wrapped). t -> Decode w t
Emit forall era.
Map Word64 Metadatum
-> StrictSeq (Timelock era)
-> Map Language (NonEmpty PlutusBinary)
-> AlonzoTxAuxDataRaw era
AlonzoTxAuxDataRaw)
              forall (w1 :: Wrapped) a t (d :: Density).
Decode w1 (Annotator (a -> t))
-> Decode ('Closed d) (Annotator a) -> Decode w1 (Annotator t)
<*! forall (w :: Wrapped) t1. Decode w t1 -> Decode w (Annotator t1)
Ann forall t (w :: Wrapped). DecCBOR t => Decode w t
From
              forall (w1 :: Wrapped) a t (d :: Density).
Decode w1 (Annotator (a -> t))
-> Decode ('Closed d) (Annotator a) -> Decode w1 (Annotator t)
<*! forall (w :: Wrapped) t1. Decode w t1 -> Decode w (Annotator t1)
Ann (forall t (w :: Wrapped). t -> Decode w t
Emit forall a. StrictSeq a
StrictSeq.empty)
              forall (w1 :: Wrapped) a t (d :: Density).
Decode w1 (Annotator (a -> t))
-> Decode ('Closed d) (Annotator a) -> Decode w1 (Annotator t)
<*! forall (w :: Wrapped) t1. Decode w t1 -> Decode w (Annotator t1)
Ann (forall t (w :: Wrapped). t -> Decode w t
Emit forall k a. Map k a
Map.empty)
          )
      decodeShelleyMA :: Decoder s (Annotator (AlonzoTxAuxDataRaw era))
decodeShelleyMA =
        forall (w :: Wrapped) t s. Decode w t -> Decoder s t
decode
          ( forall (w :: Wrapped) t1. Decode w t1 -> Decode w (Annotator t1)
Ann (forall t. t -> Decode ('Closed 'Dense) t
RecD forall era.
Map Word64 Metadatum
-> StrictSeq (Timelock era)
-> Map Language (NonEmpty PlutusBinary)
-> AlonzoTxAuxDataRaw era
AlonzoTxAuxDataRaw)
              forall (w1 :: Wrapped) a t (d :: Density).
Decode w1 (Annotator (a -> t))
-> Decode ('Closed d) (Annotator a) -> Decode w1 (Annotator t)
<*! forall (w :: Wrapped) t1. Decode w t1 -> Decode w (Annotator t1)
Ann forall t (w :: Wrapped). DecCBOR t => Decode w t
From
              forall (w1 :: Wrapped) a t (d :: Density).
Decode w1 (Annotator (a -> t))
-> Decode ('Closed d) (Annotator a) -> Decode w1 (Annotator t)
<*! forall t. (forall s. Decoder s t) -> Decode ('Closed 'Dense) t
D
                (forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s a. Decoder s a -> Decoder s (StrictSeq a)
decodeStrictSeq forall a s. DecCBOR a => Decoder s a
decCBOR)
              forall (w1 :: Wrapped) a t (d :: Density).
Decode w1 (Annotator (a -> t))
-> Decode ('Closed d) (Annotator a) -> Decode w1 (Annotator t)
<*! forall (w :: Wrapped) t1. Decode w t1 -> Decode w (Annotator t1)
Ann (forall t (w :: Wrapped). t -> Decode w t
Emit forall k a. Map k a
Map.empty)
          )
      decodeAlonzo :: Decoder s (Annotator (AlonzoTxAuxDataRaw era))
decodeAlonzo =
        forall (w :: Wrapped) t s. Decode w t -> Decoder s t
decode forall a b. (a -> b) -> a -> b
$
          forall (x :: Density) t.
Word -> Decode ('Closed x) t -> Decode ('Closed x) t
TagD Word
259 forall a b. (a -> b) -> a -> b
$
            forall t.
Typeable t =>
[Char]
-> t
-> (Word -> Field t)
-> [(Word, [Char])]
-> Decode ('Closed 'Dense) t
SparseKeyed [Char]
"AlonzoTxAuxData" (forall (f :: * -> *) a. Applicative f => a -> f a
pure forall era. AlonzoTxAuxDataRaw era
emptyAuxData) Word -> Field (Annotator (AlonzoTxAuxDataRaw era))
auxDataField []

      addPlutusScripts :: Language
-> [PlutusBinary]
-> AlonzoTxAuxDataRaw era
-> AlonzoTxAuxDataRaw era
addPlutusScripts Language
lang [PlutusBinary]
scripts AlonzoTxAuxDataRaw era
ad =
        case forall a. [a] -> Maybe (NonEmpty a)
NE.nonEmpty [PlutusBinary]
scripts of
          Maybe (NonEmpty PlutusBinary)
Nothing -> AlonzoTxAuxDataRaw era
ad
          Just NonEmpty PlutusBinary
neScripts ->
            -- Avoid leaks by deepseq, since non empty list is lazy.
            NonEmpty PlutusBinary
neScripts forall a b. NFData a => a -> b -> b
`deepseq` AlonzoTxAuxDataRaw era
ad {atadrPlutus :: Map Language (NonEmpty PlutusBinary)
atadrPlutus = forall k a. Ord k => k -> a -> Map k a -> Map k a
Map.insert Language
lang NonEmpty PlutusBinary
neScripts forall a b. (a -> b) -> a -> b
$ forall era.
AlonzoTxAuxDataRaw era -> Map Language (NonEmpty PlutusBinary)
atadrPlutus AlonzoTxAuxDataRaw era
ad}

      auxDataField :: Word -> Field (Annotator (AlonzoTxAuxDataRaw era))
      auxDataField :: Word -> Field (Annotator (AlonzoTxAuxDataRaw era))
auxDataField Word
0 = forall (ann :: * -> *) x t (d :: Density).
Applicative ann =>
(x -> t -> t) -> Decode ('Closed d) x -> Field (ann t)
fieldA (\Map Word64 Metadatum
x AlonzoTxAuxDataRaw era
ad -> AlonzoTxAuxDataRaw era
ad {atadrMetadata :: Map Word64 Metadatum
atadrMetadata = Map Word64 Metadatum
x}) forall t (w :: Wrapped). DecCBOR t => Decode w t
From
      auxDataField Word
1 =
        forall (ann :: * -> *) x t (d :: Density).
Applicative ann =>
(x -> t -> t) -> Decode ('Closed d) (ann x) -> Field (ann t)
fieldAA
          (\StrictSeq (Timelock era)
x AlonzoTxAuxDataRaw era
ad -> AlonzoTxAuxDataRaw era
ad {atadrTimelock :: StrictSeq (Timelock era)
atadrTimelock = forall era. AlonzoTxAuxDataRaw era -> StrictSeq (Timelock era)
atadrTimelock AlonzoTxAuxDataRaw era
ad forall a. Semigroup a => a -> a -> a
<> StrictSeq (Timelock era)
x})
          (forall t. (forall s. Decoder s t) -> Decode ('Closed 'Dense) t
D (forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s a. Decoder s a -> Decoder s (StrictSeq a)
decodeStrictSeq forall a s. DecCBOR a => Decoder s a
decCBOR))
      auxDataField Word
2 = forall (ann :: * -> *) x t (d :: Density).
Applicative ann =>
(x -> t -> t) -> Decode ('Closed d) x -> Field (ann t)
fieldA (forall {era}.
Language
-> [PlutusBinary]
-> AlonzoTxAuxDataRaw era
-> AlonzoTxAuxDataRaw era
addPlutusScripts Language
PlutusV1) (forall t. (forall s. Decoder s t) -> Decode ('Closed 'Dense) t
D (forall s. Language -> Decoder s ()
guardPlutus Language
PlutusV1 forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall a s. DecCBOR a => Decoder s a
decCBOR))
      auxDataField Word
3 = forall (ann :: * -> *) x t (d :: Density).
Applicative ann =>
(x -> t -> t) -> Decode ('Closed d) x -> Field (ann t)
fieldA (forall {era}.
Language
-> [PlutusBinary]
-> AlonzoTxAuxDataRaw era
-> AlonzoTxAuxDataRaw era
addPlutusScripts Language
PlutusV2) (forall t. (forall s. Decoder s t) -> Decode ('Closed 'Dense) t
D (forall s. Language -> Decoder s ()
guardPlutus Language
PlutusV2 forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall a s. DecCBOR a => Decoder s a
decCBOR))
      auxDataField Word
4 = forall (ann :: * -> *) x t (d :: Density).
Applicative ann =>
(x -> t -> t) -> Decode ('Closed d) x -> Field (ann t)
fieldA (forall {era}.
Language
-> [PlutusBinary]
-> AlonzoTxAuxDataRaw era
-> AlonzoTxAuxDataRaw era
addPlutusScripts Language
PlutusV3) (forall t. (forall s. Decoder s t) -> Decode ('Closed 'Dense) t
D (forall s. Language -> Decoder s ()
guardPlutus Language
PlutusV3 forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall a s. DecCBOR a => Decoder s a
decCBOR))
      auxDataField Word
n = forall x t (d :: Density).
(x -> t -> t) -> Decode ('Closed d) x -> Field t
field (\Any
_ Annotator (AlonzoTxAuxDataRaw era)
t -> Annotator (AlonzoTxAuxDataRaw era)
t) (forall (w :: Wrapped) t. Word -> Decode w t
Invalid Word
n)

emptyAuxData :: AlonzoTxAuxDataRaw era
emptyAuxData :: forall era. AlonzoTxAuxDataRaw era
emptyAuxData = forall era.
Map Word64 Metadatum
-> StrictSeq (Timelock era)
-> Map Language (NonEmpty PlutusBinary)
-> AlonzoTxAuxDataRaw era
AlonzoTxAuxDataRaw forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty

-- ================================================================================
-- Version with serialized bytes.

newtype AlonzoTxAuxData era = AlonzoTxAuxDataConstr (MemoBytes AlonzoTxAuxDataRaw era)
  deriving (forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall era x. Rep (AlonzoTxAuxData era) x -> AlonzoTxAuxData era
forall era x. AlonzoTxAuxData era -> Rep (AlonzoTxAuxData era) x
$cto :: forall era x. Rep (AlonzoTxAuxData era) x -> AlonzoTxAuxData era
$cfrom :: forall era x. AlonzoTxAuxData era -> Rep (AlonzoTxAuxData era) x
Generic)
  deriving newtype (AlonzoTxAuxData era -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [AlonzoTxAuxData era] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (AlonzoTxAuxData era) -> Size
forall {era}. Typeable era => Typeable (AlonzoTxAuxData era)
forall era. Typeable era => AlonzoTxAuxData era -> Encoding
forall a.
Typeable a
-> (a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
forall era.
Typeable era =>
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [AlonzoTxAuxData era] -> Size
forall era.
Typeable era =>
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (AlonzoTxAuxData era) -> Size
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [AlonzoTxAuxData era] -> Size
$cencodedListSizeExpr :: forall era.
Typeable era =>
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [AlonzoTxAuxData era] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (AlonzoTxAuxData era) -> Size
$cencodedSizeExpr :: forall era.
Typeable era =>
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy (AlonzoTxAuxData era) -> Size
toCBOR :: AlonzoTxAuxData era -> Encoding
$ctoCBOR :: forall era. Typeable era => AlonzoTxAuxData era -> Encoding
ToCBOR, AlonzoTxAuxData era -> Int
AlonzoTxAuxData era -> ByteString
forall i. Proxy i -> AlonzoTxAuxData era -> SafeHash i
forall era. AlonzoTxAuxData era -> Int
forall era. AlonzoTxAuxData era -> ByteString
forall t.
(t -> ByteString)
-> (t -> Int)
-> (forall i. Proxy i -> t -> SafeHash i)
-> SafeToHash t
forall era i. Proxy i -> AlonzoTxAuxData era -> SafeHash i
makeHashWithExplicitProxys :: forall i. Proxy i -> AlonzoTxAuxData era -> SafeHash i
$cmakeHashWithExplicitProxys :: forall era i. Proxy i -> AlonzoTxAuxData era -> SafeHash i
originalBytesSize :: AlonzoTxAuxData era -> Int
$coriginalBytesSize :: forall era. AlonzoTxAuxData era -> Int
originalBytes :: AlonzoTxAuxData era -> ByteString
$coriginalBytes :: forall era. AlonzoTxAuxData era -> ByteString
SafeToHash)

instance Memoized AlonzoTxAuxData where
  type RawType AlonzoTxAuxData = AlonzoTxAuxDataRaw

instance EqRaw (AlonzoTxAuxData era)

instance EraTxAuxData AlonzoEra where
  type TxAuxData AlonzoEra = AlonzoTxAuxData AlonzoEra

  mkBasicTxAuxData :: TxAuxData AlonzoEra
mkBasicTxAuxData = forall era.
(HasCallStack, AlonzoEraScript era) =>
Map Word64 Metadatum
-> StrictSeq (Timelock era)
-> Map Language (NonEmpty PlutusBinary)
-> AlonzoTxAuxData era
AlonzoTxAuxData forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty

  metadataTxAuxDataL :: Lens' (TxAuxData AlonzoEra) (Map Word64 Metadatum)
metadataTxAuxDataL = forall era.
Era era =>
Lens' (AlonzoTxAuxData era) (Map Word64 Metadatum)
metadataAlonzoTxAuxDataL

  upgradeTxAuxData :: EraTxAuxData (PreviousEra AlonzoEra) =>
TxAuxData (PreviousEra AlonzoEra) -> TxAuxData AlonzoEra
upgradeTxAuxData (AllegraTxAuxData Map Word64 Metadatum
md StrictSeq (Timelock MaryEra)
scripts) =
    forall era (t :: * -> *).
(Era era, EncCBOR (RawType t era), Memoized t) =>
RawType t era -> t era
mkMemoized forall a b. (a -> b) -> a -> b
$
      AlonzoTxAuxDataRaw
        { atadrMetadata :: Map Word64 Metadatum
atadrMetadata = Map Word64 Metadatum
md
        , atadrTimelock :: StrictSeq (Timelock AlonzoEra)
atadrTimelock = forall era1 era2.
(Era era1, Era era2) =>
Timelock era1 -> Timelock era2
translateTimelock forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> StrictSeq (Timelock MaryEra)
scripts
        , atadrPlutus :: Map Language (NonEmpty PlutusBinary)
atadrPlutus = forall a. Monoid a => a
mempty
        }

  validateTxAuxData :: ProtVer -> TxAuxData AlonzoEra -> Bool
validateTxAuxData = forall era.
(AlonzoEraScript era, Script era ~ AlonzoScript era) =>
ProtVer -> AlonzoTxAuxData era -> Bool
validateAlonzoTxAuxData

metadataAlonzoTxAuxDataL :: Era era => Lens' (AlonzoTxAuxData era) (Map Word64 Metadatum)
metadataAlonzoTxAuxDataL :: forall era.
Era era =>
Lens' (AlonzoTxAuxData era) (Map Word64 Metadatum)
metadataAlonzoTxAuxDataL =
  forall era (t :: * -> *) a b.
(Era era, EncCBOR (RawType t era), Memoized t) =>
(RawType t era -> a)
-> (RawType t era -> b -> RawType t era)
-> Lens (t era) (t era) a b
lensMemoRawType forall era. AlonzoTxAuxDataRaw era -> Map Word64 Metadatum
atadrMetadata forall a b. (a -> b) -> a -> b
$ \RawType AlonzoTxAuxData era
txAuxDataRaw Map Word64 Metadatum
md -> RawType AlonzoTxAuxData era
txAuxDataRaw {atadrMetadata :: Map Word64 Metadatum
atadrMetadata = Map Word64 Metadatum
md}

hashAlonzoTxAuxData ::
  HashAnnotated x EraIndependentTxAuxData =>
  x ->
  TxAuxDataHash
hashAlonzoTxAuxData :: forall x.
HashAnnotated x EraIndependentTxAuxData =>
x -> TxAuxDataHash
hashAlonzoTxAuxData x
x = SafeHash EraIndependentTxAuxData -> TxAuxDataHash
TxAuxDataHash (forall x i. HashAnnotated x i => x -> SafeHash i
hashAnnotated x
x)
{-# DEPRECATED hashAlonzoTxAuxData "In favor of `hashTxAuxData`" #-}

validateAlonzoTxAuxData ::
  (AlonzoEraScript era, Script era ~ AlonzoScript era) =>
  ProtVer ->
  AlonzoTxAuxData era ->
  Bool
validateAlonzoTxAuxData :: forall era.
(AlonzoEraScript era, Script era ~ AlonzoScript era) =>
ProtVer -> AlonzoTxAuxData era -> Bool
validateAlonzoTxAuxData ProtVer
pv auxData :: AlonzoTxAuxData era
auxData@AlonzoTxAuxData {atadMetadata :: forall era.
(HasCallStack, AlonzoEraScript era) =>
AlonzoTxAuxData era -> Map Word64 Metadatum
atadMetadata = Map Word64 Metadatum
metadata} =
  forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all Metadatum -> Bool
validMetadatum Map Word64 Metadatum
metadata
    Bool -> Bool -> Bool
&& forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (forall era.
(HasCallStack, AlonzoEraScript era) =>
ProtVer -> Script era -> Bool
validScript ProtVer
pv) (forall era.
AlonzoEraScript era =>
AlonzoTxAuxData era -> StrictSeq (AlonzoScript era)
getAlonzoTxAuxDataScripts AlonzoTxAuxData era
auxData)

instance AllegraEraTxAuxData AlonzoEra where
  timelockScriptsTxAuxDataL :: Lens' (TxAuxData AlonzoEra) (StrictSeq (Timelock AlonzoEra))
timelockScriptsTxAuxDataL = forall era.
Era era =>
Lens' (AlonzoTxAuxData era) (StrictSeq (Timelock era))
timelockScriptsAlonzoTxAuxDataL

timelockScriptsAlonzoTxAuxDataL ::
  Era era => Lens' (AlonzoTxAuxData era) (StrictSeq (Timelock era))
timelockScriptsAlonzoTxAuxDataL :: forall era.
Era era =>
Lens' (AlonzoTxAuxData era) (StrictSeq (Timelock era))
timelockScriptsAlonzoTxAuxDataL =
  forall era (t :: * -> *) a b.
(Era era, EncCBOR (RawType t era), Memoized t) =>
(RawType t era -> a)
-> (RawType t era -> b -> RawType t era)
-> Lens (t era) (t era) a b
lensMemoRawType forall era. AlonzoTxAuxDataRaw era -> StrictSeq (Timelock era)
atadrTimelock forall a b. (a -> b) -> a -> b
$ \RawType AlonzoTxAuxData era
txAuxDataRaw StrictSeq (Timelock era)
ts -> RawType AlonzoTxAuxData era
txAuxDataRaw {atadrTimelock :: StrictSeq (Timelock era)
atadrTimelock = StrictSeq (Timelock era)
ts}

instance AlonzoEraTxAuxData AlonzoEra where
  plutusScriptsTxAuxDataL :: Lens' (TxAuxData AlonzoEra) (Map Language (NonEmpty PlutusBinary))
plutusScriptsTxAuxDataL = forall era.
Era era =>
Lens' (AlonzoTxAuxData era) (Map Language (NonEmpty PlutusBinary))
plutusScriptsAllegraTxAuxDataL

plutusScriptsAllegraTxAuxDataL ::
  Era era => Lens' (AlonzoTxAuxData era) (Map Language (NE.NonEmpty PlutusBinary))
plutusScriptsAllegraTxAuxDataL :: forall era.
Era era =>
Lens' (AlonzoTxAuxData era) (Map Language (NonEmpty PlutusBinary))
plutusScriptsAllegraTxAuxDataL =
  forall era (t :: * -> *) a b.
(Era era, EncCBOR (RawType t era), Memoized t) =>
(RawType t era -> a)
-> (RawType t era -> b -> RawType t era)
-> Lens (t era) (t era) a b
lensMemoRawType forall era.
AlonzoTxAuxDataRaw era -> Map Language (NonEmpty PlutusBinary)
atadrPlutus forall a b. (a -> b) -> a -> b
$ \RawType AlonzoTxAuxData era
txAuxDataRaw Map Language (NonEmpty PlutusBinary)
ts -> RawType AlonzoTxAuxData era
txAuxDataRaw {atadrPlutus :: Map Language (NonEmpty PlutusBinary)
atadrPlutus = Map Language (NonEmpty PlutusBinary)
ts}

instance HashAnnotated (AlonzoTxAuxData era) EraIndependentTxAuxData where
  hashAnnotated :: AlonzoTxAuxData era -> SafeHash EraIndependentTxAuxData
hashAnnotated = forall (t :: * -> *) era.
Memoized t =>
t era -> SafeHash (MemoHashIndex (RawType t))
getMemoSafeHash

deriving newtype instance NFData (AlonzoTxAuxData era)

deriving instance Eq (AlonzoTxAuxData era)

deriving instance Show (AlonzoTxAuxData era)

type instance MemoHashIndex AlonzoTxAuxDataRaw = EraIndependentTxAuxData

deriving via
  InspectHeapNamed "AlonzoTxAuxDataRaw" (AlonzoTxAuxData era)
  instance
    NoThunks (AlonzoTxAuxData era)

deriving via
  (Mem AlonzoTxAuxDataRaw era)
  instance
    Era era => DecCBOR (Annotator (AlonzoTxAuxData era))

-- | Construct auxiliary data. Make sure not to supply plutus script versions that are not
-- supported in this era, because it will result in a runtime exception. Use
-- `mkAlonzoTxAuxData` instead if you need runtime safety guarantees.
pattern AlonzoTxAuxData ::
  forall era.
  (HasCallStack, AlonzoEraScript era) =>
  Map Word64 Metadatum ->
  StrictSeq (Timelock era) ->
  Map Language (NE.NonEmpty PlutusBinary) ->
  AlonzoTxAuxData era
pattern $bAlonzoTxAuxData :: forall era.
(HasCallStack, AlonzoEraScript era) =>
Map Word64 Metadatum
-> StrictSeq (Timelock era)
-> Map Language (NonEmpty PlutusBinary)
-> AlonzoTxAuxData era
$mAlonzoTxAuxData :: forall {r} {era}.
(HasCallStack, AlonzoEraScript era) =>
AlonzoTxAuxData era
-> (Map Word64 Metadatum
    -> StrictSeq (Timelock era)
    -> Map Language (NonEmpty PlutusBinary)
    -> r)
-> ((# #) -> r)
-> r
AlonzoTxAuxData {forall era.
(HasCallStack, AlonzoEraScript era) =>
AlonzoTxAuxData era -> Map Word64 Metadatum
atadMetadata, forall era.
(HasCallStack, AlonzoEraScript era) =>
AlonzoTxAuxData era -> StrictSeq (Timelock era)
atadTimelock, forall era.
(HasCallStack, AlonzoEraScript era) =>
AlonzoTxAuxData era -> Map Language (NonEmpty PlutusBinary)
atadPlutus} <-
  (getMemoRawType -> AlonzoTxAuxDataRaw atadMetadata atadTimelock atadPlutus)
  where
    AlonzoTxAuxData Map Word64 Metadatum
atadrMetadata StrictSeq (Timelock era)
atadrTimelock Map Language (NonEmpty PlutusBinary)
atadrPlutus =
      let unsupportedScripts :: Map Language (NonEmpty PlutusBinary)
unsupportedScripts =
            forall k a. (k -> a -> Bool) -> Map k a -> Map k a
Map.filterWithKey (\Language
lang NonEmpty PlutusBinary
_ -> Language
lang forall a. Ord a => a -> a -> Bool
> forall era. AlonzoEraScript era => Language
eraMaxLanguage @era) Map Language (NonEmpty PlutusBinary)
atadrPlutus
          prefix :: [Char]
prefix =
            forall a. [a] -> [[a]] -> [a]
intercalate [Char]
"," (forall a. Show a => a -> [Char]
show forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall k a. Map k a -> [k]
Map.keys Map Language (NonEmpty PlutusBinary)
unsupportedScripts)
              forall a. [a] -> [a] -> [a]
++ if forall k a. Map k a -> Int
Map.size Map Language (NonEmpty PlutusBinary)
unsupportedScripts forall a. Ord a => a -> a -> Bool
> Int
1 then [Char]
" languages are" else [Char]
" language is"
       in if forall k a. Map k a -> Bool
Map.null Map Language (NonEmpty PlutusBinary)
unsupportedScripts
            then forall era (t :: * -> *).
(Era era, EncCBOR (RawType t era), Memoized t) =>
RawType t era -> t era
mkMemoized forall a b. (a -> b) -> a -> b
$ AlonzoTxAuxDataRaw {Map Word64 Metadatum
atadrMetadata :: Map Word64 Metadatum
atadrMetadata :: Map Word64 Metadatum
atadrMetadata, StrictSeq (Timelock era)
atadrTimelock :: StrictSeq (Timelock era)
atadrTimelock :: StrictSeq (Timelock era)
atadrTimelock, Map Language (NonEmpty PlutusBinary)
atadrPlutus :: Map Language (NonEmpty PlutusBinary)
atadrPlutus :: Map Language (NonEmpty PlutusBinary)
atadrPlutus}
            else forall a. HasCallStack => [Char] -> a
error forall a b. (a -> b) -> a -> b
$ [Char]
prefix forall a. [a] -> [a] -> [a]
++ [Char]
" not supported in " forall a. [a] -> [a] -> [a]
++ forall era. Era era => [Char]
eraName @era

{-# COMPLETE AlonzoTxAuxData #-}

pattern AlonzoTxAuxData' ::
  forall era.
  Map Word64 Metadatum ->
  StrictSeq (Timelock era) ->
  Map Language (NE.NonEmpty PlutusBinary) ->
  AlonzoTxAuxData era
pattern $mAlonzoTxAuxData' :: forall {r} {era}.
AlonzoTxAuxData era
-> (Map Word64 Metadatum
    -> StrictSeq (Timelock era)
    -> Map Language (NonEmpty PlutusBinary)
    -> r)
-> ((# #) -> r)
-> r
AlonzoTxAuxData' {forall era. AlonzoTxAuxData era -> Map Word64 Metadatum
atadMetadata', forall era. AlonzoTxAuxData era -> StrictSeq (Timelock era)
atadTimelock', forall era.
AlonzoTxAuxData era -> Map Language (NonEmpty PlutusBinary)
atadPlutus'} <-
  (getMemoRawType -> AlonzoTxAuxDataRaw atadMetadata' atadTimelock' atadPlutus')

translateAlonzoTxAuxData ::
  (AlonzoEraScript era1, AlonzoEraScript era2) =>
  AlonzoTxAuxData era1 ->
  AlonzoTxAuxData era2
translateAlonzoTxAuxData :: forall era1 era2.
(AlonzoEraScript era1, AlonzoEraScript era2) =>
AlonzoTxAuxData era1 -> AlonzoTxAuxData era2
translateAlonzoTxAuxData AlonzoTxAuxData {Map Word64 Metadatum
atadMetadata :: Map Word64 Metadatum
atadMetadata :: forall era.
(HasCallStack, AlonzoEraScript era) =>
AlonzoTxAuxData era -> Map Word64 Metadatum
atadMetadata, StrictSeq (Timelock era1)
atadTimelock :: StrictSeq (Timelock era1)
atadTimelock :: forall era.
(HasCallStack, AlonzoEraScript era) =>
AlonzoTxAuxData era -> StrictSeq (Timelock era)
atadTimelock, Map Language (NonEmpty PlutusBinary)
atadPlutus :: Map Language (NonEmpty PlutusBinary)
atadPlutus :: forall era.
(HasCallStack, AlonzoEraScript era) =>
AlonzoTxAuxData era -> Map Language (NonEmpty PlutusBinary)
atadPlutus} =
  AlonzoTxAuxData
    { atadMetadata :: Map Word64 Metadatum
atadMetadata = Map Word64 Metadatum
atadMetadata
    , atadTimelock :: StrictSeq (Timelock era2)
atadTimelock = forall era1 era2.
(Era era1, Era era2) =>
Timelock era1 -> Timelock era2
translateTimelock forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> StrictSeq (Timelock era1)
atadTimelock
    , atadPlutus :: Map Language (NonEmpty PlutusBinary)
atadPlutus = Map Language (NonEmpty PlutusBinary)
atadPlutus
    }