{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Cardano.Ledger.Dijkstra.TxInfo (
DijkstraContextError (..),
transFailSubTxIsNotSupported,
) where
import Cardano.Crypto.Hash.Class (hashToBytes)
import Cardano.Ledger.Alonzo.Plutus.Context (
EraPlutusContext (..),
EraPlutusTxInfo (..),
LedgerTxInfo (..),
PlutusTxInfo,
PlutusTxInfoResult (..),
SupportedLanguage (..),
toPlutusWithContext,
)
import qualified Cardano.Ledger.Alonzo.Plutus.TxInfo as Alonzo
import Cardano.Ledger.Alonzo.Scripts (AsPurpose (..))
import qualified Cardano.Ledger.Babbage.TxInfo as Babbage
import Cardano.Ledger.BaseTypes (Inject (..), ProtVer (..), kindObject, strictMaybe)
import Cardano.Ledger.Binary (DecCBOR (..), EncCBOR (..))
import Cardano.Ledger.Binary.Coders (Decode (..), Encode (..), decode, encode, (!>), (<!))
import Cardano.Ledger.Coin (Coin (..))
import Cardano.Ledger.Conway.TxCert (Delegatee (..))
import Cardano.Ledger.Conway.TxInfo (
ConwayContextError (..),
ConwayEraPlutusTxInfo (..),
transTxInInfoV1,
transTxInInfoV3,
)
import qualified Cardano.Ledger.Conway.TxInfo as Conway
import Cardano.Ledger.Credential (StakeReference (..))
import Cardano.Ledger.Dijkstra.Core
import Cardano.Ledger.Dijkstra.Era (DijkstraEra)
import Cardano.Ledger.Dijkstra.Scripts (
PlutusScript (..),
pattern GuardingPurpose,
)
import Cardano.Ledger.Dijkstra.TxCert (DijkstraTxCert)
import Cardano.Ledger.Dijkstra.UTxO ()
import Cardano.Ledger.Plutus (
Language (..),
PlutusArgs (..),
SLanguage (..),
TxOutSource (..),
transCoinToLovelace,
transCoinToValue,
transCred,
transDatum,
transEpochNo,
transKeyHash,
)
import Cardano.Ledger.Plutus.Data (Data)
import Cardano.Ledger.Plutus.ToPlutusData (ToPlutusData (..))
import Cardano.Ledger.State (StakePoolParams (..))
import Cardano.Ledger.TxIn (TxId)
import Control.DeepSeq (NFData)
import Control.Monad (zipWithM)
import Data.Aeson (KeyValue (..), ToJSON (..))
import Data.Foldable (Foldable (..))
import qualified Data.Foldable as F
import Data.List.NonEmpty (NonEmpty (..))
import qualified Data.List.NonEmpty as NE
import qualified Data.Set as Set
import GHC.Generics (Generic)
import Lens.Micro ((^.))
import qualified PlutusLedgerApi.V1 as PV1
import qualified PlutusLedgerApi.V2 as PV2
import qualified PlutusLedgerApi.V3 as PV3
data DijkstraContextError era
= ConwayContextError (ConwayContextError era)
| PointerPresentInOutput (NonEmpty (TxOut era))
|
SubTxIsNotSupported TxId
deriving ((forall x.
DijkstraContextError era -> Rep (DijkstraContextError era) x)
-> (forall x.
Rep (DijkstraContextError era) x -> DijkstraContextError era)
-> Generic (DijkstraContextError era)
forall x.
Rep (DijkstraContextError era) x -> DijkstraContextError era
forall x.
DijkstraContextError era -> Rep (DijkstraContextError era) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall era x.
Rep (DijkstraContextError era) x -> DijkstraContextError era
forall era x.
DijkstraContextError era -> Rep (DijkstraContextError era) x
$cfrom :: forall era x.
DijkstraContextError era -> Rep (DijkstraContextError era) x
from :: forall x.
DijkstraContextError era -> Rep (DijkstraContextError era) x
$cto :: forall era x.
Rep (DijkstraContextError era) x -> DijkstraContextError era
to :: forall x.
Rep (DijkstraContextError era) x -> DijkstraContextError era
Generic)
deriving instance
( AlonzoEraScript era
, EraTxCert era
, EraTxOut era
) =>
Eq (DijkstraContextError era)
deriving instance
( AlonzoEraScript era
, EraTxCert era
, EraTxOut era
) =>
Show (DijkstraContextError era)
instance
( AlonzoEraScript era
, EraTxCert era
, EraTxOut era
) =>
NFData (DijkstraContextError era)
instance
( ToJSON (TxCert era)
, ToJSON (PlutusPurpose AsIx era)
, ToJSON (PlutusPurpose AsItem era)
, ToJSON (TxOut era)
, EraPParams era
) =>
ToJSON (DijkstraContextError era)
where
toJSON :: DijkstraContextError era -> Value
toJSON = \case
ConwayContextError ConwayContextError era
x -> ConwayContextError era -> Value
forall a. ToJSON a => a -> Value
toJSON ConwayContextError era
x
PointerPresentInOutput NonEmpty (TxOut era)
x -> Text -> [Pair] -> Value
kindObject Text
"PointerPresentInOutput" [Key
"txOut" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= NonEmpty (TxOut era) -> Value
forall a. ToJSON a => a -> Value
toJSON NonEmpty (TxOut era)
x]
SubTxIsNotSupported TxId
txId -> Text -> [Pair] -> Value
kindObject Text
"SubTxIsNotSupported" [Key
"txId" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TxId -> Value
forall a. ToJSON a => a -> Value
toJSON TxId
txId]
instance
( EraPParams era
, DecCBOR (TxCert era)
, DecCBOR (TxOut era)
, DecCBOR (PlutusPurpose AsIx era)
, DecCBOR (PlutusPurpose AsItem era)
) =>
DecCBOR (DijkstraContextError era)
where
decCBOR :: forall s. Decoder s (DijkstraContextError era)
decCBOR = Decode (Closed Dense) (DijkstraContextError era)
-> Decoder s (DijkstraContextError era)
forall t (w :: Wrapped) s. Typeable t => Decode w t -> Decoder s t
decode (Decode (Closed Dense) (DijkstraContextError era)
-> Decoder s (DijkstraContextError era))
-> Decode (Closed Dense) (DijkstraContextError era)
-> Decoder s (DijkstraContextError era)
forall a b. (a -> b) -> a -> b
$ Text
-> (Word -> Decode Open (DijkstraContextError era))
-> Decode (Closed Dense) (DijkstraContextError era)
forall t.
Text -> (Word -> Decode Open t) -> Decode (Closed Dense) t
Summands Text
"ContextError" ((Word -> Decode Open (DijkstraContextError era))
-> Decode (Closed Dense) (DijkstraContextError era))
-> (Word -> Decode Open (DijkstraContextError era))
-> Decode (Closed Dense) (DijkstraContextError era)
forall a b. (a -> b) -> a -> b
$ \case
Word
16 -> (ConwayContextError era -> DijkstraContextError era)
-> Decode Open (ConwayContextError era -> DijkstraContextError era)
forall t. t -> Decode Open t
SumD ConwayContextError era -> DijkstraContextError era
forall era. ConwayContextError era -> DijkstraContextError era
ConwayContextError Decode Open (ConwayContextError era -> DijkstraContextError era)
-> Decode (Closed (ZonkAny 0)) (ConwayContextError era)
-> Decode Open (DijkstraContextError era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 0)) (ConwayContextError era)
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
Word
17 -> (NonEmpty (TxOut era) -> DijkstraContextError era)
-> Decode Open (NonEmpty (TxOut era) -> DijkstraContextError era)
forall t. t -> Decode Open t
SumD NonEmpty (TxOut era) -> DijkstraContextError era
forall era. NonEmpty (TxOut era) -> DijkstraContextError era
PointerPresentInOutput Decode Open (NonEmpty (TxOut era) -> DijkstraContextError era)
-> Decode (Closed (ZonkAny 1)) (NonEmpty (TxOut era))
-> Decode Open (DijkstraContextError era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 1)) (NonEmpty (TxOut era))
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
Word
18 -> (TxId -> DijkstraContextError era)
-> Decode Open (TxId -> DijkstraContextError era)
forall t. t -> Decode Open t
SumD TxId -> DijkstraContextError era
forall era. TxId -> DijkstraContextError era
SubTxIsNotSupported Decode Open (TxId -> DijkstraContextError era)
-> Decode (Closed (ZonkAny 2)) TxId
-> Decode Open (DijkstraContextError era)
forall a (w1 :: Wrapped) t (w :: Density).
Typeable a =>
Decode w1 (a -> t) -> Decode (Closed w) a -> Decode w1 t
<! Decode (Closed (ZonkAny 2)) TxId
forall t (w :: Wrapped). DecCBOR t => Decode w t
From
Word
k -> Word -> Decode Open (DijkstraContextError era)
forall (w :: Wrapped) t. Word -> Decode w t
Invalid Word
k
instance
( EraPParams era
, EncCBOR (TxCert era)
, EncCBOR (TxOut era)
, EncCBOR (PlutusPurpose AsIx era)
, EncCBOR (PlutusPurpose AsItem era)
) =>
EncCBOR (DijkstraContextError era)
where
encCBOR :: DijkstraContextError era -> Encoding
encCBOR =
Encode Open (DijkstraContextError era) -> Encoding
forall (w :: Wrapped) t. Encode w t -> Encoding
encode (Encode Open (DijkstraContextError era) -> Encoding)
-> (DijkstraContextError era
-> Encode Open (DijkstraContextError era))
-> DijkstraContextError era
-> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. \case
ConwayContextError ConwayContextError era
x -> (ConwayContextError era -> DijkstraContextError era)
-> Word
-> Encode Open (ConwayContextError era -> DijkstraContextError era)
forall t. t -> Word -> Encode Open t
Sum ConwayContextError era -> DijkstraContextError era
forall era. ConwayContextError era -> DijkstraContextError era
ConwayContextError Word
16 Encode Open (ConwayContextError era -> DijkstraContextError era)
-> Encode (Closed Dense) (ConwayContextError era)
-> Encode Open (DijkstraContextError era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode (Closed r) a -> Encode w t
!> ConwayContextError era
-> Encode (Closed Dense) (ConwayContextError era)
forall t. EncCBOR t => t -> Encode (Closed Dense) t
To ConwayContextError era
x
PointerPresentInOutput NonEmpty (TxOut era)
x -> (NonEmpty (TxOut era) -> DijkstraContextError era)
-> Word
-> Encode Open (NonEmpty (TxOut era) -> DijkstraContextError era)
forall t. t -> Word -> Encode Open t
Sum NonEmpty (TxOut era) -> DijkstraContextError era
forall era. NonEmpty (TxOut era) -> DijkstraContextError era
PointerPresentInOutput Word
17 Encode Open (NonEmpty (TxOut era) -> DijkstraContextError era)
-> Encode (Closed Dense) (NonEmpty (TxOut era))
-> Encode Open (DijkstraContextError era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode (Closed r) a -> Encode w t
!> NonEmpty (TxOut era)
-> Encode (Closed Dense) (NonEmpty (TxOut era))
forall t. EncCBOR t => t -> Encode (Closed Dense) t
To NonEmpty (TxOut era)
x
SubTxIsNotSupported TxId
txId -> (TxId -> DijkstraContextError era)
-> Word -> Encode Open (TxId -> DijkstraContextError era)
forall t. t -> Word -> Encode Open t
Sum TxId -> DijkstraContextError era
forall era. TxId -> DijkstraContextError era
SubTxIsNotSupported Word
18 Encode Open (TxId -> DijkstraContextError era)
-> Encode (Closed Dense) TxId
-> Encode Open (DijkstraContextError era)
forall (w :: Wrapped) a t (r :: Density).
Encode w (a -> t) -> Encode (Closed r) a -> Encode w t
!> TxId -> Encode (Closed Dense) TxId
forall t. EncCBOR t => t -> Encode (Closed Dense) t
To TxId
txId
instance Inject (ConwayContextError era) (DijkstraContextError era) where
inject :: ConwayContextError era -> DijkstraContextError era
inject = ConwayContextError era -> DijkstraContextError era
forall era. ConwayContextError era -> DijkstraContextError era
ConwayContextError
instance Inject (Babbage.BabbageContextError era) (DijkstraContextError era) where
inject :: BabbageContextError era -> DijkstraContextError era
inject = ConwayContextError era -> DijkstraContextError era
forall era. ConwayContextError era -> DijkstraContextError era
ConwayContextError (ConwayContextError era -> DijkstraContextError era)
-> (BabbageContextError era -> ConwayContextError era)
-> BabbageContextError era
-> DijkstraContextError era
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BabbageContextError era -> ConwayContextError era
forall t s. Inject t s => t -> s
inject
instance Inject (Alonzo.AlonzoContextError era) (DijkstraContextError era) where
inject :: AlonzoContextError era -> DijkstraContextError era
inject = ConwayContextError era -> DijkstraContextError era
forall era. ConwayContextError era -> DijkstraContextError era
ConwayContextError (ConwayContextError era -> DijkstraContextError era)
-> (AlonzoContextError era -> ConwayContextError era)
-> AlonzoContextError era
-> DijkstraContextError era
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AlonzoContextError era -> ConwayContextError era
forall t s. Inject t s => t -> s
inject
instance EraPlutusContext DijkstraEra where
type ContextError DijkstraEra = DijkstraContextError DijkstraEra
data TxInfoResult DijkstraEra
= DijkstraTxInfoResult
(PlutusTxInfoResult 'PlutusV1 DijkstraEra)
(PlutusTxInfoResult 'PlutusV2 DijkstraEra)
(PlutusTxInfoResult 'PlutusV3 DijkstraEra)
(PlutusTxInfoResult 'PlutusV4 DijkstraEra)
mkSupportedLanguage :: Language -> Maybe (SupportedLanguage DijkstraEra)
mkSupportedLanguage = \case
Language
PlutusV1 -> SupportedLanguage DijkstraEra
-> Maybe (SupportedLanguage DijkstraEra)
forall a. a -> Maybe a
Just (SupportedLanguage DijkstraEra
-> Maybe (SupportedLanguage DijkstraEra))
-> SupportedLanguage DijkstraEra
-> Maybe (SupportedLanguage DijkstraEra)
forall a b. (a -> b) -> a -> b
$ SLanguage 'PlutusV1 -> SupportedLanguage DijkstraEra
forall (l :: Language) era.
EraPlutusTxInfo l era =>
SLanguage l -> SupportedLanguage era
SupportedLanguage SLanguage 'PlutusV1
SPlutusV1
Language
PlutusV2 -> SupportedLanguage DijkstraEra
-> Maybe (SupportedLanguage DijkstraEra)
forall a. a -> Maybe a
Just (SupportedLanguage DijkstraEra
-> Maybe (SupportedLanguage DijkstraEra))
-> SupportedLanguage DijkstraEra
-> Maybe (SupportedLanguage DijkstraEra)
forall a b. (a -> b) -> a -> b
$ SLanguage 'PlutusV2 -> SupportedLanguage DijkstraEra
forall (l :: Language) era.
EraPlutusTxInfo l era =>
SLanguage l -> SupportedLanguage era
SupportedLanguage SLanguage 'PlutusV2
SPlutusV2
Language
PlutusV3 -> SupportedLanguage DijkstraEra
-> Maybe (SupportedLanguage DijkstraEra)
forall a. a -> Maybe a
Just (SupportedLanguage DijkstraEra
-> Maybe (SupportedLanguage DijkstraEra))
-> SupportedLanguage DijkstraEra
-> Maybe (SupportedLanguage DijkstraEra)
forall a b. (a -> b) -> a -> b
$ SLanguage 'PlutusV3 -> SupportedLanguage DijkstraEra
forall (l :: Language) era.
EraPlutusTxInfo l era =>
SLanguage l -> SupportedLanguage era
SupportedLanguage SLanguage 'PlutusV3
SPlutusV3
Language
PlutusV4 -> SupportedLanguage DijkstraEra
-> Maybe (SupportedLanguage DijkstraEra)
forall a. a -> Maybe a
Just (SupportedLanguage DijkstraEra
-> Maybe (SupportedLanguage DijkstraEra))
-> SupportedLanguage DijkstraEra
-> Maybe (SupportedLanguage DijkstraEra)
forall a b. (a -> b) -> a -> b
$ SLanguage 'PlutusV4 -> SupportedLanguage DijkstraEra
forall (l :: Language) era.
EraPlutusTxInfo l era =>
SLanguage l -> SupportedLanguage era
SupportedLanguage SLanguage 'PlutusV4
SPlutusV4
mkTxInfoResult :: LedgerTxInfo DijkstraEra -> TxInfoResult DijkstraEra
mkTxInfoResult LedgerTxInfo DijkstraEra
lti =
PlutusTxInfoResult 'PlutusV1 DijkstraEra
-> PlutusTxInfoResult 'PlutusV2 DijkstraEra
-> PlutusTxInfoResult 'PlutusV3 DijkstraEra
-> PlutusTxInfoResult 'PlutusV4 DijkstraEra
-> TxInfoResult DijkstraEra
DijkstraTxInfoResult
(SLanguage 'PlutusV1
-> LedgerTxInfo DijkstraEra
-> PlutusTxInfoResult 'PlutusV1 DijkstraEra
forall (l :: Language) era (proxy :: Language -> *).
EraPlutusTxInfo l era =>
proxy l -> LedgerTxInfo era -> PlutusTxInfoResult l era
forall (proxy :: Language -> *).
proxy 'PlutusV1
-> LedgerTxInfo DijkstraEra
-> PlutusTxInfoResult 'PlutusV1 DijkstraEra
toPlutusTxInfo SLanguage 'PlutusV1
SPlutusV1 LedgerTxInfo DijkstraEra
lti)
(SLanguage 'PlutusV2
-> LedgerTxInfo DijkstraEra
-> PlutusTxInfoResult 'PlutusV2 DijkstraEra
forall (l :: Language) era (proxy :: Language -> *).
EraPlutusTxInfo l era =>
proxy l -> LedgerTxInfo era -> PlutusTxInfoResult l era
forall (proxy :: Language -> *).
proxy 'PlutusV2
-> LedgerTxInfo DijkstraEra
-> PlutusTxInfoResult 'PlutusV2 DijkstraEra
toPlutusTxInfo SLanguage 'PlutusV2
SPlutusV2 LedgerTxInfo DijkstraEra
lti)
(SLanguage 'PlutusV3
-> LedgerTxInfo DijkstraEra
-> PlutusTxInfoResult 'PlutusV3 DijkstraEra
forall (l :: Language) era (proxy :: Language -> *).
EraPlutusTxInfo l era =>
proxy l -> LedgerTxInfo era -> PlutusTxInfoResult l era
forall (proxy :: Language -> *).
proxy 'PlutusV3
-> LedgerTxInfo DijkstraEra
-> PlutusTxInfoResult 'PlutusV3 DijkstraEra
toPlutusTxInfo SLanguage 'PlutusV3
SPlutusV3 LedgerTxInfo DijkstraEra
lti)
(SLanguage 'PlutusV4
-> LedgerTxInfo DijkstraEra
-> PlutusTxInfoResult 'PlutusV4 DijkstraEra
forall (l :: Language) era (proxy :: Language -> *).
EraPlutusTxInfo l era =>
proxy l -> LedgerTxInfo era -> PlutusTxInfoResult l era
forall (proxy :: Language -> *).
proxy 'PlutusV4
-> LedgerTxInfo DijkstraEra
-> PlutusTxInfoResult 'PlutusV4 DijkstraEra
toPlutusTxInfo SLanguage 'PlutusV4
SPlutusV4 LedgerTxInfo DijkstraEra
lti)
lookupTxInfoResult :: forall (l :: Language).
EraPlutusTxInfo l DijkstraEra =>
SLanguage l
-> TxInfoResult DijkstraEra -> PlutusTxInfoResult l DijkstraEra
lookupTxInfoResult SLanguage l
SPlutusV1 (DijkstraTxInfoResult PlutusTxInfoResult 'PlutusV1 DijkstraEra
tirPlutusV1 PlutusTxInfoResult 'PlutusV2 DijkstraEra
_ PlutusTxInfoResult 'PlutusV3 DijkstraEra
_ PlutusTxInfoResult 'PlutusV4 DijkstraEra
_) = PlutusTxInfoResult l DijkstraEra
PlutusTxInfoResult 'PlutusV1 DijkstraEra
tirPlutusV1
lookupTxInfoResult SLanguage l
SPlutusV2 (DijkstraTxInfoResult PlutusTxInfoResult 'PlutusV1 DijkstraEra
_ PlutusTxInfoResult 'PlutusV2 DijkstraEra
tirPlutusV2 PlutusTxInfoResult 'PlutusV3 DijkstraEra
_ PlutusTxInfoResult 'PlutusV4 DijkstraEra
_) = PlutusTxInfoResult l DijkstraEra
PlutusTxInfoResult 'PlutusV2 DijkstraEra
tirPlutusV2
lookupTxInfoResult SLanguage l
SPlutusV3 (DijkstraTxInfoResult PlutusTxInfoResult 'PlutusV1 DijkstraEra
_ PlutusTxInfoResult 'PlutusV2 DijkstraEra
_ PlutusTxInfoResult 'PlutusV3 DijkstraEra
tirPlutusV3 PlutusTxInfoResult 'PlutusV4 DijkstraEra
_) = PlutusTxInfoResult l DijkstraEra
PlutusTxInfoResult 'PlutusV3 DijkstraEra
tirPlutusV3
lookupTxInfoResult SLanguage l
SPlutusV4 (DijkstraTxInfoResult PlutusTxInfoResult 'PlutusV1 DijkstraEra
_ PlutusTxInfoResult 'PlutusV2 DijkstraEra
_ PlutusTxInfoResult 'PlutusV3 DijkstraEra
_ PlutusTxInfoResult 'PlutusV4 DijkstraEra
tirPlutusV4) = PlutusTxInfoResult l DijkstraEra
PlutusTxInfoResult 'PlutusV4 DijkstraEra
tirPlutusV4
mkPlutusWithContext :: PlutusScript DijkstraEra
-> ScriptHash
-> PlutusPurpose AsIxItem DijkstraEra
-> LedgerTxInfo DijkstraEra
-> TxInfoResult DijkstraEra
-> (Data DijkstraEra, ExUnits)
-> CostModel
-> Either (ContextError DijkstraEra) PlutusWithContext
mkPlutusWithContext = \case
DijkstraPlutusV1 Plutus 'PlutusV1
p -> Either (Plutus 'PlutusV1) (PlutusRunnable 'PlutusV1)
-> ScriptHash
-> PlutusPurpose AsIxItem DijkstraEra
-> LedgerTxInfo DijkstraEra
-> TxInfoResult DijkstraEra
-> (Data DijkstraEra, ExUnits)
-> CostModel
-> Either (ContextError DijkstraEra) PlutusWithContext
forall (l :: Language) era.
(EraPlutusTxInfo l era, AlonzoEraUTxO era) =>
Either (Plutus l) (PlutusRunnable l)
-> ScriptHash
-> PlutusPurpose AsIxItem era
-> LedgerTxInfo era
-> TxInfoResult era
-> (Data era, ExUnits)
-> CostModel
-> Either (ContextError era) PlutusWithContext
toPlutusWithContext (Either (Plutus 'PlutusV1) (PlutusRunnable 'PlutusV1)
-> ScriptHash
-> PlutusPurpose AsIxItem DijkstraEra
-> LedgerTxInfo DijkstraEra
-> TxInfoResult DijkstraEra
-> (Data DijkstraEra, ExUnits)
-> CostModel
-> Either (ContextError DijkstraEra) PlutusWithContext)
-> Either (Plutus 'PlutusV1) (PlutusRunnable 'PlutusV1)
-> ScriptHash
-> PlutusPurpose AsIxItem DijkstraEra
-> LedgerTxInfo DijkstraEra
-> TxInfoResult DijkstraEra
-> (Data DijkstraEra, ExUnits)
-> CostModel
-> Either (ContextError DijkstraEra) PlutusWithContext
forall a b. (a -> b) -> a -> b
$ Plutus 'PlutusV1
-> Either (Plutus 'PlutusV1) (PlutusRunnable 'PlutusV1)
forall a b. a -> Either a b
Left Plutus 'PlutusV1
p
DijkstraPlutusV2 Plutus 'PlutusV2
p -> Either (Plutus 'PlutusV2) (PlutusRunnable 'PlutusV2)
-> ScriptHash
-> PlutusPurpose AsIxItem DijkstraEra
-> LedgerTxInfo DijkstraEra
-> TxInfoResult DijkstraEra
-> (Data DijkstraEra, ExUnits)
-> CostModel
-> Either (ContextError DijkstraEra) PlutusWithContext
forall (l :: Language) era.
(EraPlutusTxInfo l era, AlonzoEraUTxO era) =>
Either (Plutus l) (PlutusRunnable l)
-> ScriptHash
-> PlutusPurpose AsIxItem era
-> LedgerTxInfo era
-> TxInfoResult era
-> (Data era, ExUnits)
-> CostModel
-> Either (ContextError era) PlutusWithContext
toPlutusWithContext (Either (Plutus 'PlutusV2) (PlutusRunnable 'PlutusV2)
-> ScriptHash
-> PlutusPurpose AsIxItem DijkstraEra
-> LedgerTxInfo DijkstraEra
-> TxInfoResult DijkstraEra
-> (Data DijkstraEra, ExUnits)
-> CostModel
-> Either (ContextError DijkstraEra) PlutusWithContext)
-> Either (Plutus 'PlutusV2) (PlutusRunnable 'PlutusV2)
-> ScriptHash
-> PlutusPurpose AsIxItem DijkstraEra
-> LedgerTxInfo DijkstraEra
-> TxInfoResult DijkstraEra
-> (Data DijkstraEra, ExUnits)
-> CostModel
-> Either (ContextError DijkstraEra) PlutusWithContext
forall a b. (a -> b) -> a -> b
$ Plutus 'PlutusV2
-> Either (Plutus 'PlutusV2) (PlutusRunnable 'PlutusV2)
forall a b. a -> Either a b
Left Plutus 'PlutusV2
p
DijkstraPlutusV3 Plutus 'PlutusV3
p -> Either (Plutus 'PlutusV3) (PlutusRunnable 'PlutusV3)
-> ScriptHash
-> PlutusPurpose AsIxItem DijkstraEra
-> LedgerTxInfo DijkstraEra
-> TxInfoResult DijkstraEra
-> (Data DijkstraEra, ExUnits)
-> CostModel
-> Either (ContextError DijkstraEra) PlutusWithContext
forall (l :: Language) era.
(EraPlutusTxInfo l era, AlonzoEraUTxO era) =>
Either (Plutus l) (PlutusRunnable l)
-> ScriptHash
-> PlutusPurpose AsIxItem era
-> LedgerTxInfo era
-> TxInfoResult era
-> (Data era, ExUnits)
-> CostModel
-> Either (ContextError era) PlutusWithContext
toPlutusWithContext (Either (Plutus 'PlutusV3) (PlutusRunnable 'PlutusV3)
-> ScriptHash
-> PlutusPurpose AsIxItem DijkstraEra
-> LedgerTxInfo DijkstraEra
-> TxInfoResult DijkstraEra
-> (Data DijkstraEra, ExUnits)
-> CostModel
-> Either (ContextError DijkstraEra) PlutusWithContext)
-> Either (Plutus 'PlutusV3) (PlutusRunnable 'PlutusV3)
-> ScriptHash
-> PlutusPurpose AsIxItem DijkstraEra
-> LedgerTxInfo DijkstraEra
-> TxInfoResult DijkstraEra
-> (Data DijkstraEra, ExUnits)
-> CostModel
-> Either (ContextError DijkstraEra) PlutusWithContext
forall a b. (a -> b) -> a -> b
$ Plutus 'PlutusV3
-> Either (Plutus 'PlutusV3) (PlutusRunnable 'PlutusV3)
forall a b. a -> Either a b
Left Plutus 'PlutusV3
p
DijkstraPlutusV4 Plutus 'PlutusV4
p -> Either (Plutus 'PlutusV4) (PlutusRunnable 'PlutusV4)
-> ScriptHash
-> PlutusPurpose AsIxItem DijkstraEra
-> LedgerTxInfo DijkstraEra
-> TxInfoResult DijkstraEra
-> (Data DijkstraEra, ExUnits)
-> CostModel
-> Either (ContextError DijkstraEra) PlutusWithContext
forall (l :: Language) era.
(EraPlutusTxInfo l era, AlonzoEraUTxO era) =>
Either (Plutus l) (PlutusRunnable l)
-> ScriptHash
-> PlutusPurpose AsIxItem era
-> LedgerTxInfo era
-> TxInfoResult era
-> (Data era, ExUnits)
-> CostModel
-> Either (ContextError era) PlutusWithContext
toPlutusWithContext (Either (Plutus 'PlutusV4) (PlutusRunnable 'PlutusV4)
-> ScriptHash
-> PlutusPurpose AsIxItem DijkstraEra
-> LedgerTxInfo DijkstraEra
-> TxInfoResult DijkstraEra
-> (Data DijkstraEra, ExUnits)
-> CostModel
-> Either (ContextError DijkstraEra) PlutusWithContext)
-> Either (Plutus 'PlutusV4) (PlutusRunnable 'PlutusV4)
-> ScriptHash
-> PlutusPurpose AsIxItem DijkstraEra
-> LedgerTxInfo DijkstraEra
-> TxInfoResult DijkstraEra
-> (Data DijkstraEra, ExUnits)
-> CostModel
-> Either (ContextError DijkstraEra) PlutusWithContext
forall a b. (a -> b) -> a -> b
$ Plutus 'PlutusV4
-> Either (Plutus 'PlutusV4) (PlutusRunnable 'PlutusV4)
forall a b. a -> Either a b
Left Plutus 'PlutusV4
p
instance EraPlutusTxInfo 'PlutusV1 DijkstraEra where
toPlutusTxCert :: forall (proxy :: Language -> *).
proxy 'PlutusV1
-> ProtVer
-> TxCert DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxCert 'PlutusV1)
toPlutusTxCert proxy 'PlutusV1
_ ProtVer
_ = TxCert DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxCert 'PlutusV1)
TxCert DijkstraEra -> Either (ContextError DijkstraEra) DCert
forall era.
(ConwayEraTxCert era,
Inject (ConwayContextError era) (ContextError era)) =>
TxCert era -> Either (ContextError era) DCert
transTxCertV1V2
toPlutusScriptPurpose :: forall (proxy :: Language -> *).
proxy 'PlutusV1
-> ProtVer
-> PlutusPurpose AsIxItem DijkstraEra
-> Either
(ContextError DijkstraEra) (PlutusScriptPurpose 'PlutusV1)
toPlutusScriptPurpose = proxy 'PlutusV1
-> ProtVer
-> PlutusPurpose AsIxItem DijkstraEra
-> Either
(ContextError DijkstraEra) (PlutusScriptPurpose 'PlutusV1)
proxy 'PlutusV1
-> ProtVer
-> PlutusPurpose AsIxItem DijkstraEra
-> Either (ContextError DijkstraEra) ScriptPurpose
forall (l :: Language) era (proxy :: Language -> *).
(PlutusTxCert l ~ DCert, EraPlutusTxInfo l era,
Inject (ConwayContextError era) (ContextError era)) =>
proxy l
-> ProtVer
-> PlutusPurpose AsIxItem era
-> Either (ContextError era) ScriptPurpose
Conway.transPlutusPurposeV1V2
toPlutusTxInfo :: forall (proxy :: Language -> *).
proxy 'PlutusV1
-> LedgerTxInfo DijkstraEra
-> PlutusTxInfoResult 'PlutusV1 DijkstraEra
toPlutusTxInfo proxy 'PlutusV1
proxy LedgerTxInfo {ProtVer
ltiProtVer :: ProtVer
ltiProtVer :: forall era. LedgerTxInfo era -> ProtVer
ltiProtVer, EpochInfo (Either Text)
ltiEpochInfo :: EpochInfo (Either Text)
ltiEpochInfo :: forall era. LedgerTxInfo era -> EpochInfo (Either Text)
ltiEpochInfo, SystemStart
ltiSystemStart :: SystemStart
ltiSystemStart :: forall era. LedgerTxInfo era -> SystemStart
ltiSystemStart, UTxO DijkstraEra
ltiUTxO :: UTxO DijkstraEra
ltiUTxO :: forall era. LedgerTxInfo era -> UTxO era
ltiUTxO, Tx level DijkstraEra
ltiTx :: Tx level DijkstraEra
ltiTx :: ()
ltiTx} =
((Tx TopTx DijkstraEra -> PlutusTxInfoResult 'PlutusV1 DijkstraEra)
-> (Tx SubTx DijkstraEra
-> PlutusTxInfoResult 'PlutusV1 DijkstraEra)
-> PlutusTxInfoResult 'PlutusV1 DijkstraEra)
-> (Tx SubTx DijkstraEra
-> PlutusTxInfoResult 'PlutusV1 DijkstraEra)
-> (Tx TopTx DijkstraEra
-> PlutusTxInfoResult 'PlutusV1 DijkstraEra)
-> PlutusTxInfoResult 'PlutusV1 DijkstraEra
forall a b c. (a -> b -> c) -> b -> a -> c
flip (Tx level DijkstraEra
-> (Tx TopTx DijkstraEra
-> PlutusTxInfoResult 'PlutusV1 DijkstraEra)
-> (Tx SubTx DijkstraEra
-> PlutusTxInfoResult 'PlutusV1 DijkstraEra)
-> PlutusTxInfoResult 'PlutusV1 DijkstraEra
forall (t :: TxLevel -> * -> *) era (l :: TxLevel) a.
(HasEraTxLevel t era, STxLevel l era ~ STxBothLevels l era) =>
t l era -> (t TopTx era -> a) -> (t SubTx era -> a) -> a
withBothTxLevels Tx level DijkstraEra
ltiTx) Tx SubTx DijkstraEra -> PlutusTxInfoResult 'PlutusV1 DijkstraEra
forall (l :: Language) era.
(EraTx era,
Inject (DijkstraContextError era) (ContextError era)) =>
Tx SubTx era -> PlutusTxInfoResult l era
transFailSubTxIsNotSupported ((Tx TopTx DijkstraEra -> PlutusTxInfoResult 'PlutusV1 DijkstraEra)
-> PlutusTxInfoResult 'PlutusV1 DijkstraEra)
-> (Tx TopTx DijkstraEra
-> PlutusTxInfoResult 'PlutusV1 DijkstraEra)
-> PlutusTxInfoResult 'PlutusV1 DijkstraEra
forall a b. (a -> b) -> a -> b
$ \Tx TopTx DijkstraEra
tx -> Either
(ContextError DijkstraEra)
(PlutusPurpose AsPurpose DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV1))
-> PlutusTxInfoResult 'PlutusV1 DijkstraEra
forall (l :: Language) era.
Either
(ContextError era)
(PlutusPurpose AsPurpose era
-> Either (ContextError era) (PlutusTxInfo l))
-> PlutusTxInfoResult l era
PlutusTxInfoResult (Either
(ContextError DijkstraEra)
(PlutusPurpose AsPurpose DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV1))
-> PlutusTxInfoResult 'PlutusV1 DijkstraEra)
-> Either
(ContextError DijkstraEra)
(PlutusPurpose AsPurpose DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV1))
-> PlutusTxInfoResult 'PlutusV1 DijkstraEra
forall a b. (a -> b) -> a -> b
$ do
let txBody :: TxBody TopTx DijkstraEra
txBody = Tx TopTx DijkstraEra
tx Tx TopTx DijkstraEra
-> Getting
(TxBody TopTx DijkstraEra)
(Tx TopTx DijkstraEra)
(TxBody TopTx DijkstraEra)
-> TxBody TopTx DijkstraEra
forall s a. s -> Getting a s a -> a
^. Getting
(TxBody TopTx DijkstraEra)
(Tx TopTx DijkstraEra)
(TxBody TopTx DijkstraEra)
forall era (l :: TxLevel).
EraTx era =>
Lens' (Tx l era) (TxBody l era)
forall (l :: TxLevel).
Lens' (Tx l DijkstraEra) (TxBody l DijkstraEra)
bodyTxL
Tx TopTx DijkstraEra -> Either (ContextError DijkstraEra) ()
forall era (l :: TxLevel).
(EraTx era, ConwayEraTxBody era,
Inject (ConwayContextError era) (ContextError era)) =>
Tx l era -> Either (ContextError era) ()
Conway.guardConwayFeaturesForPlutusV1V2 Tx TopTx DijkstraEra
tx
timeRange <- Tx TopTx DijkstraEra
-> EpochInfo (Either Text)
-> SystemStart
-> ValidityInterval
-> Either (DijkstraContextError DijkstraEra) POSIXTimeRange
forall (proxy :: * -> *) era a.
Inject (AlonzoContextError era) a =>
proxy era
-> EpochInfo (Either Text)
-> SystemStart
-> ValidityInterval
-> Either a POSIXTimeRange
Conway.transValidityInterval Tx TopTx DijkstraEra
tx EpochInfo (Either Text)
ltiEpochInfo SystemStart
ltiSystemStart (TxBody TopTx DijkstraEra
txBody TxBody TopTx DijkstraEra
-> Getting
ValidityInterval (TxBody TopTx DijkstraEra) ValidityInterval
-> ValidityInterval
forall s a. s -> Getting a s a -> a
^. Getting
ValidityInterval (TxBody TopTx DijkstraEra) ValidityInterval
forall era (l :: TxLevel).
AllegraEraTxBody era =>
Lens' (TxBody l era) ValidityInterval
forall (l :: TxLevel).
Lens' (TxBody l DijkstraEra) ValidityInterval
vldtTxBodyL)
inputs <- mapM (Conway.transTxInInfoV1 ltiUTxO) (Set.toList (txBody ^. inputsTxBodyL))
mapM_ (Conway.transTxInInfoV1 ltiUTxO) (Set.toList (txBody ^. referenceInputsTxBodyL))
outputs <-
zipWithM
(Conway.transTxOutV1 . TxOutFromOutput)
[minBound ..]
(F.toList (txBody ^. outputsTxBodyL))
txCerts <- Alonzo.transTxBodyCerts proxy ltiProtVer txBody
let
txInfo =
PV1.TxInfo
{ txInfoInputs :: [TxInInfo]
PV1.txInfoInputs = [TxInInfo]
inputs
, txInfoOutputs :: [TxOut]
PV1.txInfoOutputs = [TxOut]
outputs
, txInfoFee :: Value
PV1.txInfoFee = Coin -> Value
transCoinToValue (TxBody TopTx DijkstraEra
txBody TxBody TopTx DijkstraEra
-> Getting Coin (TxBody TopTx DijkstraEra) Coin -> Coin
forall s a. s -> Getting a s a -> a
^. Getting Coin (TxBody TopTx DijkstraEra) Coin
forall era. EraTxBody era => Lens' (TxBody TopTx era) Coin
Lens' (TxBody TopTx DijkstraEra) Coin
feeTxBodyL)
, txInfoMint :: Value
PV1.txInfoMint = MultiAsset -> Value
Alonzo.transMintValue (TxBody TopTx DijkstraEra
txBody TxBody TopTx DijkstraEra
-> Getting MultiAsset (TxBody TopTx DijkstraEra) MultiAsset
-> MultiAsset
forall s a. s -> Getting a s a -> a
^. Getting MultiAsset (TxBody TopTx DijkstraEra) MultiAsset
forall era (l :: TxLevel).
MaryEraTxBody era =>
Lens' (TxBody l era) MultiAsset
forall (l :: TxLevel). Lens' (TxBody l DijkstraEra) MultiAsset
mintTxBodyL)
, txInfoDCert :: [DCert]
PV1.txInfoDCert = [DCert]
txCerts
, txInfoWdrl :: [(StakingCredential, Integer)]
PV1.txInfoWdrl = TxBody TopTx DijkstraEra -> [(StakingCredential, Integer)]
forall era (t :: TxLevel).
EraTxBody era =>
TxBody t era -> [(StakingCredential, Integer)]
Alonzo.transTxBodyWithdrawals TxBody TopTx DijkstraEra
txBody
, txInfoValidRange :: POSIXTimeRange
PV1.txInfoValidRange = POSIXTimeRange
timeRange
, txInfoSignatories :: [PubKeyHash]
PV1.txInfoSignatories = TxBody TopTx DijkstraEra -> [PubKeyHash]
forall era (t :: TxLevel).
AlonzoEraTxBody era =>
TxBody t era -> [PubKeyHash]
Alonzo.transTxBodyReqSignerHashes TxBody TopTx DijkstraEra
txBody
, txInfoData :: [(DatumHash, Datum)]
PV1.txInfoData = TxWits DijkstraEra -> [(DatumHash, Datum)]
forall era.
AlonzoEraTxWits era =>
TxWits era -> [(DatumHash, Datum)]
Alonzo.transTxWitsDatums (Tx TopTx DijkstraEra
tx Tx TopTx DijkstraEra
-> Getting
(TxWits DijkstraEra) (Tx TopTx DijkstraEra) (TxWits DijkstraEra)
-> TxWits DijkstraEra
forall s a. s -> Getting a s a -> a
^. Getting
(TxWits DijkstraEra) (Tx TopTx DijkstraEra) (TxWits DijkstraEra)
forall era (l :: TxLevel).
EraTx era =>
Lens' (Tx l era) (TxWits era)
forall (l :: TxLevel).
Lens' (Tx l DijkstraEra) (TxWits DijkstraEra)
witsTxL)
, txInfoId :: TxId
PV1.txInfoId = TxBody TopTx DijkstraEra -> TxId
forall era (l :: TxLevel). EraTxBody era => TxBody l era -> TxId
Alonzo.transTxBodyId TxBody TopTx DijkstraEra
txBody
}
Right $ \DijkstraPlutusPurpose AsPurpose DijkstraEra
_ -> TxInfo -> Either (DijkstraContextError DijkstraEra) TxInfo
forall a b. b -> Either a b
Right TxInfo
txInfo
toPlutusArgs :: forall (proxy :: Language -> *).
proxy 'PlutusV1
-> ProtVer
-> PlutusTxInfo 'PlutusV1
-> PlutusPurpose AsIxItem DijkstraEra
-> Maybe (Data DijkstraEra)
-> Data DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusArgs 'PlutusV1)
toPlutusArgs = proxy 'PlutusV1
-> ProtVer
-> PlutusTxInfo 'PlutusV1
-> PlutusPurpose AsIxItem DijkstraEra
-> Maybe (Data DijkstraEra)
-> Data DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusArgs 'PlutusV1)
proxy 'PlutusV1
-> ProtVer
-> TxInfo
-> PlutusPurpose AsIxItem DijkstraEra
-> Maybe (Data DijkstraEra)
-> Data DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusArgs 'PlutusV1)
forall era (proxy :: Language -> *).
EraPlutusTxInfo 'PlutusV1 era =>
proxy 'PlutusV1
-> ProtVer
-> TxInfo
-> PlutusPurpose AsIxItem era
-> Maybe (Data era)
-> Data era
-> Either (ContextError era) (PlutusArgs 'PlutusV1)
Alonzo.toPlutusV1Args
toPlutusTxInInfo :: forall (proxy :: Language -> *).
proxy 'PlutusV1
-> UTxO DijkstraEra
-> TxIn
-> Either
(ContextError DijkstraEra) (PlutusTxInInfo DijkstraEra 'PlutusV1)
toPlutusTxInInfo proxy 'PlutusV1
_ = UTxO DijkstraEra
-> TxIn
-> Either
(ContextError DijkstraEra) (PlutusTxInInfo DijkstraEra 'PlutusV1)
UTxO DijkstraEra
-> TxIn -> Either (ContextError DijkstraEra) TxInInfo
forall era.
(Inject (BabbageContextError era) (ContextError era),
Value era ~ MaryValue, BabbageEraTxOut era) =>
UTxO era -> TxIn -> Either (ContextError era) TxInInfo
transTxInInfoV1
transTxCertV1V2 ::
( ConwayEraTxCert era
, Inject (ConwayContextError era) (ContextError era)
) =>
TxCert era ->
Either (ContextError era) PV1.DCert
transTxCertV1V2 :: forall era.
(ConwayEraTxCert era,
Inject (ConwayContextError era) (ContextError era)) =>
TxCert era -> Either (ContextError era) DCert
transTxCertV1V2 = \case
RegDepositTxCert Credential Staking
stakeCred Coin
_deposit ->
DCert -> Either (ContextError era) DCert
forall a b. b -> Either a b
Right (DCert -> Either (ContextError era) DCert)
-> DCert -> Either (ContextError era) DCert
forall a b. (a -> b) -> a -> b
$ StakingCredential -> DCert
PV1.DCertDelegRegKey (Credential -> StakingCredential
PV1.StakingHash (Credential Staking -> Credential
forall (kr :: KeyRole). Credential kr -> Credential
transCred Credential Staking
stakeCred))
UnRegDepositTxCert Credential Staking
stakeCred Coin
_refund ->
DCert -> Either (ContextError era) DCert
forall a b. b -> Either a b
Right (DCert -> Either (ContextError era) DCert)
-> DCert -> Either (ContextError era) DCert
forall a b. (a -> b) -> a -> b
$ StakingCredential -> DCert
PV1.DCertDelegDeRegKey (Credential -> StakingCredential
PV1.StakingHash (Credential Staking -> Credential
forall (kr :: KeyRole). Credential kr -> Credential
transCred Credential Staking
stakeCred))
DelegTxCert Credential Staking
stakeCred (DelegStake KeyHash StakePool
keyHash) ->
DCert -> Either (ContextError era) DCert
forall a b. b -> Either a b
Right (DCert -> Either (ContextError era) DCert)
-> DCert -> Either (ContextError era) DCert
forall a b. (a -> b) -> a -> b
$ StakingCredential -> PubKeyHash -> DCert
PV1.DCertDelegDelegate (Credential -> StakingCredential
PV1.StakingHash (Credential Staking -> Credential
forall (kr :: KeyRole). Credential kr -> Credential
transCred Credential Staking
stakeCred)) (KeyHash StakePool -> PubKeyHash
forall (d :: KeyRole). KeyHash d -> PubKeyHash
transKeyHash KeyHash StakePool
keyHash)
RegPoolTxCert (StakePoolParams {KeyHash StakePool
sppId :: KeyHash StakePool
sppId :: StakePoolParams -> KeyHash StakePool
sppId, VRFVerKeyHash StakePoolVRF
sppVrf :: VRFVerKeyHash StakePoolVRF
sppVrf :: StakePoolParams -> VRFVerKeyHash StakePoolVRF
sppVrf}) ->
DCert -> Either (ContextError era) DCert
forall a b. b -> Either a b
Right (DCert -> Either (ContextError era) DCert)
-> DCert -> Either (ContextError era) DCert
forall a b. (a -> b) -> a -> b
$
PubKeyHash -> PubKeyHash -> DCert
PV1.DCertPoolRegister
(KeyHash StakePool -> PubKeyHash
forall (d :: KeyRole). KeyHash d -> PubKeyHash
transKeyHash KeyHash StakePool
sppId)
(BuiltinByteString -> PubKeyHash
PV1.PubKeyHash (ByteString -> ToBuiltin ByteString
forall a. HasToBuiltin a => a -> ToBuiltin a
PV1.toBuiltin (Hash HASH KeyRoleVRF -> ByteString
forall h a. Hash h a -> ByteString
hashToBytes (VRFVerKeyHash StakePoolVRF -> Hash HASH KeyRoleVRF
forall (r :: KeyRoleVRF). VRFVerKeyHash r -> Hash HASH KeyRoleVRF
unVRFVerKeyHash VRFVerKeyHash StakePoolVRF
sppVrf))))
RetirePoolTxCert KeyHash StakePool
poolId EpochNo
retireEpochNo ->
DCert -> Either (ContextError era) DCert
forall a b. b -> Either a b
Right (DCert -> Either (ContextError era) DCert)
-> DCert -> Either (ContextError era) DCert
forall a b. (a -> b) -> a -> b
$ PubKeyHash -> Integer -> DCert
PV1.DCertPoolRetire (KeyHash StakePool -> PubKeyHash
forall (d :: KeyRole). KeyHash d -> PubKeyHash
transKeyHash KeyHash StakePool
poolId) (EpochNo -> Integer
transEpochNo EpochNo
retireEpochNo)
TxCert era
txCert -> ContextError era -> Either (ContextError era) DCert
forall a b. a -> Either a b
Left (ContextError era -> Either (ContextError era) DCert)
-> ContextError era -> Either (ContextError era) DCert
forall a b. (a -> b) -> a -> b
$ ConwayContextError era -> ContextError era
forall t s. Inject t s => t -> s
inject (ConwayContextError era -> ContextError era)
-> ConwayContextError era -> ContextError era
forall a b. (a -> b) -> a -> b
$ TxCert era -> ConwayContextError era
forall era. TxCert era -> ConwayContextError era
CertificateNotSupported TxCert era
txCert
instance EraPlutusTxInfo 'PlutusV2 DijkstraEra where
toPlutusTxCert :: forall (proxy :: Language -> *).
proxy 'PlutusV2
-> ProtVer
-> TxCert DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxCert 'PlutusV2)
toPlutusTxCert proxy 'PlutusV2
_ ProtVer
_ = TxCert DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxCert 'PlutusV2)
TxCert DijkstraEra -> Either (ContextError DijkstraEra) DCert
forall era.
(ConwayEraTxCert era,
Inject (ConwayContextError era) (ContextError era)) =>
TxCert era -> Either (ContextError era) DCert
transTxCertV1V2
toPlutusScriptPurpose :: forall (proxy :: Language -> *).
proxy 'PlutusV2
-> ProtVer
-> PlutusPurpose AsIxItem DijkstraEra
-> Either
(ContextError DijkstraEra) (PlutusScriptPurpose 'PlutusV2)
toPlutusScriptPurpose = proxy 'PlutusV2
-> ProtVer
-> PlutusPurpose AsIxItem DijkstraEra
-> Either
(ContextError DijkstraEra) (PlutusScriptPurpose 'PlutusV2)
proxy 'PlutusV2
-> ProtVer
-> PlutusPurpose AsIxItem DijkstraEra
-> Either (ContextError DijkstraEra) ScriptPurpose
forall (l :: Language) era (proxy :: Language -> *).
(PlutusTxCert l ~ DCert, EraPlutusTxInfo l era,
Inject (ConwayContextError era) (ContextError era)) =>
proxy l
-> ProtVer
-> PlutusPurpose AsIxItem era
-> Either (ContextError era) ScriptPurpose
Conway.transPlutusPurposeV1V2
toPlutusTxInfo :: forall (proxy :: Language -> *).
proxy 'PlutusV2
-> LedgerTxInfo DijkstraEra
-> PlutusTxInfoResult 'PlutusV2 DijkstraEra
toPlutusTxInfo proxy 'PlutusV2
proxy LedgerTxInfo {ProtVer
ltiProtVer :: forall era. LedgerTxInfo era -> ProtVer
ltiProtVer :: ProtVer
ltiProtVer, EpochInfo (Either Text)
ltiEpochInfo :: forall era. LedgerTxInfo era -> EpochInfo (Either Text)
ltiEpochInfo :: EpochInfo (Either Text)
ltiEpochInfo, SystemStart
ltiSystemStart :: forall era. LedgerTxInfo era -> SystemStart
ltiSystemStart :: SystemStart
ltiSystemStart, UTxO DijkstraEra
ltiUTxO :: forall era. LedgerTxInfo era -> UTxO era
ltiUTxO :: UTxO DijkstraEra
ltiUTxO, Tx level DijkstraEra
ltiTx :: ()
ltiTx :: Tx level DijkstraEra
ltiTx} =
((Tx TopTx DijkstraEra -> PlutusTxInfoResult 'PlutusV2 DijkstraEra)
-> (Tx SubTx DijkstraEra
-> PlutusTxInfoResult 'PlutusV2 DijkstraEra)
-> PlutusTxInfoResult 'PlutusV2 DijkstraEra)
-> (Tx SubTx DijkstraEra
-> PlutusTxInfoResult 'PlutusV2 DijkstraEra)
-> (Tx TopTx DijkstraEra
-> PlutusTxInfoResult 'PlutusV2 DijkstraEra)
-> PlutusTxInfoResult 'PlutusV2 DijkstraEra
forall a b c. (a -> b -> c) -> b -> a -> c
flip (Tx level DijkstraEra
-> (Tx TopTx DijkstraEra
-> PlutusTxInfoResult 'PlutusV2 DijkstraEra)
-> (Tx SubTx DijkstraEra
-> PlutusTxInfoResult 'PlutusV2 DijkstraEra)
-> PlutusTxInfoResult 'PlutusV2 DijkstraEra
forall (t :: TxLevel -> * -> *) era (l :: TxLevel) a.
(HasEraTxLevel t era, STxLevel l era ~ STxBothLevels l era) =>
t l era -> (t TopTx era -> a) -> (t SubTx era -> a) -> a
withBothTxLevels Tx level DijkstraEra
ltiTx) Tx SubTx DijkstraEra -> PlutusTxInfoResult 'PlutusV2 DijkstraEra
forall (l :: Language) era.
(EraTx era,
Inject (DijkstraContextError era) (ContextError era)) =>
Tx SubTx era -> PlutusTxInfoResult l era
transFailSubTxIsNotSupported ((Tx TopTx DijkstraEra -> PlutusTxInfoResult 'PlutusV2 DijkstraEra)
-> PlutusTxInfoResult 'PlutusV2 DijkstraEra)
-> (Tx TopTx DijkstraEra
-> PlutusTxInfoResult 'PlutusV2 DijkstraEra)
-> PlutusTxInfoResult 'PlutusV2 DijkstraEra
forall a b. (a -> b) -> a -> b
$ \Tx TopTx DijkstraEra
tx -> Either
(ContextError DijkstraEra)
(PlutusPurpose AsPurpose DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV2))
-> PlutusTxInfoResult 'PlutusV2 DijkstraEra
forall (l :: Language) era.
Either
(ContextError era)
(PlutusPurpose AsPurpose era
-> Either (ContextError era) (PlutusTxInfo l))
-> PlutusTxInfoResult l era
PlutusTxInfoResult (Either
(ContextError DijkstraEra)
(PlutusPurpose AsPurpose DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV2))
-> PlutusTxInfoResult 'PlutusV2 DijkstraEra)
-> Either
(ContextError DijkstraEra)
(PlutusPurpose AsPurpose DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV2))
-> PlutusTxInfoResult 'PlutusV2 DijkstraEra
forall a b. (a -> b) -> a -> b
$ do
let txBody :: TxBody TopTx DijkstraEra
txBody = Tx TopTx DijkstraEra
tx Tx TopTx DijkstraEra
-> Getting
(TxBody TopTx DijkstraEra)
(Tx TopTx DijkstraEra)
(TxBody TopTx DijkstraEra)
-> TxBody TopTx DijkstraEra
forall s a. s -> Getting a s a -> a
^. Getting
(TxBody TopTx DijkstraEra)
(Tx TopTx DijkstraEra)
(TxBody TopTx DijkstraEra)
forall era (l :: TxLevel).
EraTx era =>
Lens' (Tx l era) (TxBody l era)
forall (l :: TxLevel).
Lens' (Tx l DijkstraEra) (TxBody l DijkstraEra)
bodyTxL
Tx TopTx DijkstraEra -> Either (ContextError DijkstraEra) ()
forall era (l :: TxLevel).
(EraTx era, ConwayEraTxBody era,
Inject (ConwayContextError era) (ContextError era)) =>
Tx l era -> Either (ContextError era) ()
Conway.guardConwayFeaturesForPlutusV1V2 Tx TopTx DijkstraEra
tx
timeRange <-
Tx TopTx DijkstraEra
-> EpochInfo (Either Text)
-> SystemStart
-> ValidityInterval
-> Either (DijkstraContextError DijkstraEra) POSIXTimeRange
forall (proxy :: * -> *) era a.
Inject (AlonzoContextError era) a =>
proxy era
-> EpochInfo (Either Text)
-> SystemStart
-> ValidityInterval
-> Either a POSIXTimeRange
Conway.transValidityInterval Tx TopTx DijkstraEra
tx EpochInfo (Either Text)
ltiEpochInfo SystemStart
ltiSystemStart (TxBody TopTx DijkstraEra
txBody TxBody TopTx DijkstraEra
-> Getting
ValidityInterval (TxBody TopTx DijkstraEra) ValidityInterval
-> ValidityInterval
forall s a. s -> Getting a s a -> a
^. Getting
ValidityInterval (TxBody TopTx DijkstraEra) ValidityInterval
forall era (l :: TxLevel).
AllegraEraTxBody era =>
Lens' (TxBody l era) ValidityInterval
forall (l :: TxLevel).
Lens' (TxBody l DijkstraEra) ValidityInterval
vldtTxBodyL)
inputs <- mapM (Babbage.transTxInInfoV2 ltiUTxO) (Set.toList (txBody ^. inputsTxBodyL))
refInputs <- mapM (Babbage.transTxInInfoV2 ltiUTxO) (Set.toList (txBody ^. referenceInputsTxBodyL))
outputs <-
zipWithM
(Babbage.transTxOutV2 . TxOutFromOutput)
[minBound ..]
(F.toList (txBody ^. outputsTxBodyL))
txCerts <- Alonzo.transTxBodyCerts proxy ltiProtVer txBody
plutusRedeemers <- Babbage.transTxRedeemers proxy ltiProtVer tx
let
txInfo =
PV2.TxInfo
{ txInfoInputs :: [TxInInfo]
PV2.txInfoInputs = [TxInInfo]
inputs
, txInfoOutputs :: [TxOut]
PV2.txInfoOutputs = [TxOut]
outputs
, txInfoReferenceInputs :: [TxInInfo]
PV2.txInfoReferenceInputs = [TxInInfo]
refInputs
, txInfoFee :: Value
PV2.txInfoFee = Coin -> Value
transCoinToValue (TxBody TopTx DijkstraEra
txBody TxBody TopTx DijkstraEra
-> Getting Coin (TxBody TopTx DijkstraEra) Coin -> Coin
forall s a. s -> Getting a s a -> a
^. Getting Coin (TxBody TopTx DijkstraEra) Coin
forall era. EraTxBody era => Lens' (TxBody TopTx era) Coin
Lens' (TxBody TopTx DijkstraEra) Coin
feeTxBodyL)
, txInfoMint :: Value
PV2.txInfoMint = MultiAsset -> Value
Alonzo.transMintValue (TxBody TopTx DijkstraEra
txBody TxBody TopTx DijkstraEra
-> Getting MultiAsset (TxBody TopTx DijkstraEra) MultiAsset
-> MultiAsset
forall s a. s -> Getting a s a -> a
^. Getting MultiAsset (TxBody TopTx DijkstraEra) MultiAsset
forall era (l :: TxLevel).
MaryEraTxBody era =>
Lens' (TxBody l era) MultiAsset
forall (l :: TxLevel). Lens' (TxBody l DijkstraEra) MultiAsset
mintTxBodyL)
, txInfoDCert :: [DCert]
PV2.txInfoDCert = [DCert]
txCerts
, txInfoWdrl :: Map StakingCredential Integer
PV2.txInfoWdrl = [(StakingCredential, Integer)] -> Map StakingCredential Integer
forall k v. [(k, v)] -> Map k v
PV2.unsafeFromList ([(StakingCredential, Integer)] -> Map StakingCredential Integer)
-> [(StakingCredential, Integer)] -> Map StakingCredential Integer
forall a b. (a -> b) -> a -> b
$ TxBody TopTx DijkstraEra -> [(StakingCredential, Integer)]
forall era (t :: TxLevel).
EraTxBody era =>
TxBody t era -> [(StakingCredential, Integer)]
Alonzo.transTxBodyWithdrawals TxBody TopTx DijkstraEra
txBody
, txInfoValidRange :: POSIXTimeRange
PV2.txInfoValidRange = POSIXTimeRange
timeRange
, txInfoSignatories :: [PubKeyHash]
PV2.txInfoSignatories = TxBody TopTx DijkstraEra -> [PubKeyHash]
forall era (t :: TxLevel).
AlonzoEraTxBody era =>
TxBody t era -> [PubKeyHash]
Alonzo.transTxBodyReqSignerHashes TxBody TopTx DijkstraEra
txBody
, txInfoRedeemers :: Map ScriptPurpose Redeemer
PV2.txInfoRedeemers = Map ScriptPurpose Redeemer
plutusRedeemers
, txInfoData :: Map DatumHash Datum
PV2.txInfoData = [(DatumHash, Datum)] -> Map DatumHash Datum
forall k v. [(k, v)] -> Map k v
PV2.unsafeFromList ([(DatumHash, Datum)] -> Map DatumHash Datum)
-> [(DatumHash, Datum)] -> Map DatumHash Datum
forall a b. (a -> b) -> a -> b
$ TxWits DijkstraEra -> [(DatumHash, Datum)]
forall era.
AlonzoEraTxWits era =>
TxWits era -> [(DatumHash, Datum)]
Alonzo.transTxWitsDatums (Tx TopTx DijkstraEra
tx Tx TopTx DijkstraEra
-> Getting
(TxWits DijkstraEra) (Tx TopTx DijkstraEra) (TxWits DijkstraEra)
-> TxWits DijkstraEra
forall s a. s -> Getting a s a -> a
^. Getting
(TxWits DijkstraEra) (Tx TopTx DijkstraEra) (TxWits DijkstraEra)
forall era (l :: TxLevel).
EraTx era =>
Lens' (Tx l era) (TxWits era)
forall (l :: TxLevel).
Lens' (Tx l DijkstraEra) (TxWits DijkstraEra)
witsTxL)
, txInfoId :: TxId
PV2.txInfoId = TxBody TopTx DijkstraEra -> TxId
forall era (l :: TxLevel). EraTxBody era => TxBody l era -> TxId
Alonzo.transTxBodyId TxBody TopTx DijkstraEra
txBody
}
Right $ \DijkstraPlutusPurpose AsPurpose DijkstraEra
_ -> TxInfo -> Either (DijkstraContextError DijkstraEra) TxInfo
forall a b. b -> Either a b
Right TxInfo
txInfo
toPlutusArgs :: forall (proxy :: Language -> *).
proxy 'PlutusV2
-> ProtVer
-> PlutusTxInfo 'PlutusV2
-> PlutusPurpose AsIxItem DijkstraEra
-> Maybe (Data DijkstraEra)
-> Data DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusArgs 'PlutusV2)
toPlutusArgs = proxy 'PlutusV2
-> ProtVer
-> PlutusTxInfo 'PlutusV2
-> PlutusPurpose AsIxItem DijkstraEra
-> Maybe (Data DijkstraEra)
-> Data DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusArgs 'PlutusV2)
proxy 'PlutusV2
-> ProtVer
-> TxInfo
-> PlutusPurpose AsIxItem DijkstraEra
-> Maybe (Data DijkstraEra)
-> Data DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusArgs 'PlutusV2)
forall era (proxy :: Language -> *).
EraPlutusTxInfo 'PlutusV2 era =>
proxy 'PlutusV2
-> ProtVer
-> TxInfo
-> PlutusPurpose AsIxItem era
-> Maybe (Data era)
-> Data era
-> Either (ContextError era) (PlutusArgs 'PlutusV2)
Babbage.toPlutusV2Args
toPlutusTxInInfo :: forall (proxy :: Language -> *).
proxy 'PlutusV2
-> UTxO DijkstraEra
-> TxIn
-> Either
(ContextError DijkstraEra) (PlutusTxInInfo DijkstraEra 'PlutusV2)
toPlutusTxInInfo proxy 'PlutusV2
_ = UTxO DijkstraEra
-> TxIn
-> Either
(ContextError DijkstraEra) (PlutusTxInInfo DijkstraEra 'PlutusV2)
UTxO DijkstraEra
-> TxIn -> Either (ContextError DijkstraEra) TxInInfo
forall era.
(Inject (BabbageContextError era) (ContextError era),
Value era ~ MaryValue, BabbageEraTxOut era) =>
UTxO era -> TxIn -> Either (ContextError era) TxInInfo
Babbage.transTxInInfoV2
instance EraPlutusTxInfo 'PlutusV3 DijkstraEra where
toPlutusTxCert :: forall (proxy :: Language -> *).
proxy 'PlutusV3
-> ProtVer
-> TxCert DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxCert 'PlutusV3)
toPlutusTxCert proxy 'PlutusV3
_ ProtVer
_ = TxCert -> Either (DijkstraContextError DijkstraEra) TxCert
forall a. a -> Either (DijkstraContextError DijkstraEra) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TxCert -> Either (DijkstraContextError DijkstraEra) TxCert)
-> (DijkstraTxCert DijkstraEra -> TxCert)
-> DijkstraTxCert DijkstraEra
-> Either (DijkstraContextError DijkstraEra) TxCert
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxCert DijkstraEra -> TxCert
DijkstraTxCert DijkstraEra -> TxCert
forall era.
(ConwayEraTxCert era, TxCert era ~ DijkstraTxCert era) =>
TxCert era -> TxCert
transTxCert
toPlutusScriptPurpose :: forall (proxy :: Language -> *).
proxy 'PlutusV3
-> ProtVer
-> PlutusPurpose AsIxItem DijkstraEra
-> Either
(ContextError DijkstraEra) (PlutusScriptPurpose 'PlutusV3)
toPlutusScriptPurpose = proxy 'PlutusV3
-> ProtVer
-> PlutusPurpose AsIxItem DijkstraEra
-> Either
(ContextError DijkstraEra) (PlutusScriptPurpose 'PlutusV3)
proxy 'PlutusV3
-> ProtVer
-> PlutusPurpose AsIxItem DijkstraEra
-> Either (ContextError DijkstraEra) ScriptPurpose
forall era (proxy :: Language -> *).
(ConwayEraPlutusTxInfo 'PlutusV3 era,
Inject (ConwayContextError era) (ContextError era)) =>
proxy 'PlutusV3
-> ProtVer
-> PlutusPurpose AsIxItem era
-> Either (ContextError era) ScriptPurpose
Conway.transPlutusPurposeV3
toPlutusTxInfo :: forall (proxy :: Language -> *).
proxy 'PlutusV3
-> LedgerTxInfo DijkstraEra
-> PlutusTxInfoResult 'PlutusV3 DijkstraEra
toPlutusTxInfo proxy 'PlutusV3
proxy LedgerTxInfo {ProtVer
ltiProtVer :: forall era. LedgerTxInfo era -> ProtVer
ltiProtVer :: ProtVer
ltiProtVer, EpochInfo (Either Text)
ltiEpochInfo :: forall era. LedgerTxInfo era -> EpochInfo (Either Text)
ltiEpochInfo :: EpochInfo (Either Text)
ltiEpochInfo, SystemStart
ltiSystemStart :: forall era. LedgerTxInfo era -> SystemStart
ltiSystemStart :: SystemStart
ltiSystemStart, UTxO DijkstraEra
ltiUTxO :: forall era. LedgerTxInfo era -> UTxO era
ltiUTxO :: UTxO DijkstraEra
ltiUTxO, Tx level DijkstraEra
ltiTx :: ()
ltiTx :: Tx level DijkstraEra
ltiTx} =
((Tx TopTx DijkstraEra -> PlutusTxInfoResult 'PlutusV3 DijkstraEra)
-> (Tx SubTx DijkstraEra
-> PlutusTxInfoResult 'PlutusV3 DijkstraEra)
-> PlutusTxInfoResult 'PlutusV3 DijkstraEra)
-> (Tx SubTx DijkstraEra
-> PlutusTxInfoResult 'PlutusV3 DijkstraEra)
-> (Tx TopTx DijkstraEra
-> PlutusTxInfoResult 'PlutusV3 DijkstraEra)
-> PlutusTxInfoResult 'PlutusV3 DijkstraEra
forall a b c. (a -> b -> c) -> b -> a -> c
flip (Tx level DijkstraEra
-> (Tx TopTx DijkstraEra
-> PlutusTxInfoResult 'PlutusV3 DijkstraEra)
-> (Tx SubTx DijkstraEra
-> PlutusTxInfoResult 'PlutusV3 DijkstraEra)
-> PlutusTxInfoResult 'PlutusV3 DijkstraEra
forall (t :: TxLevel -> * -> *) era (l :: TxLevel) a.
(HasEraTxLevel t era, STxLevel l era ~ STxBothLevels l era) =>
t l era -> (t TopTx era -> a) -> (t SubTx era -> a) -> a
withBothTxLevels Tx level DijkstraEra
ltiTx) Tx SubTx DijkstraEra -> PlutusTxInfoResult 'PlutusV3 DijkstraEra
forall (l :: Language) era.
(EraTx era,
Inject (DijkstraContextError era) (ContextError era)) =>
Tx SubTx era -> PlutusTxInfoResult l era
transFailSubTxIsNotSupported ((Tx TopTx DijkstraEra -> PlutusTxInfoResult 'PlutusV3 DijkstraEra)
-> PlutusTxInfoResult 'PlutusV3 DijkstraEra)
-> (Tx TopTx DijkstraEra
-> PlutusTxInfoResult 'PlutusV3 DijkstraEra)
-> PlutusTxInfoResult 'PlutusV3 DijkstraEra
forall a b. (a -> b) -> a -> b
$ \Tx TopTx DijkstraEra
tx -> Either
(ContextError DijkstraEra)
(PlutusPurpose AsPurpose DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV3))
-> PlutusTxInfoResult 'PlutusV3 DijkstraEra
forall (l :: Language) era.
Either
(ContextError era)
(PlutusPurpose AsPurpose era
-> Either (ContextError era) (PlutusTxInfo l))
-> PlutusTxInfoResult l era
PlutusTxInfoResult (Either
(ContextError DijkstraEra)
(PlutusPurpose AsPurpose DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV3))
-> PlutusTxInfoResult 'PlutusV3 DijkstraEra)
-> Either
(ContextError DijkstraEra)
(PlutusPurpose AsPurpose DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV3))
-> PlutusTxInfoResult 'PlutusV3 DijkstraEra
forall a b. (a -> b) -> a -> b
$ do
let
txBody :: TxBody TopTx DijkstraEra
txBody = Tx TopTx DijkstraEra
tx Tx TopTx DijkstraEra
-> Getting
(TxBody TopTx DijkstraEra)
(Tx TopTx DijkstraEra)
(TxBody TopTx DijkstraEra)
-> TxBody TopTx DijkstraEra
forall s a. s -> Getting a s a -> a
^. Getting
(TxBody TopTx DijkstraEra)
(Tx TopTx DijkstraEra)
(TxBody TopTx DijkstraEra)
forall era (l :: TxLevel).
EraTx era =>
Lens' (Tx l era) (TxBody l era)
forall (l :: TxLevel).
Lens' (Tx l DijkstraEra) (TxBody l DijkstraEra)
bodyTxL
txInputs :: Set TxIn
txInputs = TxBody TopTx DijkstraEra
txBody TxBody TopTx DijkstraEra
-> Getting (Set TxIn) (TxBody TopTx DijkstraEra) (Set TxIn)
-> Set TxIn
forall s a. s -> Getting a s a -> a
^. Getting (Set TxIn) (TxBody TopTx DijkstraEra) (Set TxIn)
forall era (l :: TxLevel).
EraTxBody era =>
Lens' (TxBody l era) (Set TxIn)
forall (l :: TxLevel). Lens' (TxBody l DijkstraEra) (Set TxIn)
inputsTxBodyL
refInputs :: Set TxIn
refInputs = TxBody TopTx DijkstraEra
txBody TxBody TopTx DijkstraEra
-> Getting (Set TxIn) (TxBody TopTx DijkstraEra) (Set TxIn)
-> Set TxIn
forall s a. s -> Getting a s a -> a
^. Getting (Set TxIn) (TxBody TopTx DijkstraEra) (Set TxIn)
forall era (l :: TxLevel).
BabbageEraTxBody era =>
Lens' (TxBody l era) (Set TxIn)
forall (l :: TxLevel). Lens' (TxBody l DijkstraEra) (Set TxIn)
referenceInputsTxBodyL
timeRange <-
Tx TopTx DijkstraEra
-> EpochInfo (Either Text)
-> SystemStart
-> ValidityInterval
-> Either (DijkstraContextError DijkstraEra) POSIXTimeRange
forall (proxy :: * -> *) era a.
Inject (AlonzoContextError era) a =>
proxy era
-> EpochInfo (Either Text)
-> SystemStart
-> ValidityInterval
-> Either a POSIXTimeRange
Conway.transValidityInterval Tx TopTx DijkstraEra
tx EpochInfo (Either Text)
ltiEpochInfo SystemStart
ltiSystemStart (TxBody TopTx DijkstraEra
txBody TxBody TopTx DijkstraEra
-> Getting
ValidityInterval (TxBody TopTx DijkstraEra) ValidityInterval
-> ValidityInterval
forall s a. s -> Getting a s a -> a
^. Getting
ValidityInterval (TxBody TopTx DijkstraEra) ValidityInterval
forall era (l :: TxLevel).
AllegraEraTxBody era =>
Lens' (TxBody l era) ValidityInterval
forall (l :: TxLevel).
Lens' (TxBody l DijkstraEra) ValidityInterval
vldtTxBodyL)
inputsInfo <- mapM (Conway.transTxInInfoV3 ltiUTxO) (Set.toList txInputs)
refInputsInfo <- mapM (Conway.transTxInInfoV3 ltiUTxO) (Set.toList refInputs)
Conway.checkReferenceInputsNotDisjointFromInputs txBody
outputs <-
zipWithM
(Babbage.transTxOutV2 . TxOutFromOutput)
[minBound ..]
(F.toList (txBody ^. outputsTxBodyL))
txCerts <- Alonzo.transTxBodyCerts proxy ltiProtVer txBody
plutusRedeemers <- Babbage.transTxRedeemers proxy ltiProtVer tx
let
txInfo =
PV3.TxInfo
{ txInfoInputs :: [TxInInfo]
PV3.txInfoInputs = [TxInInfo]
inputsInfo
, txInfoOutputs :: [TxOut]
PV3.txInfoOutputs = [TxOut]
outputs
, txInfoReferenceInputs :: [TxInInfo]
PV3.txInfoReferenceInputs = [TxInInfo]
refInputsInfo
, txInfoFee :: Lovelace
PV3.txInfoFee = Coin -> Lovelace
transCoinToLovelace (TxBody TopTx DijkstraEra
txBody TxBody TopTx DijkstraEra
-> Getting Coin (TxBody TopTx DijkstraEra) Coin -> Coin
forall s a. s -> Getting a s a -> a
^. Getting Coin (TxBody TopTx DijkstraEra) Coin
forall era. EraTxBody era => Lens' (TxBody TopTx era) Coin
Lens' (TxBody TopTx DijkstraEra) Coin
feeTxBodyL)
, txInfoMint :: MintValue
PV3.txInfoMint = MultiAsset -> MintValue
Conway.transMintValue (TxBody TopTx DijkstraEra
txBody TxBody TopTx DijkstraEra
-> Getting MultiAsset (TxBody TopTx DijkstraEra) MultiAsset
-> MultiAsset
forall s a. s -> Getting a s a -> a
^. Getting MultiAsset (TxBody TopTx DijkstraEra) MultiAsset
forall era (l :: TxLevel).
MaryEraTxBody era =>
Lens' (TxBody l era) MultiAsset
forall (l :: TxLevel). Lens' (TxBody l DijkstraEra) MultiAsset
mintTxBodyL)
, txInfoTxCerts :: [TxCert]
PV3.txInfoTxCerts = [TxCert]
txCerts
, txInfoWdrl :: Map Credential Lovelace
PV3.txInfoWdrl = TxBody TopTx DijkstraEra -> Map Credential Lovelace
forall era (l :: TxLevel).
EraTxBody era =>
TxBody l era -> Map Credential Lovelace
Conway.transTxBodyWithdrawals TxBody TopTx DijkstraEra
txBody
, txInfoValidRange :: POSIXTimeRange
PV3.txInfoValidRange = POSIXTimeRange
timeRange
, txInfoSignatories :: [PubKeyHash]
PV3.txInfoSignatories = TxBody TopTx DijkstraEra -> [PubKeyHash]
forall era (t :: TxLevel).
AlonzoEraTxBody era =>
TxBody t era -> [PubKeyHash]
Alonzo.transTxBodyReqSignerHashes TxBody TopTx DijkstraEra
txBody
, txInfoRedeemers :: Map ScriptPurpose Redeemer
PV3.txInfoRedeemers = Map ScriptPurpose Redeemer
plutusRedeemers
, txInfoData :: Map DatumHash Datum
PV3.txInfoData = [(DatumHash, Datum)] -> Map DatumHash Datum
forall k v. [(k, v)] -> Map k v
PV3.unsafeFromList ([(DatumHash, Datum)] -> Map DatumHash Datum)
-> [(DatumHash, Datum)] -> Map DatumHash Datum
forall a b. (a -> b) -> a -> b
$ TxWits DijkstraEra -> [(DatumHash, Datum)]
forall era.
AlonzoEraTxWits era =>
TxWits era -> [(DatumHash, Datum)]
Alonzo.transTxWitsDatums (Tx TopTx DijkstraEra
tx Tx TopTx DijkstraEra
-> Getting
(TxWits DijkstraEra) (Tx TopTx DijkstraEra) (TxWits DijkstraEra)
-> TxWits DijkstraEra
forall s a. s -> Getting a s a -> a
^. Getting
(TxWits DijkstraEra) (Tx TopTx DijkstraEra) (TxWits DijkstraEra)
forall era (l :: TxLevel).
EraTx era =>
Lens' (Tx l era) (TxWits era)
forall (l :: TxLevel).
Lens' (Tx l DijkstraEra) (TxWits DijkstraEra)
witsTxL)
, txInfoId :: TxId
PV3.txInfoId = TxBody TopTx DijkstraEra -> TxId
forall era (l :: TxLevel). EraTxBody era => TxBody l era -> TxId
Conway.transTxBodyId TxBody TopTx DijkstraEra
txBody
, txInfoVotes :: Map Voter (Map GovernanceActionId Vote)
PV3.txInfoVotes = VotingProcedures DijkstraEra
-> Map Voter (Map GovernanceActionId Vote)
forall era.
VotingProcedures era -> Map Voter (Map GovernanceActionId Vote)
Conway.transVotingProcedures (TxBody TopTx DijkstraEra
txBody TxBody TopTx DijkstraEra
-> Getting
(VotingProcedures DijkstraEra)
(TxBody TopTx DijkstraEra)
(VotingProcedures DijkstraEra)
-> VotingProcedures DijkstraEra
forall s a. s -> Getting a s a -> a
^. Getting
(VotingProcedures DijkstraEra)
(TxBody TopTx DijkstraEra)
(VotingProcedures DijkstraEra)
forall era (l :: TxLevel).
ConwayEraTxBody era =>
Lens' (TxBody l era) (VotingProcedures era)
forall (l :: TxLevel).
Lens' (TxBody l DijkstraEra) (VotingProcedures DijkstraEra)
votingProceduresTxBodyL)
, txInfoProposalProcedures :: [ProposalProcedure]
PV3.txInfoProposalProcedures =
(ProposalProcedure DijkstraEra -> ProposalProcedure)
-> [ProposalProcedure DijkstraEra] -> [ProposalProcedure]
forall a b. (a -> b) -> [a] -> [b]
map (proxy 'PlutusV3
-> ProposalProcedure DijkstraEra -> ProposalProcedure
forall (l :: Language) era (proxy :: Language -> *).
ConwayEraPlutusTxInfo l era =>
proxy l -> ProposalProcedure era -> ProposalProcedure
Conway.transProposal proxy 'PlutusV3
proxy) ([ProposalProcedure DijkstraEra] -> [ProposalProcedure])
-> [ProposalProcedure DijkstraEra] -> [ProposalProcedure]
forall a b. (a -> b) -> a -> b
$ OSet (ProposalProcedure DijkstraEra)
-> [ProposalProcedure DijkstraEra]
forall a. OSet a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList (TxBody TopTx DijkstraEra
txBody TxBody TopTx DijkstraEra
-> Getting
(OSet (ProposalProcedure DijkstraEra))
(TxBody TopTx DijkstraEra)
(OSet (ProposalProcedure DijkstraEra))
-> OSet (ProposalProcedure DijkstraEra)
forall s a. s -> Getting a s a -> a
^. Getting
(OSet (ProposalProcedure DijkstraEra))
(TxBody TopTx DijkstraEra)
(OSet (ProposalProcedure DijkstraEra))
forall era (l :: TxLevel).
ConwayEraTxBody era =>
Lens' (TxBody l era) (OSet (ProposalProcedure era))
forall (l :: TxLevel).
Lens' (TxBody l DijkstraEra) (OSet (ProposalProcedure DijkstraEra))
proposalProceduresTxBodyL)
, txInfoCurrentTreasuryAmount :: Maybe Lovelace
PV3.txInfoCurrentTreasuryAmount =
Maybe Lovelace
-> (Coin -> Maybe Lovelace) -> StrictMaybe Coin -> Maybe Lovelace
forall a b. a -> (b -> a) -> StrictMaybe b -> a
strictMaybe Maybe Lovelace
forall a. Maybe a
Nothing (Lovelace -> Maybe Lovelace
forall a. a -> Maybe a
Just (Lovelace -> Maybe Lovelace)
-> (Coin -> Lovelace) -> Coin -> Maybe Lovelace
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Coin -> Lovelace
transCoinToLovelace) (StrictMaybe Coin -> Maybe Lovelace)
-> StrictMaybe Coin -> Maybe Lovelace
forall a b. (a -> b) -> a -> b
$ TxBody TopTx DijkstraEra
txBody TxBody TopTx DijkstraEra
-> Getting
(StrictMaybe Coin) (TxBody TopTx DijkstraEra) (StrictMaybe Coin)
-> StrictMaybe Coin
forall s a. s -> Getting a s a -> a
^. Getting
(StrictMaybe Coin) (TxBody TopTx DijkstraEra) (StrictMaybe Coin)
forall era (l :: TxLevel).
ConwayEraTxBody era =>
Lens' (TxBody l era) (StrictMaybe Coin)
forall (l :: TxLevel).
Lens' (TxBody l DijkstraEra) (StrictMaybe Coin)
currentTreasuryValueTxBodyL
, txInfoTreasuryDonation :: Maybe Lovelace
PV3.txInfoTreasuryDonation =
case TxBody TopTx DijkstraEra
txBody TxBody TopTx DijkstraEra
-> Getting Coin (TxBody TopTx DijkstraEra) Coin -> Coin
forall s a. s -> Getting a s a -> a
^. Getting Coin (TxBody TopTx DijkstraEra) Coin
forall era (l :: TxLevel).
ConwayEraTxBody era =>
Lens' (TxBody l era) Coin
forall (l :: TxLevel). Lens' (TxBody l DijkstraEra) Coin
treasuryDonationTxBodyL of
Coin Integer
0 -> Maybe Lovelace
forall a. Maybe a
Nothing
Coin
coin -> Lovelace -> Maybe Lovelace
forall a. a -> Maybe a
Just (Lovelace -> Maybe Lovelace) -> Lovelace -> Maybe Lovelace
forall a b. (a -> b) -> a -> b
$ Coin -> Lovelace
transCoinToLovelace Coin
coin
}
Right $ \DijkstraPlutusPurpose AsPurpose DijkstraEra
_ -> TxInfo -> Either (DijkstraContextError DijkstraEra) TxInfo
forall a b. b -> Either a b
Right TxInfo
txInfo
toPlutusArgs :: forall (proxy :: Language -> *).
proxy 'PlutusV3
-> ProtVer
-> PlutusTxInfo 'PlutusV3
-> PlutusPurpose AsIxItem DijkstraEra
-> Maybe (Data DijkstraEra)
-> Data DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusArgs 'PlutusV3)
toPlutusArgs = proxy 'PlutusV3
-> ProtVer
-> PlutusTxInfo 'PlutusV3
-> PlutusPurpose AsIxItem DijkstraEra
-> Maybe (Data DijkstraEra)
-> Data DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusArgs 'PlutusV3)
proxy 'PlutusV3
-> ProtVer
-> TxInfo
-> PlutusPurpose AsIxItem DijkstraEra
-> Maybe (Data DijkstraEra)
-> Data DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusArgs 'PlutusV3)
forall era (proxy :: Language -> *).
EraPlutusTxInfo 'PlutusV3 era =>
proxy 'PlutusV3
-> ProtVer
-> TxInfo
-> PlutusPurpose AsIxItem era
-> Maybe (Data era)
-> Data era
-> Either (ContextError era) (PlutusArgs 'PlutusV3)
Conway.toPlutusV3Args
toPlutusTxInInfo :: forall (proxy :: Language -> *).
proxy 'PlutusV3
-> UTxO DijkstraEra
-> TxIn
-> Either
(ContextError DijkstraEra) (PlutusTxInInfo DijkstraEra 'PlutusV3)
toPlutusTxInInfo proxy 'PlutusV3
_ = UTxO DijkstraEra
-> TxIn
-> Either
(ContextError DijkstraEra) (PlutusTxInInfo DijkstraEra 'PlutusV3)
UTxO DijkstraEra
-> TxIn -> Either (ContextError DijkstraEra) TxInInfo
forall era.
(Inject (BabbageContextError era) (ContextError era),
Value era ~ MaryValue, BabbageEraTxOut era) =>
UTxO era -> TxIn -> Either (ContextError era) TxInInfo
transTxInInfoV3
transFailSubTxIsNotSupported ::
forall l era.
(EraTx era, Inject (DijkstraContextError era) (ContextError era)) =>
Tx SubTx era -> PlutusTxInfoResult l era
transFailSubTxIsNotSupported :: forall (l :: Language) era.
(EraTx era,
Inject (DijkstraContextError era) (ContextError era)) =>
Tx SubTx era -> PlutusTxInfoResult l era
transFailSubTxIsNotSupported Tx SubTx era
tx =
Either
(ContextError era)
(PlutusPurpose AsPurpose era
-> Either (ContextError era) (PlutusTxInfo l))
-> PlutusTxInfoResult l era
forall (l :: Language) era.
Either
(ContextError era)
(PlutusPurpose AsPurpose era
-> Either (ContextError era) (PlutusTxInfo l))
-> PlutusTxInfoResult l era
PlutusTxInfoResult (Either
(ContextError era)
(PlutusPurpose AsPurpose era
-> Either (ContextError era) (PlutusTxInfo l))
-> PlutusTxInfoResult l era)
-> Either
(ContextError era)
(PlutusPurpose AsPurpose era
-> Either (ContextError era) (PlutusTxInfo l))
-> PlutusTxInfoResult l era
forall a b. (a -> b) -> a -> b
$ ContextError era
-> Either
(ContextError era)
(PlutusPurpose AsPurpose era
-> Either (ContextError era) (PlutusTxInfo l))
forall a b. a -> Either a b
Left (ContextError era
-> Either
(ContextError era)
(PlutusPurpose AsPurpose era
-> Either (ContextError era) (PlutusTxInfo l)))
-> ContextError era
-> Either
(ContextError era)
(PlutusPurpose AsPurpose era
-> Either (ContextError era) (PlutusTxInfo l))
forall a b. (a -> b) -> a -> b
$ DijkstraContextError era -> ContextError era
forall t s. Inject t s => t -> s
inject (DijkstraContextError era -> ContextError era)
-> DijkstraContextError era -> ContextError era
forall a b. (a -> b) -> a -> b
$ forall era. TxId -> DijkstraContextError era
SubTxIsNotSupported @era (Tx SubTx era -> TxId
forall era (l :: TxLevel). EraTx era => Tx l era -> TxId
txIdTx Tx SubTx era
tx)
transTxCert ::
(ConwayEraTxCert era, TxCert era ~ DijkstraTxCert era) => TxCert era -> PV3.TxCert
transTxCert :: forall era.
(ConwayEraTxCert era, TxCert era ~ DijkstraTxCert era) =>
TxCert era -> TxCert
transTxCert = \case
RegPoolTxCert StakePoolParams {KeyHash StakePool
sppId :: StakePoolParams -> KeyHash StakePool
sppId :: KeyHash StakePool
sppId, VRFVerKeyHash StakePoolVRF
sppVrf :: StakePoolParams -> VRFVerKeyHash StakePoolVRF
sppVrf :: VRFVerKeyHash StakePoolVRF
sppVrf} ->
PubKeyHash -> PubKeyHash -> TxCert
PV3.TxCertPoolRegister
(KeyHash StakePool -> PubKeyHash
forall (d :: KeyRole). KeyHash d -> PubKeyHash
transKeyHash KeyHash StakePool
sppId)
(BuiltinByteString -> PubKeyHash
PV3.PubKeyHash (ByteString -> ToBuiltin ByteString
forall a. HasToBuiltin a => a -> ToBuiltin a
PV3.toBuiltin (Hash HASH KeyRoleVRF -> ByteString
forall h a. Hash h a -> ByteString
hashToBytes (VRFVerKeyHash StakePoolVRF -> Hash HASH KeyRoleVRF
forall (r :: KeyRoleVRF). VRFVerKeyHash r -> Hash HASH KeyRoleVRF
unVRFVerKeyHash VRFVerKeyHash StakePoolVRF
sppVrf))))
RetirePoolTxCert KeyHash StakePool
poolId EpochNo
retireEpochNo ->
PubKeyHash -> Integer -> TxCert
PV3.TxCertPoolRetire (KeyHash StakePool -> PubKeyHash
forall (d :: KeyRole). KeyHash d -> PubKeyHash
transKeyHash KeyHash StakePool
poolId) (EpochNo -> Integer
transEpochNo EpochNo
retireEpochNo)
RegDepositTxCert Credential Staking
stakeCred Coin
deposit ->
Credential -> Maybe Lovelace -> TxCert
PV3.TxCertRegStaking (Credential Staking -> Credential
forall (kr :: KeyRole). Credential kr -> Credential
transCred Credential Staking
stakeCred) (Lovelace -> Maybe Lovelace
forall a. a -> Maybe a
Just (Lovelace -> Maybe Lovelace) -> Lovelace -> Maybe Lovelace
forall a b. (a -> b) -> a -> b
$ Coin -> Lovelace
transCoinToLovelace Coin
deposit)
UnRegDepositTxCert Credential Staking
stakeCred Coin
refund ->
Credential -> Maybe Lovelace -> TxCert
PV3.TxCertUnRegStaking (Credential Staking -> Credential
forall (kr :: KeyRole). Credential kr -> Credential
transCred Credential Staking
stakeCred) (Lovelace -> Maybe Lovelace
forall a. a -> Maybe a
Just (Lovelace -> Maybe Lovelace) -> Lovelace -> Maybe Lovelace
forall a b. (a -> b) -> a -> b
$ Coin -> Lovelace
transCoinToLovelace Coin
refund)
DelegTxCert Credential Staking
stakeCred Delegatee
delegatee ->
Credential -> Delegatee -> TxCert
PV3.TxCertDelegStaking (Credential Staking -> Credential
forall (kr :: KeyRole). Credential kr -> Credential
transCred Credential Staking
stakeCred) (Delegatee -> Delegatee
Conway.transDelegatee Delegatee
delegatee)
RegDepositDelegTxCert Credential Staking
stakeCred Delegatee
delegatee Coin
deposit ->
Credential -> Delegatee -> Lovelace -> TxCert
PV3.TxCertRegDeleg
(Credential Staking -> Credential
forall (kr :: KeyRole). Credential kr -> Credential
transCred Credential Staking
stakeCred)
(Delegatee -> Delegatee
Conway.transDelegatee Delegatee
delegatee)
(Coin -> Lovelace
transCoinToLovelace Coin
deposit)
AuthCommitteeHotKeyTxCert Credential ColdCommitteeRole
coldCred Credential HotCommitteeRole
hotCred ->
ColdCommitteeCredential -> HotCommitteeCredential -> TxCert
PV3.TxCertAuthHotCommittee
(Credential ColdCommitteeRole -> ColdCommitteeCredential
Conway.transColdCommitteeCred Credential ColdCommitteeRole
coldCred)
(Credential HotCommitteeRole -> HotCommitteeCredential
Conway.transHotCommitteeCred Credential HotCommitteeRole
hotCred)
ResignCommitteeColdTxCert Credential ColdCommitteeRole
coldCred StrictMaybe Anchor
_anchor ->
ColdCommitteeCredential -> TxCert
PV3.TxCertResignColdCommittee (Credential ColdCommitteeRole -> ColdCommitteeCredential
Conway.transColdCommitteeCred Credential ColdCommitteeRole
coldCred)
RegDRepTxCert Credential DRepRole
drepCred Coin
deposit StrictMaybe Anchor
_anchor ->
DRepCredential -> Lovelace -> TxCert
PV3.TxCertRegDRep (Credential DRepRole -> DRepCredential
Conway.transDRepCred Credential DRepRole
drepCred) (Coin -> Lovelace
transCoinToLovelace Coin
deposit)
UnRegDRepTxCert Credential DRepRole
drepCred Coin
refund ->
DRepCredential -> Lovelace -> TxCert
PV3.TxCertUnRegDRep (Credential DRepRole -> DRepCredential
Conway.transDRepCred Credential DRepRole
drepCred) (Coin -> Lovelace
transCoinToLovelace Coin
refund)
UpdateDRepTxCert Credential DRepRole
drepCred StrictMaybe Anchor
_anchor ->
DRepCredential -> TxCert
PV3.TxCertUpdateDRep (Credential DRepRole -> DRepCredential
Conway.transDRepCred Credential DRepRole
drepCred)
TxCert era
_ -> String -> TxCert
forall a. HasCallStack => String -> a
error String
"Impossible: All TxCerts should have been accounted for"
instance ConwayEraPlutusTxInfo 'PlutusV3 DijkstraEra where
toPlutusChangedParameters :: forall (proxy :: Language -> *).
proxy 'PlutusV3 -> PParamsUpdate DijkstraEra -> ChangedParameters
toPlutusChangedParameters proxy 'PlutusV3
_ PParamsUpdate DijkstraEra
x = BuiltinData -> ChangedParameters
PV3.ChangedParameters (Data -> BuiltinData
PV3.dataToBuiltinData (PParamsUpdate DijkstraEra -> Data
forall x. ToPlutusData x => x -> Data
toPlutusData PParamsUpdate DijkstraEra
x))
instance ConwayEraPlutusTxInfo 'PlutusV4 DijkstraEra where
toPlutusChangedParameters :: forall (proxy :: Language -> *).
proxy 'PlutusV4 -> PParamsUpdate DijkstraEra -> ChangedParameters
toPlutusChangedParameters proxy 'PlutusV4
_ PParamsUpdate DijkstraEra
x = BuiltinData -> ChangedParameters
PV3.ChangedParameters (Data -> BuiltinData
PV3.dataToBuiltinData (PParamsUpdate DijkstraEra -> Data
forall x. ToPlutusData x => x -> Data
toPlutusData PParamsUpdate DijkstraEra
x))
instance EraPlutusTxInfo 'PlutusV4 DijkstraEra where
toPlutusTxCert :: forall (proxy :: Language -> *).
proxy 'PlutusV4
-> ProtVer
-> TxCert DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxCert 'PlutusV4)
toPlutusTxCert proxy 'PlutusV4
_ ProtVer
_ = TxCert -> Either (DijkstraContextError DijkstraEra) TxCert
forall a. a -> Either (DijkstraContextError DijkstraEra) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TxCert -> Either (DijkstraContextError DijkstraEra) TxCert)
-> (DijkstraTxCert DijkstraEra -> TxCert)
-> DijkstraTxCert DijkstraEra
-> Either (DijkstraContextError DijkstraEra) TxCert
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxCert DijkstraEra -> TxCert
DijkstraTxCert DijkstraEra -> TxCert
forall era.
(ConwayEraTxCert era, TxCert era ~ DijkstraTxCert era) =>
TxCert era -> TxCert
transTxCert
toPlutusScriptPurpose :: forall (proxy :: Language -> *).
proxy 'PlutusV4
-> ProtVer
-> PlutusPurpose AsIxItem DijkstraEra
-> Either
(ContextError DijkstraEra) (PlutusScriptPurpose 'PlutusV4)
toPlutusScriptPurpose proxy 'PlutusV4
_ = String
-> ProtVer
-> DijkstraPlutusPurpose AsIxItem DijkstraEra
-> Either (DijkstraContextError DijkstraEra) ScriptPurpose
forall a. HasCallStack => String -> a
error String
"stub: PlutusV4 not yet implemented"
toPlutusTxInfo :: forall (proxy :: Language -> *).
proxy 'PlutusV4
-> LedgerTxInfo DijkstraEra
-> PlutusTxInfoResult 'PlutusV4 DijkstraEra
toPlutusTxInfo proxy 'PlutusV4
proxy LedgerTxInfo {ProtVer
ltiProtVer :: forall era. LedgerTxInfo era -> ProtVer
ltiProtVer :: ProtVer
ltiProtVer, EpochInfo (Either Text)
ltiEpochInfo :: forall era. LedgerTxInfo era -> EpochInfo (Either Text)
ltiEpochInfo :: EpochInfo (Either Text)
ltiEpochInfo, SystemStart
ltiSystemStart :: forall era. LedgerTxInfo era -> SystemStart
ltiSystemStart :: SystemStart
ltiSystemStart, UTxO DijkstraEra
ltiUTxO :: forall era. LedgerTxInfo era -> UTxO era
ltiUTxO :: UTxO DijkstraEra
ltiUTxO, Tx level DijkstraEra
ltiTx :: ()
ltiTx :: Tx level DijkstraEra
ltiTx} = do
Tx level DijkstraEra
-> (Tx TopTx DijkstraEra
-> PlutusTxInfoResult 'PlutusV4 DijkstraEra)
-> (Tx SubTx DijkstraEra
-> PlutusTxInfoResult 'PlutusV4 DijkstraEra)
-> PlutusTxInfoResult 'PlutusV4 DijkstraEra
forall (t :: TxLevel -> * -> *) era (l :: TxLevel) a.
(HasEraTxLevel t era, STxLevel l era ~ STxBothLevels l era) =>
t l era -> (t TopTx era -> a) -> (t SubTx era -> a) -> a
withBothTxLevels Tx level DijkstraEra
ltiTx Tx TopTx DijkstraEra -> PlutusTxInfoResult 'PlutusV4 DijkstraEra
forall {l :: Language}.
(PlutusTxInfo l ~ TxInfo) =>
Tx TopTx DijkstraEra -> PlutusTxInfoResult l DijkstraEra
mkTopTxInfo Tx SubTx DijkstraEra -> PlutusTxInfoResult 'PlutusV4 DijkstraEra
forall {l :: Language} {l :: TxLevel}.
(PlutusTxInfo l ~ TxInfo) =>
Tx l DijkstraEra -> PlutusTxInfoResult l DijkstraEra
mkSubTxInfo
where
mkTopTxInfo :: Tx TopTx DijkstraEra -> PlutusTxInfoResult l DijkstraEra
mkTopTxInfo Tx TopTx DijkstraEra
tx = Either
(ContextError DijkstraEra)
(PlutusPurpose AsPurpose DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo l))
-> PlutusTxInfoResult l DijkstraEra
forall (l :: Language) era.
Either
(ContextError era)
(PlutusPurpose AsPurpose era
-> Either (ContextError era) (PlutusTxInfo l))
-> PlutusTxInfoResult l era
PlutusTxInfoResult (Either
(ContextError DijkstraEra)
(PlutusPurpose AsPurpose DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo l))
-> PlutusTxInfoResult l DijkstraEra)
-> Either
(ContextError DijkstraEra)
(PlutusPurpose AsPurpose DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo l))
-> PlutusTxInfoResult l DijkstraEra
forall a b. (a -> b) -> a -> b
$ do
txInfo <- Tx TopTx DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV4)
forall (l :: TxLevel).
Tx l DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV4)
mkAnyLevelTxInfo Tx TopTx DijkstraEra
tx
let topTxInfo = TxInfo
txInfo {PV3.txInfoFee = transCoinToLovelace (tx ^. bodyTxL . feeTxBodyL)}
Right $ \case
GuardingPurpose AsPurpose Word32 ScriptHash
AsPurpose ->
TxInfo -> Either (ContextError DijkstraEra) TxInfo
forall a b. b -> Either a b
Right TxInfo
topTxInfo
PlutusPurpose AsPurpose DijkstraEra
_ -> TxInfo -> Either (ContextError DijkstraEra) TxInfo
forall a b. b -> Either a b
Right TxInfo
topTxInfo
mkSubTxInfo :: Tx l DijkstraEra -> PlutusTxInfoResult l DijkstraEra
mkSubTxInfo Tx l DijkstraEra
tx = Either
(ContextError DijkstraEra)
(PlutusPurpose AsPurpose DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo l))
-> PlutusTxInfoResult l DijkstraEra
forall (l :: Language) era.
Either
(ContextError era)
(PlutusPurpose AsPurpose era
-> Either (ContextError era) (PlutusTxInfo l))
-> PlutusTxInfoResult l era
PlutusTxInfoResult (Either
(ContextError DijkstraEra)
(PlutusPurpose AsPurpose DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo l))
-> PlutusTxInfoResult l DijkstraEra)
-> Either
(ContextError DijkstraEra)
(PlutusPurpose AsPurpose DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo l))
-> PlutusTxInfoResult l DijkstraEra
forall a b. (a -> b) -> a -> b
$ do
txInfo <- Tx l DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV4)
forall (l :: TxLevel).
Tx l DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV4)
mkAnyLevelTxInfo Tx l DijkstraEra
tx
Right $ \PlutusPurpose AsPurpose DijkstraEra
_ -> PlutusTxInfo l
-> Either (ContextError DijkstraEra) (PlutusTxInfo l)
forall a b. b -> Either a b
Right PlutusTxInfo l
txInfo
mkAnyLevelTxInfo ::
Tx l DijkstraEra ->
Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV4)
mkAnyLevelTxInfo :: forall (l :: TxLevel).
Tx l DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV4)
mkAnyLevelTxInfo Tx l DijkstraEra
tx = do
let
txBody :: TxBody l DijkstraEra
txBody = Tx l DijkstraEra
tx Tx l DijkstraEra
-> Getting
(TxBody l DijkstraEra) (Tx l DijkstraEra) (TxBody l DijkstraEra)
-> TxBody l DijkstraEra
forall s a. s -> Getting a s a -> a
^. Getting
(TxBody l DijkstraEra) (Tx l DijkstraEra) (TxBody l DijkstraEra)
forall era (l :: TxLevel).
EraTx era =>
Lens' (Tx l era) (TxBody l era)
forall (l :: TxLevel).
Lens' (Tx l DijkstraEra) (TxBody l DijkstraEra)
bodyTxL
txInputs :: Set TxIn
txInputs = TxBody l DijkstraEra
txBody TxBody l DijkstraEra
-> Getting (Set TxIn) (TxBody l DijkstraEra) (Set TxIn) -> Set TxIn
forall s a. s -> Getting a s a -> a
^. Getting (Set TxIn) (TxBody l DijkstraEra) (Set TxIn)
forall era (l :: TxLevel).
EraTxBody era =>
Lens' (TxBody l era) (Set TxIn)
forall (l :: TxLevel). Lens' (TxBody l DijkstraEra) (Set TxIn)
inputsTxBodyL
refInputs :: Set TxIn
refInputs = TxBody l DijkstraEra
txBody TxBody l DijkstraEra
-> Getting (Set TxIn) (TxBody l DijkstraEra) (Set TxIn) -> Set TxIn
forall s a. s -> Getting a s a -> a
^. Getting (Set TxIn) (TxBody l DijkstraEra) (Set TxIn)
forall era (l :: TxLevel).
BabbageEraTxBody era =>
Lens' (TxBody l era) (Set TxIn)
forall (l :: TxLevel). Lens' (TxBody l DijkstraEra) (Set TxIn)
referenceInputsTxBodyL
timeRange <-
Tx l DijkstraEra
-> EpochInfo (Either Text)
-> SystemStart
-> ValidityInterval
-> Either (DijkstraContextError DijkstraEra) POSIXTimeRange
forall (proxy :: * -> *) era a.
Inject (AlonzoContextError era) a =>
proxy era
-> EpochInfo (Either Text)
-> SystemStart
-> ValidityInterval
-> Either a POSIXTimeRange
Conway.transValidityInterval Tx l DijkstraEra
tx EpochInfo (Either Text)
ltiEpochInfo SystemStart
ltiSystemStart (TxBody l DijkstraEra
txBody TxBody l DijkstraEra
-> Getting ValidityInterval (TxBody l DijkstraEra) ValidityInterval
-> ValidityInterval
forall s a. s -> Getting a s a -> a
^. Getting ValidityInterval (TxBody l DijkstraEra) ValidityInterval
forall era (l :: TxLevel).
AllegraEraTxBody era =>
Lens' (TxBody l era) ValidityInterval
forall (l :: TxLevel).
Lens' (TxBody l DijkstraEra) ValidityInterval
vldtTxBodyL)
inputsInfo <- mapM (Conway.transTxInInfoV3 ltiUTxO) (Set.toList txInputs)
refInputsInfo <- mapM (Conway.transTxInInfoV3 ltiUTxO) (Set.toList refInputs)
Conway.checkReferenceInputsNotDisjointFromInputs txBody
checkPointerPresentInOutput $ txBody ^. outputsTxBodyL
outputs <-
zipWithM
(Babbage.transTxOutV2 . TxOutFromOutput)
[minBound ..]
(F.toList (txBody ^. outputsTxBodyL))
txCerts <- Alonzo.transTxBodyCerts proxy ltiProtVer txBody
plutusRedeemers <- Babbage.transTxRedeemers proxy ltiProtVer tx
Right $
PV3.TxInfo
{ PV3.txInfoInputs = inputsInfo
, PV3.txInfoOutputs = outputs
, PV3.txInfoReferenceInputs = refInputsInfo
, PV3.txInfoFee = 0
, PV3.txInfoMint = Conway.transMintValue (txBody ^. mintTxBodyL)
, PV3.txInfoTxCerts = txCerts
, PV3.txInfoWdrl = Conway.transTxBodyWithdrawals txBody
, PV3.txInfoValidRange = timeRange
, PV3.txInfoSignatories = Alonzo.transTxBodyReqSignerHashes txBody
, PV3.txInfoRedeemers = plutusRedeemers
, PV3.txInfoData = PV3.unsafeFromList $ Alonzo.transTxWitsDatums (tx ^. witsTxL)
, PV3.txInfoId = Conway.transTxBodyId txBody
, PV3.txInfoVotes = Conway.transVotingProcedures (txBody ^. votingProceduresTxBodyL)
, PV3.txInfoProposalProcedures =
map (Conway.transProposal proxy) $ toList (txBody ^. proposalProceduresTxBodyL)
, PV3.txInfoCurrentTreasuryAmount =
strictMaybe Nothing (Just . transCoinToLovelace) $ txBody ^. currentTreasuryValueTxBodyL
, PV3.txInfoTreasuryDonation =
case txBody ^. treasuryDonationTxBodyL of
Coin Integer
0 -> Maybe Lovelace
forall a. Maybe a
Nothing
Coin
coin -> Lovelace -> Maybe Lovelace
forall a. a -> Maybe a
Just (Lovelace -> Maybe Lovelace) -> Lovelace -> Maybe Lovelace
forall a b. (a -> b) -> a -> b
$ Coin -> Lovelace
transCoinToLovelace Coin
coin
}
toPlutusArgs :: forall (proxy :: Language -> *).
proxy 'PlutusV4
-> ProtVer
-> PlutusTxInfo 'PlutusV4
-> PlutusPurpose AsIxItem DijkstraEra
-> Maybe (Data DijkstraEra)
-> Data DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusArgs 'PlutusV4)
toPlutusArgs = proxy 'PlutusV4
-> ProtVer
-> PlutusTxInfo 'PlutusV4
-> PlutusPurpose AsIxItem DijkstraEra
-> Maybe (Data DijkstraEra)
-> Data DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusArgs 'PlutusV4)
proxy 'PlutusV4
-> ProtVer
-> TxInfo
-> PlutusPurpose AsIxItem DijkstraEra
-> Maybe (Data DijkstraEra)
-> Data DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusArgs 'PlutusV4)
forall era (proxy :: Language -> *).
EraPlutusTxInfo 'PlutusV4 era =>
proxy 'PlutusV4
-> ProtVer
-> TxInfo
-> PlutusPurpose AsIxItem era
-> Maybe (Data era)
-> Data era
-> Either (ContextError era) (PlutusArgs 'PlutusV4)
toPlutusV4Args
toPlutusTxInInfo :: forall (proxy :: Language -> *).
proxy 'PlutusV4
-> UTxO DijkstraEra
-> TxIn
-> Either
(ContextError DijkstraEra) (PlutusTxInInfo DijkstraEra 'PlutusV4)
toPlutusTxInInfo proxy 'PlutusV4
_ = UTxO DijkstraEra
-> TxIn
-> Either
(ContextError DijkstraEra) (PlutusTxInInfo DijkstraEra 'PlutusV4)
UTxO DijkstraEra
-> TxIn -> Either (ContextError DijkstraEra) TxInInfo
forall era.
(Inject (BabbageContextError era) (ContextError era),
Value era ~ MaryValue, BabbageEraTxOut era) =>
UTxO era -> TxIn -> Either (ContextError era) TxInInfo
transTxInInfoV3
toPlutusV4Args ::
EraPlutusTxInfo 'PlutusV4 era =>
proxy 'PlutusV4 ->
ProtVer ->
PV3.TxInfo ->
PlutusPurpose AsIxItem era ->
Maybe (Data era) ->
Data era ->
Either (ContextError era) (PlutusArgs 'PlutusV4)
toPlutusV4Args :: forall era (proxy :: Language -> *).
EraPlutusTxInfo 'PlutusV4 era =>
proxy 'PlutusV4
-> ProtVer
-> TxInfo
-> PlutusPurpose AsIxItem era
-> Maybe (Data era)
-> Data era
-> Either (ContextError era) (PlutusArgs 'PlutusV4)
toPlutusV4Args proxy 'PlutusV4
proxy ProtVer
pv TxInfo
txInfo PlutusPurpose AsIxItem era
plutusPurpose Maybe (Data era)
maybeSpendingData Data era
redeemerData = do
scriptPurpose <- proxy 'PlutusV4
-> ProtVer
-> PlutusPurpose AsIxItem era
-> Either (ContextError era) (PlutusScriptPurpose 'PlutusV4)
forall (l :: Language) era (proxy :: Language -> *).
EraPlutusTxInfo l era =>
proxy l
-> ProtVer
-> PlutusPurpose AsIxItem era
-> Either (ContextError era) (PlutusScriptPurpose l)
forall (proxy :: Language -> *).
proxy 'PlutusV4
-> ProtVer
-> PlutusPurpose AsIxItem era
-> Either (ContextError era) (PlutusScriptPurpose 'PlutusV4)
toPlutusScriptPurpose proxy 'PlutusV4
proxy ProtVer
pv PlutusPurpose AsIxItem era
plutusPurpose
let scriptInfo =
ScriptPurpose -> Maybe Datum -> ScriptInfo
Conway.scriptPurposeToScriptInfo ScriptPurpose
scriptPurpose (Data era -> Datum
forall era. Data era -> Datum
transDatum (Data era -> Datum) -> Maybe (Data era) -> Maybe Datum
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (Data era)
maybeSpendingData)
pure $
PlutusV4Args $
PV3.ScriptContext
{ PV3.scriptContextTxInfo = txInfo
, PV3.scriptContextRedeemer = Babbage.transRedeemer redeemerData
, PV3.scriptContextScriptInfo = scriptInfo
}
checkPointerPresentInOutput ::
Foldable f =>
f (TxOut DijkstraEra) ->
Either (ContextError DijkstraEra) ()
checkPointerPresentInOutput :: forall (f :: * -> *).
Foldable f =>
f (TxOut DijkstraEra) -> Either (ContextError DijkstraEra) ()
checkPointerPresentInOutput f (TxOut DijkstraEra)
outputs =
case [TxOut DijkstraEra] -> Maybe (NonEmpty (TxOut DijkstraEra))
forall a. [a] -> Maybe (NonEmpty a)
NE.nonEmpty ((TxOut DijkstraEra -> Bool)
-> [TxOut DijkstraEra] -> [TxOut DijkstraEra]
forall a. (a -> Bool) -> [a] -> [a]
filter TxOut DijkstraEra -> Bool
forall {era}.
(Assert
(OrdCond
(CmpNat (ProtVerLow era) (ProtVerHigh era)) 'True 'True 'False)
(TypeError ...),
Assert
(OrdCond (CmpNat 0 (ProtVerLow era)) 'True 'True 'False)
(TypeError ...),
Assert
(OrdCond (CmpNat 0 (ProtVerHigh era)) 'True 'True 'False)
(TypeError ...),
EraTxOut era) =>
TxOut era -> Bool
outputHasPtr ([TxOut DijkstraEra] -> [TxOut DijkstraEra])
-> [TxOut DijkstraEra] -> [TxOut DijkstraEra]
forall a b. (a -> b) -> a -> b
$ f (TxOut DijkstraEra) -> [TxOut DijkstraEra]
forall a. f a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList f (TxOut DijkstraEra)
outputs) of
Maybe (NonEmpty (TxOut DijkstraEra))
Nothing -> () -> Either (DijkstraContextError DijkstraEra) ()
forall a. a -> Either (DijkstraContextError DijkstraEra) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
Just NonEmpty (TxOut DijkstraEra)
ptrOutputs -> ContextError DijkstraEra -> Either (ContextError DijkstraEra) ()
forall a b. a -> Either a b
Left (ContextError DijkstraEra -> Either (ContextError DijkstraEra) ())
-> ContextError DijkstraEra -> Either (ContextError DijkstraEra) ()
forall a b. (a -> b) -> a -> b
$ NonEmpty (TxOut DijkstraEra) -> DijkstraContextError DijkstraEra
forall era. NonEmpty (TxOut era) -> DijkstraContextError era
PointerPresentInOutput NonEmpty (TxOut DijkstraEra)
ptrOutputs
where
outputHasPtr :: TxOut era -> Bool
outputHasPtr TxOut era
txOut = case TxOut era
txOut TxOut era -> Getting Addr (TxOut era) Addr -> Addr
forall s a. s -> Getting a s a -> a
^. Getting Addr (TxOut era) Addr
forall era. EraTxOut era => Lens' (TxOut era) Addr
Lens' (TxOut era) Addr
addrTxOutL of
Addr Network
_ Credential Payment
_ (StakeRefPtr Ptr
_) -> Bool
True
Addr
_ -> Bool
False