{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Cardano.Ledger.Dijkstra.TxInfo (
transPlutusPurposeV1V2,
transPlutusPurposeV3,
) where
import Cardano.Crypto.Hash.Class (hashToBytes)
import Cardano.Ledger.Alonzo.Plutus.Context (
EraPlutusContext (..),
EraPlutusTxInfo (..),
LedgerTxInfo (..),
PlutusTxCert,
PlutusTxInfo,
SupportedLanguage (..),
toPlutusWithContext,
)
import qualified Cardano.Ledger.Alonzo.Plutus.TxInfo as Alonzo
import Cardano.Ledger.Alonzo.Scripts (toAsItem)
import qualified Cardano.Ledger.Babbage.TxInfo as Babbage
import Cardano.Ledger.BaseTypes (Inject (..), ProtVer (..), strictMaybe)
import Cardano.Ledger.Coin (Coin (..))
import Cardano.Ledger.Conway.Scripts (ConwayPlutusPurpose (..))
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.Dijkstra.Core
import Cardano.Ledger.Dijkstra.Era (DijkstraEra)
import Cardano.Ledger.Dijkstra.Scripts (DijkstraPlutusPurpose (..), PlutusScript (..))
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 (PoolParams (..))
import Control.Monad (zipWithM)
import Data.Foldable (Foldable (..))
import qualified Data.Foldable as F
import Data.List.NonEmpty (NonEmpty (..))
import Data.Proxy (Proxy (..))
import qualified Data.Set as Set
import Lens.Micro ((^.))
import qualified PlutusLedgerApi.V1 as PV1
import qualified PlutusLedgerApi.V2 as PV2
import qualified PlutusLedgerApi.V3 as PV3
instance EraPlutusContext DijkstraEra where
type ContextError DijkstraEra = ConwayContextError DijkstraEra
data TxInfoResult DijkstraEra
= DijkstraTxInfoResult
(Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV1))
(Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV2))
(Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV3))
(Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV4))
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 =
Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV1)
-> Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV2)
-> Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV3)
-> Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV4)
-> TxInfoResult DijkstraEra
DijkstraTxInfoResult
(SLanguage 'PlutusV1
-> LedgerTxInfo DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV1)
forall (l :: Language) era (proxy :: Language -> *).
EraPlutusTxInfo l era =>
proxy l
-> LedgerTxInfo era -> Either (ContextError era) (PlutusTxInfo l)
forall (proxy :: Language -> *).
proxy 'PlutusV1
-> LedgerTxInfo DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV1)
toPlutusTxInfo SLanguage 'PlutusV1
SPlutusV1 LedgerTxInfo DijkstraEra
lti)
(SLanguage 'PlutusV2
-> LedgerTxInfo DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV2)
forall (l :: Language) era (proxy :: Language -> *).
EraPlutusTxInfo l era =>
proxy l
-> LedgerTxInfo era -> Either (ContextError era) (PlutusTxInfo l)
forall (proxy :: Language -> *).
proxy 'PlutusV2
-> LedgerTxInfo DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV2)
toPlutusTxInfo SLanguage 'PlutusV2
SPlutusV2 LedgerTxInfo DijkstraEra
lti)
(SLanguage 'PlutusV3
-> LedgerTxInfo DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV3)
forall (l :: Language) era (proxy :: Language -> *).
EraPlutusTxInfo l era =>
proxy l
-> LedgerTxInfo era -> Either (ContextError era) (PlutusTxInfo l)
forall (proxy :: Language -> *).
proxy 'PlutusV3
-> LedgerTxInfo DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV3)
toPlutusTxInfo SLanguage 'PlutusV3
SPlutusV3 LedgerTxInfo DijkstraEra
lti)
(SLanguage 'PlutusV4
-> LedgerTxInfo DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV4)
forall (l :: Language) era (proxy :: Language -> *).
EraPlutusTxInfo l era =>
proxy l
-> LedgerTxInfo era -> Either (ContextError era) (PlutusTxInfo l)
forall (proxy :: Language -> *).
proxy 'PlutusV4
-> LedgerTxInfo DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV4)
toPlutusTxInfo SLanguage 'PlutusV4
SPlutusV4 LedgerTxInfo DijkstraEra
lti)
lookupTxInfoResult :: forall (l :: Language).
EraPlutusTxInfo l DijkstraEra =>
SLanguage l
-> TxInfoResult DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo l)
lookupTxInfoResult SLanguage l
SPlutusV1 (DijkstraTxInfoResult Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV1)
tirPlutusV1 Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV2)
_ Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV3)
_ Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV4)
_) = Either (ContextError DijkstraEra) (PlutusTxInfo l)
Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV1)
tirPlutusV1
lookupTxInfoResult SLanguage l
SPlutusV2 (DijkstraTxInfoResult Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV1)
_ Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV2)
tirPlutusV2 Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV3)
_ Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV4)
_) = Either (ContextError DijkstraEra) (PlutusTxInfo l)
Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV2)
tirPlutusV2
lookupTxInfoResult SLanguage l
SPlutusV3 (DijkstraTxInfoResult Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV1)
_ Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV2)
_ Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV3)
tirPlutusV3 Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV4)
_) = Either (ContextError DijkstraEra) (PlutusTxInfo l)
Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV3)
tirPlutusV3
lookupTxInfoResult SLanguage l
SPlutusV4 (DijkstraTxInfoResult Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV1)
_ Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV2)
_ Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV3)
_ Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV4)
tirPlutusV4) = Either (ContextError DijkstraEra) (PlutusTxInfo l)
Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV4)
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
transPlutusPurposeV1V2 ::
forall l era proxy.
( EraPlutusTxInfo l era
, PlutusTxCert l ~ PV2.DCert
, Inject (ConwayPlutusPurpose AsItem era) (PlutusPurpose AsItem era)
, Inject (DijkstraPlutusPurpose AsItem era) (PlutusPurpose AsItem era)
, Inject (ConwayContextError era) (ContextError era)
) =>
proxy l ->
ProtVer ->
DijkstraPlutusPurpose AsItem era ->
Either (ContextError era) PV2.ScriptPurpose
transPlutusPurposeV1V2 :: forall (l :: Language) era (proxy :: Language -> *).
(EraPlutusTxInfo l era, PlutusTxCert l ~ DCert,
Inject (ConwayPlutusPurpose AsItem era) (PlutusPurpose AsItem era),
Inject
(DijkstraPlutusPurpose AsItem era) (PlutusPurpose AsItem era),
Inject (ConwayContextError era) (ContextError era)) =>
proxy l
-> ProtVer
-> DijkstraPlutusPurpose AsItem era
-> Either (ContextError era) ScriptPurpose
transPlutusPurposeV1V2 proxy l
proxy ProtVer
pv = \case
DijkstraSpending AsItem Word32 TxIn
txIn -> proxy l
-> ProtVer
-> ConwayPlutusPurpose AsItem era
-> Either (ContextError era) ScriptPurpose
forall (l :: Language) era (proxy :: Language -> *).
(PlutusTxCert l ~ DCert, EraPlutusTxInfo l era,
Inject (ConwayContextError era) (ContextError era),
Inject
(ConwayPlutusPurpose AsItem era) (PlutusPurpose AsItem era)) =>
proxy l
-> ProtVer
-> ConwayPlutusPurpose AsItem era
-> Either (ContextError era) ScriptPurpose
Conway.transPlutusPurposeV1V2 proxy l
proxy ProtVer
pv (ConwayPlutusPurpose AsItem era
-> Either (ContextError era) ScriptPurpose)
-> ConwayPlutusPurpose AsItem era
-> Either (ContextError era) ScriptPurpose
forall a b. (a -> b) -> a -> b
$ AsItem Word32 TxIn -> ConwayPlutusPurpose AsItem era
forall (f :: * -> * -> *) era.
f Word32 TxIn -> ConwayPlutusPurpose f era
ConwaySpending AsItem Word32 TxIn
txIn
DijkstraMinting AsItem Word32 PolicyID
policyId -> proxy l
-> ProtVer
-> ConwayPlutusPurpose AsItem era
-> Either (ContextError era) ScriptPurpose
forall (l :: Language) era (proxy :: Language -> *).
(PlutusTxCert l ~ DCert, EraPlutusTxInfo l era,
Inject (ConwayContextError era) (ContextError era),
Inject
(ConwayPlutusPurpose AsItem era) (PlutusPurpose AsItem era)) =>
proxy l
-> ProtVer
-> ConwayPlutusPurpose AsItem era
-> Either (ContextError era) ScriptPurpose
Conway.transPlutusPurposeV1V2 proxy l
proxy ProtVer
pv (ConwayPlutusPurpose AsItem era
-> Either (ContextError era) ScriptPurpose)
-> ConwayPlutusPurpose AsItem era
-> Either (ContextError era) ScriptPurpose
forall a b. (a -> b) -> a -> b
$ AsItem Word32 PolicyID -> ConwayPlutusPurpose AsItem era
forall (f :: * -> * -> *) era.
f Word32 PolicyID -> ConwayPlutusPurpose f era
ConwayMinting AsItem Word32 PolicyID
policyId
DijkstraCertifying AsItem Word32 (TxCert era)
txCert -> proxy l
-> ProtVer
-> ConwayPlutusPurpose AsItem era
-> Either (ContextError era) ScriptPurpose
forall (l :: Language) era (proxy :: Language -> *).
(PlutusTxCert l ~ DCert, EraPlutusTxInfo l era,
Inject (ConwayContextError era) (ContextError era),
Inject
(ConwayPlutusPurpose AsItem era) (PlutusPurpose AsItem era)) =>
proxy l
-> ProtVer
-> ConwayPlutusPurpose AsItem era
-> Either (ContextError era) ScriptPurpose
Conway.transPlutusPurposeV1V2 proxy l
proxy ProtVer
pv (ConwayPlutusPurpose AsItem era
-> Either (ContextError era) ScriptPurpose)
-> ConwayPlutusPurpose AsItem era
-> Either (ContextError era) ScriptPurpose
forall a b. (a -> b) -> a -> b
$ AsItem Word32 (TxCert era) -> ConwayPlutusPurpose AsItem era
forall (f :: * -> * -> *) era.
f Word32 (TxCert era) -> ConwayPlutusPurpose f era
ConwayCertifying AsItem Word32 (TxCert era)
txCert
DijkstraRewarding AsItem Word32 RewardAccount
rewardAccount -> proxy l
-> ProtVer
-> ConwayPlutusPurpose AsItem era
-> Either (ContextError era) ScriptPurpose
forall (l :: Language) era (proxy :: Language -> *).
(PlutusTxCert l ~ DCert, EraPlutusTxInfo l era,
Inject (ConwayContextError era) (ContextError era),
Inject
(ConwayPlutusPurpose AsItem era) (PlutusPurpose AsItem era)) =>
proxy l
-> ProtVer
-> ConwayPlutusPurpose AsItem era
-> Either (ContextError era) ScriptPurpose
Conway.transPlutusPurposeV1V2 proxy l
proxy ProtVer
pv (ConwayPlutusPurpose AsItem era
-> Either (ContextError era) ScriptPurpose)
-> ConwayPlutusPurpose AsItem era
-> Either (ContextError era) ScriptPurpose
forall a b. (a -> b) -> a -> b
$ AsItem Word32 RewardAccount -> ConwayPlutusPurpose AsItem era
forall (f :: * -> * -> *) era.
f Word32 RewardAccount -> ConwayPlutusPurpose f era
ConwayRewarding AsItem Word32 RewardAccount
rewardAccount
DijkstraVoting AsItem Word32 Voter
voting -> proxy l
-> ProtVer
-> ConwayPlutusPurpose AsItem era
-> Either (ContextError era) ScriptPurpose
forall (l :: Language) era (proxy :: Language -> *).
(PlutusTxCert l ~ DCert, EraPlutusTxInfo l era,
Inject (ConwayContextError era) (ContextError era),
Inject
(ConwayPlutusPurpose AsItem era) (PlutusPurpose AsItem era)) =>
proxy l
-> ProtVer
-> ConwayPlutusPurpose AsItem era
-> Either (ContextError era) ScriptPurpose
Conway.transPlutusPurposeV1V2 proxy l
proxy ProtVer
pv (ConwayPlutusPurpose AsItem era
-> Either (ContextError era) ScriptPurpose)
-> ConwayPlutusPurpose AsItem era
-> Either (ContextError era) ScriptPurpose
forall a b. (a -> b) -> a -> b
$ AsItem Word32 Voter -> ConwayPlutusPurpose AsItem era
forall (f :: * -> * -> *) era.
f Word32 Voter -> ConwayPlutusPurpose f era
ConwayVoting AsItem Word32 Voter
voting
DijkstraProposing AsItem Word32 (ProposalProcedure era)
proposing -> proxy l
-> ProtVer
-> ConwayPlutusPurpose AsItem era
-> Either (ContextError era) ScriptPurpose
forall (l :: Language) era (proxy :: Language -> *).
(PlutusTxCert l ~ DCert, EraPlutusTxInfo l era,
Inject (ConwayContextError era) (ContextError era),
Inject
(ConwayPlutusPurpose AsItem era) (PlutusPurpose AsItem era)) =>
proxy l
-> ProtVer
-> ConwayPlutusPurpose AsItem era
-> Either (ContextError era) ScriptPurpose
Conway.transPlutusPurposeV1V2 proxy l
proxy ProtVer
pv (ConwayPlutusPurpose AsItem era
-> Either (ContextError era) ScriptPurpose)
-> ConwayPlutusPurpose AsItem era
-> Either (ContextError era) ScriptPurpose
forall a b. (a -> b) -> a -> b
$ AsItem Word32 (ProposalProcedure era)
-> ConwayPlutusPurpose AsItem era
forall (f :: * -> * -> *) era.
f Word32 (ProposalProcedure era) -> ConwayPlutusPurpose f era
ConwayProposing AsItem Word32 (ProposalProcedure era)
proposing
DijkstraPlutusPurpose AsItem era
purpose -> ContextError era -> Either (ContextError era) ScriptPurpose
forall a b. a -> Either a b
Left (ContextError era -> Either (ContextError era) ScriptPurpose)
-> ContextError era -> Either (ContextError era) ScriptPurpose
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
$ forall era. PlutusPurpose AsItem era -> ConwayContextError era
PlutusPurposeNotSupported @era (PlutusPurpose AsItem era -> ConwayContextError era)
-> PlutusPurpose AsItem era -> ConwayContextError era
forall a b. (a -> b) -> a -> b
$ DijkstraPlutusPurpose AsItem era -> PlutusPurpose AsItem era
forall t s. Inject t s => t -> s
inject DijkstraPlutusPurpose AsItem era
purpose
transPlutusPurposeV3 ::
forall era.
( ConwayEraPlutusTxInfo PlutusV3 era
, Inject (ConwayContextError era) (ContextError era)
, Inject (DijkstraPlutusPurpose AsIxItem era) (PlutusPurpose AsIxItem era)
) =>
ProtVer ->
DijkstraPlutusPurpose AsIxItem era ->
Either (ContextError era) PV3.ScriptPurpose
transPlutusPurposeV3 :: forall era.
(ConwayEraPlutusTxInfo 'PlutusV3 era,
Inject (ConwayContextError era) (ContextError era),
Inject
(DijkstraPlutusPurpose AsIxItem era)
(PlutusPurpose AsIxItem era)) =>
ProtVer
-> DijkstraPlutusPurpose AsIxItem era
-> Either (ContextError era) ScriptPurpose
transPlutusPurposeV3 ProtVer
pv = \case
DijkstraSpending AsIxItem Word32 TxIn
txIn -> forall (l :: Language) era (proxy :: Language -> *).
(ConwayEraPlutusTxInfo l era, PlutusTxCert l ~ TxCert) =>
proxy l
-> ProtVer
-> ConwayPlutusPurpose AsIxItem era
-> Either (ContextError era) ScriptPurpose
Conway.transPlutusPurposeV3 @PlutusV3 @era Proxy 'PlutusV3
forall {k} (t :: k). Proxy t
Proxy ProtVer
pv (ConwayPlutusPurpose AsIxItem era
-> Either (ContextError era) ScriptPurpose)
-> ConwayPlutusPurpose AsIxItem era
-> Either (ContextError era) ScriptPurpose
forall a b. (a -> b) -> a -> b
$ AsIxItem Word32 TxIn -> ConwayPlutusPurpose AsIxItem era
forall (f :: * -> * -> *) era.
f Word32 TxIn -> ConwayPlutusPurpose f era
ConwaySpending AsIxItem Word32 TxIn
txIn
DijkstraMinting AsIxItem Word32 PolicyID
txIn -> forall (l :: Language) era (proxy :: Language -> *).
(ConwayEraPlutusTxInfo l era, PlutusTxCert l ~ TxCert) =>
proxy l
-> ProtVer
-> ConwayPlutusPurpose AsIxItem era
-> Either (ContextError era) ScriptPurpose
Conway.transPlutusPurposeV3 @PlutusV3 @era Proxy 'PlutusV3
forall {k} (t :: k). Proxy t
Proxy ProtVer
pv (ConwayPlutusPurpose AsIxItem era
-> Either (ContextError era) ScriptPurpose)
-> ConwayPlutusPurpose AsIxItem era
-> Either (ContextError era) ScriptPurpose
forall a b. (a -> b) -> a -> b
$ AsIxItem Word32 PolicyID -> ConwayPlutusPurpose AsIxItem era
forall (f :: * -> * -> *) era.
f Word32 PolicyID -> ConwayPlutusPurpose f era
ConwayMinting AsIxItem Word32 PolicyID
txIn
DijkstraCertifying AsIxItem Word32 (TxCert era)
txIn -> forall (l :: Language) era (proxy :: Language -> *).
(ConwayEraPlutusTxInfo l era, PlutusTxCert l ~ TxCert) =>
proxy l
-> ProtVer
-> ConwayPlutusPurpose AsIxItem era
-> Either (ContextError era) ScriptPurpose
Conway.transPlutusPurposeV3 @PlutusV3 @era Proxy 'PlutusV3
forall {k} (t :: k). Proxy t
Proxy ProtVer
pv (ConwayPlutusPurpose AsIxItem era
-> Either (ContextError era) ScriptPurpose)
-> ConwayPlutusPurpose AsIxItem era
-> Either (ContextError era) ScriptPurpose
forall a b. (a -> b) -> a -> b
$ AsIxItem Word32 (TxCert era) -> ConwayPlutusPurpose AsIxItem era
forall (f :: * -> * -> *) era.
f Word32 (TxCert era) -> ConwayPlutusPurpose f era
ConwayCertifying AsIxItem Word32 (TxCert era)
txIn
DijkstraRewarding AsIxItem Word32 RewardAccount
txIn -> forall (l :: Language) era (proxy :: Language -> *).
(ConwayEraPlutusTxInfo l era, PlutusTxCert l ~ TxCert) =>
proxy l
-> ProtVer
-> ConwayPlutusPurpose AsIxItem era
-> Either (ContextError era) ScriptPurpose
Conway.transPlutusPurposeV3 @PlutusV3 @era Proxy 'PlutusV3
forall {k} (t :: k). Proxy t
Proxy ProtVer
pv (ConwayPlutusPurpose AsIxItem era
-> Either (ContextError era) ScriptPurpose)
-> ConwayPlutusPurpose AsIxItem era
-> Either (ContextError era) ScriptPurpose
forall a b. (a -> b) -> a -> b
$ AsIxItem Word32 RewardAccount -> ConwayPlutusPurpose AsIxItem era
forall (f :: * -> * -> *) era.
f Word32 RewardAccount -> ConwayPlutusPurpose f era
ConwayRewarding AsIxItem Word32 RewardAccount
txIn
DijkstraVoting AsIxItem Word32 Voter
txIn -> forall (l :: Language) era (proxy :: Language -> *).
(ConwayEraPlutusTxInfo l era, PlutusTxCert l ~ TxCert) =>
proxy l
-> ProtVer
-> ConwayPlutusPurpose AsIxItem era
-> Either (ContextError era) ScriptPurpose
Conway.transPlutusPurposeV3 @PlutusV3 @era Proxy 'PlutusV3
forall {k} (t :: k). Proxy t
Proxy ProtVer
pv (ConwayPlutusPurpose AsIxItem era
-> Either (ContextError era) ScriptPurpose)
-> ConwayPlutusPurpose AsIxItem era
-> Either (ContextError era) ScriptPurpose
forall a b. (a -> b) -> a -> b
$ AsIxItem Word32 Voter -> ConwayPlutusPurpose AsIxItem era
forall (f :: * -> * -> *) era.
f Word32 Voter -> ConwayPlutusPurpose f era
ConwayVoting AsIxItem Word32 Voter
txIn
DijkstraProposing AsIxItem Word32 (ProposalProcedure era)
txIn -> forall (l :: Language) era (proxy :: Language -> *).
(ConwayEraPlutusTxInfo l era, PlutusTxCert l ~ TxCert) =>
proxy l
-> ProtVer
-> ConwayPlutusPurpose AsIxItem era
-> Either (ContextError era) ScriptPurpose
Conway.transPlutusPurposeV3 @PlutusV3 @era Proxy 'PlutusV3
forall {k} (t :: k). Proxy t
Proxy ProtVer
pv (ConwayPlutusPurpose AsIxItem era
-> Either (ContextError era) ScriptPurpose)
-> ConwayPlutusPurpose AsIxItem era
-> Either (ContextError era) ScriptPurpose
forall a b. (a -> b) -> a -> b
$ AsIxItem Word32 (ProposalProcedure era)
-> ConwayPlutusPurpose AsIxItem era
forall (f :: * -> * -> *) era.
f Word32 (ProposalProcedure era) -> ConwayPlutusPurpose f era
ConwayProposing AsIxItem Word32 (ProposalProcedure era)
txIn
DijkstraPlutusPurpose AsIxItem era
purpose ->
ContextError era -> Either (ContextError era) ScriptPurpose
forall a b. a -> Either a b
Left (ContextError era -> Either (ContextError era) ScriptPurpose)
-> ContextError era -> Either (ContextError era) ScriptPurpose
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
$ forall era. PlutusPurpose AsItem era -> ConwayContextError era
PlutusPurposeNotSupported @era (PlutusPurpose AsItem era -> ConwayContextError era)
-> (PlutusPurpose AsIxItem era -> PlutusPurpose AsItem era)
-> PlutusPurpose AsIxItem era
-> ConwayContextError era
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall era (g :: * -> * -> *) (f :: * -> * -> *).
AlonzoEraScript era =>
(forall ix it. g ix it -> f ix it)
-> PlutusPurpose g era -> PlutusPurpose f era
hoistPlutusPurpose @era AsIxItem ix it -> AsItem ix it
forall ix it. AsIxItem ix it -> AsItem ix it
toAsItem (PlutusPurpose AsIxItem era -> ConwayContextError era)
-> PlutusPurpose AsIxItem era -> ConwayContextError era
forall a b. (a -> b) -> a -> b
$ DijkstraPlutusPurpose AsIxItem era -> PlutusPurpose AsIxItem era
forall t s. Inject t s => t -> s
inject DijkstraPlutusPurpose AsIxItem era
purpose
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
proxy ProtVer
pv =
proxy 'PlutusV1
-> ProtVer
-> DijkstraPlutusPurpose AsItem DijkstraEra
-> Either (ContextError DijkstraEra) ScriptPurpose
forall (l :: Language) era (proxy :: Language -> *).
(EraPlutusTxInfo l era, PlutusTxCert l ~ DCert,
Inject (ConwayPlutusPurpose AsItem era) (PlutusPurpose AsItem era),
Inject
(DijkstraPlutusPurpose AsItem era) (PlutusPurpose AsItem era),
Inject (ConwayContextError era) (ContextError era)) =>
proxy l
-> ProtVer
-> DijkstraPlutusPurpose AsItem era
-> Either (ContextError era) ScriptPurpose
transPlutusPurposeV1V2 proxy 'PlutusV1
proxy ProtVer
pv (DijkstraPlutusPurpose AsItem DijkstraEra
-> Either (ConwayContextError DijkstraEra) ScriptPurpose)
-> (DijkstraPlutusPurpose AsIxItem DijkstraEra
-> DijkstraPlutusPurpose AsItem DijkstraEra)
-> DijkstraPlutusPurpose AsIxItem DijkstraEra
-> Either (ConwayContextError DijkstraEra) ScriptPurpose
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall ix it. AsIxItem ix it -> AsItem ix it)
-> PlutusPurpose AsIxItem DijkstraEra
-> PlutusPurpose AsItem DijkstraEra
forall era (g :: * -> * -> *) (f :: * -> * -> *).
AlonzoEraScript era =>
(forall ix it. g ix it -> f ix it)
-> PlutusPurpose g era -> PlutusPurpose f era
forall (g :: * -> * -> *) (f :: * -> * -> *).
(forall ix it. g ix it -> f ix it)
-> PlutusPurpose g DijkstraEra -> PlutusPurpose f DijkstraEra
hoistPlutusPurpose AsIxItem ix it -> AsItem ix it
forall ix it. AsIxItem ix it -> AsItem ix it
toAsItem
toPlutusTxInfo :: forall (proxy :: Language -> *).
proxy 'PlutusV1
-> LedgerTxInfo DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV1)
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 DijkstraEra
ltiTx :: Tx DijkstraEra
ltiTx :: forall era. LedgerTxInfo era -> Tx era
ltiTx} = do
Tx DijkstraEra -> Either (ContextError DijkstraEra) ()
forall era.
(EraTx era, ConwayEraTxBody era,
Inject (ConwayContextError era) (ContextError era)) =>
Tx era -> Either (ContextError era) ()
Conway.guardConwayFeaturesForPlutusV1V2 Tx DijkstraEra
ltiTx
POSIXTimeRange
timeRange <- Tx DijkstraEra
-> EpochInfo (Either Text)
-> SystemStart
-> ValidityInterval
-> Either (ConwayContextError DijkstraEra) POSIXTimeRange
forall (proxy :: * -> *) era a.
Inject (AlonzoContextError era) a =>
proxy era
-> EpochInfo (Either Text)
-> SystemStart
-> ValidityInterval
-> Either a POSIXTimeRange
Conway.transValidityInterval Tx DijkstraEra
ltiTx EpochInfo (Either Text)
ltiEpochInfo SystemStart
ltiSystemStart (TxBody DijkstraEra
txBody TxBody DijkstraEra
-> Getting ValidityInterval (TxBody DijkstraEra) ValidityInterval
-> ValidityInterval
forall s a. s -> Getting a s a -> a
^. Getting ValidityInterval (TxBody DijkstraEra) ValidityInterval
forall era.
AllegraEraTxBody era =>
Lens' (TxBody era) ValidityInterval
Lens' (TxBody DijkstraEra) ValidityInterval
vldtTxBodyL)
[TxInInfo]
inputs <- (TxIn -> Either (ConwayContextError DijkstraEra) TxInInfo)
-> [TxIn] -> Either (ConwayContextError DijkstraEra) [TxInInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (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
Conway.transTxInInfoV1 UTxO DijkstraEra
ltiUTxO) (Set TxIn -> [TxIn]
forall a. Set a -> [a]
Set.toList (TxBody DijkstraEra
txBody TxBody DijkstraEra
-> Getting (Set TxIn) (TxBody DijkstraEra) (Set TxIn) -> Set TxIn
forall s a. s -> Getting a s a -> a
^. Getting (Set TxIn) (TxBody DijkstraEra) (Set TxIn)
forall era. EraTxBody era => Lens' (TxBody era) (Set TxIn)
Lens' (TxBody DijkstraEra) (Set TxIn)
inputsTxBodyL))
(TxIn -> Either (ConwayContextError DijkstraEra) TxInInfo)
-> [TxIn] -> Either (ConwayContextError DijkstraEra) ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (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
Conway.transTxInInfoV1 UTxO DijkstraEra
ltiUTxO) (Set TxIn -> [TxIn]
forall a. Set a -> [a]
Set.toList (TxBody DijkstraEra
txBody TxBody DijkstraEra
-> Getting (Set TxIn) (TxBody DijkstraEra) (Set TxIn) -> Set TxIn
forall s a. s -> Getting a s a -> a
^. Getting (Set TxIn) (TxBody DijkstraEra) (Set TxIn)
forall era. BabbageEraTxBody era => Lens' (TxBody era) (Set TxIn)
Lens' (TxBody DijkstraEra) (Set TxIn)
referenceInputsTxBodyL))
[TxOut]
outputs <-
(TxIx
-> TxOut DijkstraEra
-> Either (ConwayContextError DijkstraEra) TxOut)
-> [TxIx]
-> [TxOut DijkstraEra]
-> Either (ConwayContextError DijkstraEra) [TxOut]
forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> m c) -> [a] -> [b] -> m [c]
zipWithM
(TxOutSource
-> TxOut DijkstraEra -> Either (ContextError DijkstraEra) TxOut
TxOutSource
-> TxOut DijkstraEra
-> Either (ConwayContextError DijkstraEra) TxOut
forall era.
(Inject (BabbageContextError era) (ContextError era),
Value era ~ MaryValue, BabbageEraTxOut era) =>
TxOutSource -> TxOut era -> Either (ContextError era) TxOut
Conway.transTxOutV1 (TxOutSource
-> TxOut DijkstraEra
-> Either (ConwayContextError DijkstraEra) TxOut)
-> (TxIx -> TxOutSource)
-> TxIx
-> TxOut DijkstraEra
-> Either (ConwayContextError DijkstraEra) TxOut
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxIx -> TxOutSource
TxOutFromOutput)
[TxIx
forall a. Bounded a => a
minBound ..]
(StrictSeq (TxOut DijkstraEra) -> [TxOut DijkstraEra]
forall a. StrictSeq a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
F.toList (TxBody DijkstraEra
txBody TxBody DijkstraEra
-> Getting
(StrictSeq (TxOut DijkstraEra))
(TxBody DijkstraEra)
(StrictSeq (TxOut DijkstraEra))
-> StrictSeq (TxOut DijkstraEra)
forall s a. s -> Getting a s a -> a
^. Getting
(StrictSeq (TxOut DijkstraEra))
(TxBody DijkstraEra)
(StrictSeq (TxOut DijkstraEra))
forall era.
EraTxBody era =>
Lens' (TxBody era) (StrictSeq (TxOut era))
Lens' (TxBody DijkstraEra) (StrictSeq (TxOut DijkstraEra))
outputsTxBodyL))
[DCert]
txCerts <- proxy 'PlutusV1
-> ProtVer
-> TxBody DijkstraEra
-> Either (ContextError DijkstraEra) [PlutusTxCert 'PlutusV1]
forall (l :: Language) era (proxy :: Language -> *).
(EraPlutusTxInfo l era, EraTxBody era) =>
proxy l
-> ProtVer
-> TxBody era
-> Either (ContextError era) [PlutusTxCert l]
Alonzo.transTxBodyCerts proxy 'PlutusV1
proxy ProtVer
ltiProtVer TxBody DijkstraEra
txBody
TxInfo -> Either (ConwayContextError DijkstraEra) TxInfo
forall a. a -> Either (ConwayContextError DijkstraEra) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
PV1.TxInfo
{ txInfoInputs :: [TxInInfo]
PV1.txInfoInputs = [TxInInfo]
inputs
, txInfoOutputs :: [TxOut]
PV1.txInfoOutputs = [TxOut]
outputs
, txInfoFee :: Value
PV1.txInfoFee = Coin -> Value
transCoinToValue (TxBody DijkstraEra
txBody TxBody DijkstraEra
-> Getting Coin (TxBody DijkstraEra) Coin -> Coin
forall s a. s -> Getting a s a -> a
^. Getting Coin (TxBody DijkstraEra) Coin
forall era. EraTxBody era => Lens' (TxBody era) Coin
Lens' (TxBody DijkstraEra) Coin
feeTxBodyL)
, txInfoMint :: Value
PV1.txInfoMint = MultiAsset -> Value
Alonzo.transMintValue (TxBody DijkstraEra
txBody TxBody DijkstraEra
-> Getting MultiAsset (TxBody DijkstraEra) MultiAsset -> MultiAsset
forall s a. s -> Getting a s a -> a
^. Getting MultiAsset (TxBody DijkstraEra) MultiAsset
forall era. MaryEraTxBody era => Lens' (TxBody era) MultiAsset
Lens' (TxBody DijkstraEra) MultiAsset
mintTxBodyL)
, txInfoDCert :: [DCert]
PV1.txInfoDCert = [DCert]
txCerts
, txInfoWdrl :: [(StakingCredential, Integer)]
PV1.txInfoWdrl = TxBody DijkstraEra -> [(StakingCredential, Integer)]
forall era.
EraTxBody era =>
TxBody era -> [(StakingCredential, Integer)]
Alonzo.transTxBodyWithdrawals TxBody DijkstraEra
txBody
, txInfoValidRange :: POSIXTimeRange
PV1.txInfoValidRange = POSIXTimeRange
timeRange
, txInfoSignatories :: [PubKeyHash]
PV1.txInfoSignatories = TxBody DijkstraEra -> [PubKeyHash]
forall era. AlonzoEraTxBody era => TxBody era -> [PubKeyHash]
Alonzo.transTxBodyReqSignerHashes TxBody DijkstraEra
txBody
, txInfoData :: [(DatumHash, Datum)]
PV1.txInfoData = TxWits DijkstraEra -> [(DatumHash, Datum)]
forall era.
AlonzoEraTxWits era =>
TxWits era -> [(DatumHash, Datum)]
Alonzo.transTxWitsDatums (Tx DijkstraEra
ltiTx Tx DijkstraEra
-> Getting
(TxWits DijkstraEra) (Tx DijkstraEra) (TxWits DijkstraEra)
-> TxWits DijkstraEra
forall s a. s -> Getting a s a -> a
^. Getting (TxWits DijkstraEra) (Tx DijkstraEra) (TxWits DijkstraEra)
forall era. EraTx era => Lens' (Tx era) (TxWits era)
Lens' (Tx DijkstraEra) (TxWits DijkstraEra)
witsTxL)
, txInfoId :: TxId
PV1.txInfoId = TxBody DijkstraEra -> TxId
forall era. EraTxBody era => TxBody era -> TxId
Alonzo.transTxBodyId TxBody DijkstraEra
txBody
}
where
txBody :: TxBody DijkstraEra
txBody = Tx DijkstraEra
ltiTx Tx DijkstraEra
-> Getting
(TxBody DijkstraEra) (Tx DijkstraEra) (TxBody DijkstraEra)
-> TxBody DijkstraEra
forall s a. s -> Getting a s a -> a
^. Getting (TxBody DijkstraEra) (Tx DijkstraEra) (TxBody DijkstraEra)
forall era. EraTx era => Lens' (Tx era) (TxBody era)
Lens' (Tx DijkstraEra) (TxBody DijkstraEra)
bodyTxL
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 StakeCredential
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 (StakeCredential -> Credential
forall (kr :: KeyRole). Credential kr -> Credential
transCred StakeCredential
stakeCred))
UnRegDepositTxCert StakeCredential
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 (StakeCredential -> Credential
forall (kr :: KeyRole). Credential kr -> Credential
transCred StakeCredential
stakeCred))
DelegTxCert StakeCredential
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 (StakeCredential -> Credential
forall (kr :: KeyRole). Credential kr -> Credential
transCred StakeCredential
stakeCred)) (KeyHash 'StakePool -> PubKeyHash
forall (d :: KeyRole). KeyHash d -> PubKeyHash
transKeyHash KeyHash 'StakePool
keyHash)
RegPoolTxCert (PoolParams {KeyHash 'StakePool
ppId :: KeyHash 'StakePool
ppId :: PoolParams -> KeyHash 'StakePool
ppId, VRFVerKeyHash 'StakePoolVRF
ppVrf :: VRFVerKeyHash 'StakePoolVRF
ppVrf :: PoolParams -> VRFVerKeyHash 'StakePoolVRF
ppVrf}) ->
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
ppId)
(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
ppVrf))))
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
proxy ProtVer
pv = proxy 'PlutusV2
-> ProtVer
-> DijkstraPlutusPurpose AsItem DijkstraEra
-> Either (ContextError DijkstraEra) ScriptPurpose
forall (l :: Language) era (proxy :: Language -> *).
(EraPlutusTxInfo l era, PlutusTxCert l ~ DCert,
Inject (ConwayPlutusPurpose AsItem era) (PlutusPurpose AsItem era),
Inject
(DijkstraPlutusPurpose AsItem era) (PlutusPurpose AsItem era),
Inject (ConwayContextError era) (ContextError era)) =>
proxy l
-> ProtVer
-> DijkstraPlutusPurpose AsItem era
-> Either (ContextError era) ScriptPurpose
transPlutusPurposeV1V2 proxy 'PlutusV2
proxy ProtVer
pv (DijkstraPlutusPurpose AsItem DijkstraEra
-> Either (ConwayContextError DijkstraEra) ScriptPurpose)
-> (DijkstraPlutusPurpose AsIxItem DijkstraEra
-> DijkstraPlutusPurpose AsItem DijkstraEra)
-> DijkstraPlutusPurpose AsIxItem DijkstraEra
-> Either (ConwayContextError DijkstraEra) ScriptPurpose
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall ix it. AsIxItem ix it -> AsItem ix it)
-> PlutusPurpose AsIxItem DijkstraEra
-> PlutusPurpose AsItem DijkstraEra
forall era (g :: * -> * -> *) (f :: * -> * -> *).
AlonzoEraScript era =>
(forall ix it. g ix it -> f ix it)
-> PlutusPurpose g era -> PlutusPurpose f era
forall (g :: * -> * -> *) (f :: * -> * -> *).
(forall ix it. g ix it -> f ix it)
-> PlutusPurpose g DijkstraEra -> PlutusPurpose f DijkstraEra
hoistPlutusPurpose AsIxItem ix it -> AsItem ix it
forall ix it. AsIxItem ix it -> AsItem ix it
toAsItem
toPlutusTxInfo :: forall (proxy :: Language -> *).
proxy 'PlutusV2
-> LedgerTxInfo DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV2)
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 DijkstraEra
ltiTx :: forall era. LedgerTxInfo era -> Tx era
ltiTx :: Tx DijkstraEra
ltiTx} = do
Tx DijkstraEra -> Either (ContextError DijkstraEra) ()
forall era.
(EraTx era, ConwayEraTxBody era,
Inject (ConwayContextError era) (ContextError era)) =>
Tx era -> Either (ContextError era) ()
Conway.guardConwayFeaturesForPlutusV1V2 Tx DijkstraEra
ltiTx
POSIXTimeRange
timeRange <-
Tx DijkstraEra
-> EpochInfo (Either Text)
-> SystemStart
-> ValidityInterval
-> Either (ConwayContextError DijkstraEra) POSIXTimeRange
forall (proxy :: * -> *) era a.
Inject (AlonzoContextError era) a =>
proxy era
-> EpochInfo (Either Text)
-> SystemStart
-> ValidityInterval
-> Either a POSIXTimeRange
Conway.transValidityInterval Tx DijkstraEra
ltiTx EpochInfo (Either Text)
ltiEpochInfo SystemStart
ltiSystemStart (TxBody DijkstraEra
txBody TxBody DijkstraEra
-> Getting ValidityInterval (TxBody DijkstraEra) ValidityInterval
-> ValidityInterval
forall s a. s -> Getting a s a -> a
^. Getting ValidityInterval (TxBody DijkstraEra) ValidityInterval
forall era.
AllegraEraTxBody era =>
Lens' (TxBody era) ValidityInterval
Lens' (TxBody DijkstraEra) ValidityInterval
vldtTxBodyL)
[TxInInfo]
inputs <- (TxIn -> Either (ConwayContextError DijkstraEra) TxInInfo)
-> [TxIn] -> Either (ConwayContextError DijkstraEra) [TxInInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (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 UTxO DijkstraEra
ltiUTxO) (Set TxIn -> [TxIn]
forall a. Set a -> [a]
Set.toList (TxBody DijkstraEra
txBody TxBody DijkstraEra
-> Getting (Set TxIn) (TxBody DijkstraEra) (Set TxIn) -> Set TxIn
forall s a. s -> Getting a s a -> a
^. Getting (Set TxIn) (TxBody DijkstraEra) (Set TxIn)
forall era. EraTxBody era => Lens' (TxBody era) (Set TxIn)
Lens' (TxBody DijkstraEra) (Set TxIn)
inputsTxBodyL))
[TxInInfo]
refInputs <- (TxIn -> Either (ConwayContextError DijkstraEra) TxInInfo)
-> [TxIn] -> Either (ConwayContextError DijkstraEra) [TxInInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (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 UTxO DijkstraEra
ltiUTxO) (Set TxIn -> [TxIn]
forall a. Set a -> [a]
Set.toList (TxBody DijkstraEra
txBody TxBody DijkstraEra
-> Getting (Set TxIn) (TxBody DijkstraEra) (Set TxIn) -> Set TxIn
forall s a. s -> Getting a s a -> a
^. Getting (Set TxIn) (TxBody DijkstraEra) (Set TxIn)
forall era. BabbageEraTxBody era => Lens' (TxBody era) (Set TxIn)
Lens' (TxBody DijkstraEra) (Set TxIn)
referenceInputsTxBodyL))
[TxOut]
outputs <-
(TxIx
-> TxOut DijkstraEra
-> Either (ConwayContextError DijkstraEra) TxOut)
-> [TxIx]
-> [TxOut DijkstraEra]
-> Either (ConwayContextError DijkstraEra) [TxOut]
forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> m c) -> [a] -> [b] -> m [c]
zipWithM
(TxOutSource
-> TxOut DijkstraEra -> Either (ContextError DijkstraEra) TxOut
TxOutSource
-> TxOut DijkstraEra
-> Either (ConwayContextError DijkstraEra) TxOut
forall era.
(Inject (BabbageContextError era) (ContextError era),
Value era ~ MaryValue, BabbageEraTxOut era) =>
TxOutSource -> TxOut era -> Either (ContextError era) TxOut
Babbage.transTxOutV2 (TxOutSource
-> TxOut DijkstraEra
-> Either (ConwayContextError DijkstraEra) TxOut)
-> (TxIx -> TxOutSource)
-> TxIx
-> TxOut DijkstraEra
-> Either (ConwayContextError DijkstraEra) TxOut
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxIx -> TxOutSource
TxOutFromOutput)
[TxIx
forall a. Bounded a => a
minBound ..]
(StrictSeq (TxOut DijkstraEra) -> [TxOut DijkstraEra]
forall a. StrictSeq a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
F.toList (TxBody DijkstraEra
txBody TxBody DijkstraEra
-> Getting
(StrictSeq (TxOut DijkstraEra))
(TxBody DijkstraEra)
(StrictSeq (TxOut DijkstraEra))
-> StrictSeq (TxOut DijkstraEra)
forall s a. s -> Getting a s a -> a
^. Getting
(StrictSeq (TxOut DijkstraEra))
(TxBody DijkstraEra)
(StrictSeq (TxOut DijkstraEra))
forall era.
EraTxBody era =>
Lens' (TxBody era) (StrictSeq (TxOut era))
Lens' (TxBody DijkstraEra) (StrictSeq (TxOut DijkstraEra))
outputsTxBodyL))
[DCert]
txCerts <- proxy 'PlutusV2
-> ProtVer
-> TxBody DijkstraEra
-> Either (ContextError DijkstraEra) [PlutusTxCert 'PlutusV2]
forall (l :: Language) era (proxy :: Language -> *).
(EraPlutusTxInfo l era, EraTxBody era) =>
proxy l
-> ProtVer
-> TxBody era
-> Either (ContextError era) [PlutusTxCert l]
Alonzo.transTxBodyCerts proxy 'PlutusV2
proxy ProtVer
ltiProtVer TxBody DijkstraEra
txBody
Map ScriptPurpose Redeemer
plutusRedeemers <- proxy 'PlutusV2
-> ProtVer
-> Tx DijkstraEra
-> Either
(ContextError DijkstraEra)
(Map (PlutusScriptPurpose 'PlutusV2) Redeemer)
forall (l :: Language) era (proxy :: Language -> *).
(EraPlutusTxInfo l era, AlonzoEraTxBody era, EraTx era,
AlonzoEraTxWits era,
Inject (BabbageContextError era) (ContextError era)) =>
proxy l
-> ProtVer
-> Tx era
-> Either (ContextError era) (Map (PlutusScriptPurpose l) Redeemer)
Babbage.transTxRedeemers proxy 'PlutusV2
proxy ProtVer
ltiProtVer Tx DijkstraEra
ltiTx
TxInfo -> Either (ConwayContextError DijkstraEra) TxInfo
forall a. a -> Either (ConwayContextError DijkstraEra) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
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 DijkstraEra
txBody TxBody DijkstraEra
-> Getting Coin (TxBody DijkstraEra) Coin -> Coin
forall s a. s -> Getting a s a -> a
^. Getting Coin (TxBody DijkstraEra) Coin
forall era. EraTxBody era => Lens' (TxBody era) Coin
Lens' (TxBody DijkstraEra) Coin
feeTxBodyL)
, txInfoMint :: Value
PV2.txInfoMint = MultiAsset -> Value
Alonzo.transMintValue (TxBody DijkstraEra
txBody TxBody DijkstraEra
-> Getting MultiAsset (TxBody DijkstraEra) MultiAsset -> MultiAsset
forall s a. s -> Getting a s a -> a
^. Getting MultiAsset (TxBody DijkstraEra) MultiAsset
forall era. MaryEraTxBody era => Lens' (TxBody era) MultiAsset
Lens' (TxBody 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 DijkstraEra -> [(StakingCredential, Integer)]
forall era.
EraTxBody era =>
TxBody era -> [(StakingCredential, Integer)]
Alonzo.transTxBodyWithdrawals TxBody DijkstraEra
txBody
, txInfoValidRange :: POSIXTimeRange
PV2.txInfoValidRange = POSIXTimeRange
timeRange
, txInfoSignatories :: [PubKeyHash]
PV2.txInfoSignatories = TxBody DijkstraEra -> [PubKeyHash]
forall era. AlonzoEraTxBody era => TxBody era -> [PubKeyHash]
Alonzo.transTxBodyReqSignerHashes TxBody 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 DijkstraEra
ltiTx Tx DijkstraEra
-> Getting
(TxWits DijkstraEra) (Tx DijkstraEra) (TxWits DijkstraEra)
-> TxWits DijkstraEra
forall s a. s -> Getting a s a -> a
^. Getting (TxWits DijkstraEra) (Tx DijkstraEra) (TxWits DijkstraEra)
forall era. EraTx era => Lens' (Tx era) (TxWits era)
Lens' (Tx DijkstraEra) (TxWits DijkstraEra)
witsTxL)
, txInfoId :: TxId
PV2.txInfoId = TxBody DijkstraEra -> TxId
forall era. EraTxBody era => TxBody era -> TxId
Alonzo.transTxBodyId TxBody DijkstraEra
txBody
}
where
txBody :: TxBody DijkstraEra
txBody = Tx DijkstraEra
ltiTx Tx DijkstraEra
-> Getting
(TxBody DijkstraEra) (Tx DijkstraEra) (TxBody DijkstraEra)
-> TxBody DijkstraEra
forall s a. s -> Getting a s a -> a
^. Getting (TxBody DijkstraEra) (Tx DijkstraEra) (TxBody DijkstraEra)
forall era. EraTx era => Lens' (Tx era) (TxBody era)
Lens' (Tx DijkstraEra) (TxBody DijkstraEra)
bodyTxL
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 (ConwayContextError DijkstraEra) TxCert
forall a. a -> Either (ConwayContextError DijkstraEra) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TxCert -> Either (ConwayContextError DijkstraEra) TxCert)
-> (DijkstraTxCert DijkstraEra -> TxCert)
-> DijkstraTxCert DijkstraEra
-> Either (ConwayContextError 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)
ProtVer
-> DijkstraPlutusPurpose AsIxItem DijkstraEra
-> Either (ContextError DijkstraEra) ScriptPurpose
forall era.
(ConwayEraPlutusTxInfo 'PlutusV3 era,
Inject (ConwayContextError era) (ContextError era),
Inject
(DijkstraPlutusPurpose AsIxItem era)
(PlutusPurpose AsIxItem era)) =>
ProtVer
-> DijkstraPlutusPurpose AsIxItem era
-> Either (ContextError era) ScriptPurpose
transPlutusPurposeV3
toPlutusTxInfo :: forall (proxy :: Language -> *).
proxy 'PlutusV3
-> LedgerTxInfo DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV3)
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 DijkstraEra
ltiTx :: forall era. LedgerTxInfo era -> Tx era
ltiTx :: Tx DijkstraEra
ltiTx} = do
POSIXTimeRange
timeRange <-
Tx DijkstraEra
-> EpochInfo (Either Text)
-> SystemStart
-> ValidityInterval
-> Either (ConwayContextError DijkstraEra) POSIXTimeRange
forall (proxy :: * -> *) era a.
Inject (AlonzoContextError era) a =>
proxy era
-> EpochInfo (Either Text)
-> SystemStart
-> ValidityInterval
-> Either a POSIXTimeRange
Conway.transValidityInterval Tx DijkstraEra
ltiTx EpochInfo (Either Text)
ltiEpochInfo SystemStart
ltiSystemStart (TxBody DijkstraEra
txBody TxBody DijkstraEra
-> Getting ValidityInterval (TxBody DijkstraEra) ValidityInterval
-> ValidityInterval
forall s a. s -> Getting a s a -> a
^. Getting ValidityInterval (TxBody DijkstraEra) ValidityInterval
forall era.
AllegraEraTxBody era =>
Lens' (TxBody era) ValidityInterval
Lens' (TxBody DijkstraEra) ValidityInterval
vldtTxBodyL)
let
txInputs :: Set TxIn
txInputs = TxBody DijkstraEra
txBody TxBody DijkstraEra
-> Getting (Set TxIn) (TxBody DijkstraEra) (Set TxIn) -> Set TxIn
forall s a. s -> Getting a s a -> a
^. Getting (Set TxIn) (TxBody DijkstraEra) (Set TxIn)
forall era. EraTxBody era => Lens' (TxBody era) (Set TxIn)
Lens' (TxBody DijkstraEra) (Set TxIn)
inputsTxBodyL
refInputs :: Set TxIn
refInputs = TxBody DijkstraEra
txBody TxBody DijkstraEra
-> Getting (Set TxIn) (TxBody DijkstraEra) (Set TxIn) -> Set TxIn
forall s a. s -> Getting a s a -> a
^. Getting (Set TxIn) (TxBody DijkstraEra) (Set TxIn)
forall era. BabbageEraTxBody era => Lens' (TxBody era) (Set TxIn)
Lens' (TxBody DijkstraEra) (Set TxIn)
referenceInputsTxBodyL
[TxInInfo]
inputsInfo <- (TxIn -> Either (ConwayContextError DijkstraEra) TxInInfo)
-> [TxIn] -> Either (ConwayContextError DijkstraEra) [TxInInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (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
Conway.transTxInInfoV3 UTxO DijkstraEra
ltiUTxO) (Set TxIn -> [TxIn]
forall a. Set a -> [a]
Set.toList Set TxIn
txInputs)
[TxInInfo]
refInputsInfo <- (TxIn -> Either (ConwayContextError DijkstraEra) TxInInfo)
-> [TxIn] -> Either (ConwayContextError DijkstraEra) [TxInInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (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
Conway.transTxInInfoV3 UTxO DijkstraEra
ltiUTxO) (Set TxIn -> [TxIn]
forall a. Set a -> [a]
Set.toList Set TxIn
refInputs)
let
commonInputs :: Set TxIn
commonInputs = Set TxIn
txInputs Set TxIn -> Set TxIn -> Set TxIn
forall a. Ord a => Set a -> Set a -> Set a
`Set.intersection` Set TxIn
refInputs
case Set TxIn -> [TxIn]
forall a. Set a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Set TxIn
commonInputs of
(TxIn
x : [TxIn]
xs) -> ConwayContextError DijkstraEra
-> Either (ConwayContextError DijkstraEra) ()
forall a b. a -> Either a b
Left (ConwayContextError DijkstraEra
-> Either (ConwayContextError DijkstraEra) ())
-> ConwayContextError DijkstraEra
-> Either (ConwayContextError DijkstraEra) ()
forall a b. (a -> b) -> a -> b
$ NonEmpty TxIn -> ConwayContextError DijkstraEra
forall era. NonEmpty TxIn -> ConwayContextError era
ReferenceInputsNotDisjointFromInputs (NonEmpty TxIn -> ConwayContextError DijkstraEra)
-> NonEmpty TxIn -> ConwayContextError DijkstraEra
forall a b. (a -> b) -> a -> b
$ TxIn
x TxIn -> [TxIn] -> NonEmpty TxIn
forall a. a -> [a] -> NonEmpty a
:| [TxIn]
xs
[TxIn]
_ -> () -> Either (ConwayContextError DijkstraEra) ()
forall a b. b -> Either a b
Right ()
[TxOut]
outputs <-
(TxIx
-> TxOut DijkstraEra
-> Either (ConwayContextError DijkstraEra) TxOut)
-> [TxIx]
-> [TxOut DijkstraEra]
-> Either (ConwayContextError DijkstraEra) [TxOut]
forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> m c) -> [a] -> [b] -> m [c]
zipWithM
(TxOutSource
-> TxOut DijkstraEra -> Either (ContextError DijkstraEra) TxOut
TxOutSource
-> TxOut DijkstraEra
-> Either (ConwayContextError DijkstraEra) TxOut
forall era.
(Inject (BabbageContextError era) (ContextError era),
Value era ~ MaryValue, BabbageEraTxOut era) =>
TxOutSource -> TxOut era -> Either (ContextError era) TxOut
Babbage.transTxOutV2 (TxOutSource
-> TxOut DijkstraEra
-> Either (ConwayContextError DijkstraEra) TxOut)
-> (TxIx -> TxOutSource)
-> TxIx
-> TxOut DijkstraEra
-> Either (ConwayContextError DijkstraEra) TxOut
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxIx -> TxOutSource
TxOutFromOutput)
[TxIx
forall a. Bounded a => a
minBound ..]
(StrictSeq (TxOut DijkstraEra) -> [TxOut DijkstraEra]
forall a. StrictSeq a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
F.toList (TxBody DijkstraEra
txBody TxBody DijkstraEra
-> Getting
(StrictSeq (TxOut DijkstraEra))
(TxBody DijkstraEra)
(StrictSeq (TxOut DijkstraEra))
-> StrictSeq (TxOut DijkstraEra)
forall s a. s -> Getting a s a -> a
^. Getting
(StrictSeq (TxOut DijkstraEra))
(TxBody DijkstraEra)
(StrictSeq (TxOut DijkstraEra))
forall era.
EraTxBody era =>
Lens' (TxBody era) (StrictSeq (TxOut era))
Lens' (TxBody DijkstraEra) (StrictSeq (TxOut DijkstraEra))
outputsTxBodyL))
[TxCert]
txCerts <- proxy 'PlutusV3
-> ProtVer
-> TxBody DijkstraEra
-> Either (ContextError DijkstraEra) [PlutusTxCert 'PlutusV3]
forall (l :: Language) era (proxy :: Language -> *).
(EraPlutusTxInfo l era, EraTxBody era) =>
proxy l
-> ProtVer
-> TxBody era
-> Either (ContextError era) [PlutusTxCert l]
Alonzo.transTxBodyCerts proxy 'PlutusV3
proxy ProtVer
ltiProtVer TxBody DijkstraEra
txBody
Map ScriptPurpose Redeemer
plutusRedeemers <- proxy 'PlutusV3
-> ProtVer
-> Tx DijkstraEra
-> Either
(ContextError DijkstraEra)
(Map (PlutusScriptPurpose 'PlutusV3) Redeemer)
forall (l :: Language) era (proxy :: Language -> *).
(EraPlutusTxInfo l era, AlonzoEraTxBody era, EraTx era,
AlonzoEraTxWits era,
Inject (BabbageContextError era) (ContextError era)) =>
proxy l
-> ProtVer
-> Tx era
-> Either (ContextError era) (Map (PlutusScriptPurpose l) Redeemer)
Babbage.transTxRedeemers proxy 'PlutusV3
proxy ProtVer
ltiProtVer Tx DijkstraEra
ltiTx
TxInfo -> Either (ConwayContextError DijkstraEra) TxInfo
forall a. a -> Either (ConwayContextError DijkstraEra) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
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 DijkstraEra
txBody TxBody DijkstraEra
-> Getting Coin (TxBody DijkstraEra) Coin -> Coin
forall s a. s -> Getting a s a -> a
^. Getting Coin (TxBody DijkstraEra) Coin
forall era. EraTxBody era => Lens' (TxBody era) Coin
Lens' (TxBody DijkstraEra) Coin
feeTxBodyL)
, txInfoMint :: MintValue
PV3.txInfoMint = MultiAsset -> MintValue
Conway.transMintValue (TxBody DijkstraEra
txBody TxBody DijkstraEra
-> Getting MultiAsset (TxBody DijkstraEra) MultiAsset -> MultiAsset
forall s a. s -> Getting a s a -> a
^. Getting MultiAsset (TxBody DijkstraEra) MultiAsset
forall era. MaryEraTxBody era => Lens' (TxBody era) MultiAsset
Lens' (TxBody DijkstraEra) MultiAsset
mintTxBodyL)
, txInfoTxCerts :: [TxCert]
PV3.txInfoTxCerts = [TxCert]
txCerts
, txInfoWdrl :: Map Credential Lovelace
PV3.txInfoWdrl = TxBody DijkstraEra -> Map Credential Lovelace
forall era. EraTxBody era => TxBody era -> Map Credential Lovelace
Conway.transTxBodyWithdrawals TxBody DijkstraEra
txBody
, txInfoValidRange :: POSIXTimeRange
PV3.txInfoValidRange = POSIXTimeRange
timeRange
, txInfoSignatories :: [PubKeyHash]
PV3.txInfoSignatories = TxBody DijkstraEra -> [PubKeyHash]
forall era. AlonzoEraTxBody era => TxBody era -> [PubKeyHash]
Alonzo.transTxBodyReqSignerHashes TxBody 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 DijkstraEra
ltiTx Tx DijkstraEra
-> Getting
(TxWits DijkstraEra) (Tx DijkstraEra) (TxWits DijkstraEra)
-> TxWits DijkstraEra
forall s a. s -> Getting a s a -> a
^. Getting (TxWits DijkstraEra) (Tx DijkstraEra) (TxWits DijkstraEra)
forall era. EraTx era => Lens' (Tx era) (TxWits era)
Lens' (Tx DijkstraEra) (TxWits DijkstraEra)
witsTxL)
, txInfoId :: TxId
PV3.txInfoId = TxBody DijkstraEra -> TxId
forall era. EraTxBody era => TxBody era -> TxId
Conway.transTxBodyId TxBody 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 DijkstraEra
txBody TxBody DijkstraEra
-> Getting
(VotingProcedures DijkstraEra)
(TxBody DijkstraEra)
(VotingProcedures DijkstraEra)
-> VotingProcedures DijkstraEra
forall s a. s -> Getting a s a -> a
^. Getting
(VotingProcedures DijkstraEra)
(TxBody DijkstraEra)
(VotingProcedures DijkstraEra)
forall era.
ConwayEraTxBody era =>
Lens' (TxBody era) (VotingProcedures era)
Lens' (TxBody 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 DijkstraEra
txBody TxBody DijkstraEra
-> Getting
(OSet (ProposalProcedure DijkstraEra))
(TxBody DijkstraEra)
(OSet (ProposalProcedure DijkstraEra))
-> OSet (ProposalProcedure DijkstraEra)
forall s a. s -> Getting a s a -> a
^. Getting
(OSet (ProposalProcedure DijkstraEra))
(TxBody DijkstraEra)
(OSet (ProposalProcedure DijkstraEra))
forall era.
ConwayEraTxBody era =>
Lens' (TxBody era) (OSet (ProposalProcedure era))
Lens' (TxBody 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 DijkstraEra
txBody TxBody DijkstraEra
-> Getting
(StrictMaybe Coin) (TxBody DijkstraEra) (StrictMaybe Coin)
-> StrictMaybe Coin
forall s a. s -> Getting a s a -> a
^. Getting (StrictMaybe Coin) (TxBody DijkstraEra) (StrictMaybe Coin)
forall era.
ConwayEraTxBody era =>
Lens' (TxBody era) (StrictMaybe Coin)
Lens' (TxBody DijkstraEra) (StrictMaybe Coin)
currentTreasuryValueTxBodyL
, txInfoTreasuryDonation :: Maybe Lovelace
PV3.txInfoTreasuryDonation =
case TxBody DijkstraEra
txBody TxBody DijkstraEra
-> Getting Coin (TxBody DijkstraEra) Coin -> Coin
forall s a. s -> Getting a s a -> a
^. Getting Coin (TxBody DijkstraEra) Coin
forall era. ConwayEraTxBody era => Lens' (TxBody era) Coin
Lens' (TxBody 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
}
where
txBody :: TxBody DijkstraEra
txBody = Tx DijkstraEra
ltiTx Tx DijkstraEra
-> Getting
(TxBody DijkstraEra) (Tx DijkstraEra) (TxBody DijkstraEra)
-> TxBody DijkstraEra
forall s a. s -> Getting a s a -> a
^. Getting (TxBody DijkstraEra) (Tx DijkstraEra) (TxBody DijkstraEra)
forall era. EraTx era => Lens' (Tx era) (TxBody era)
Lens' (Tx DijkstraEra) (TxBody DijkstraEra)
bodyTxL
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
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 PoolParams {KeyHash 'StakePool
ppId :: PoolParams -> KeyHash 'StakePool
ppId :: KeyHash 'StakePool
ppId, VRFVerKeyHash 'StakePoolVRF
ppVrf :: PoolParams -> VRFVerKeyHash 'StakePoolVRF
ppVrf :: VRFVerKeyHash 'StakePoolVRF
ppVrf} ->
PubKeyHash -> PubKeyHash -> TxCert
PV3.TxCertPoolRegister
(KeyHash 'StakePool -> PubKeyHash
forall (d :: KeyRole). KeyHash d -> PubKeyHash
transKeyHash KeyHash 'StakePool
ppId)
(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
ppVrf))))
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 StakeCredential
stakeCred Coin
deposit ->
Credential -> Maybe Lovelace -> TxCert
PV3.TxCertRegStaking (StakeCredential -> Credential
forall (kr :: KeyRole). Credential kr -> Credential
transCred StakeCredential
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 StakeCredential
stakeCred Coin
refund ->
Credential -> Maybe Lovelace -> TxCert
PV3.TxCertUnRegStaking (StakeCredential -> Credential
forall (kr :: KeyRole). Credential kr -> Credential
transCred StakeCredential
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 StakeCredential
stakeCred Delegatee
delegatee ->
Credential -> Delegatee -> TxCert
PV3.TxCertDelegStaking (StakeCredential -> Credential
forall (kr :: KeyRole). Credential kr -> Credential
transCred StakeCredential
stakeCred) (Delegatee -> Delegatee
Conway.transDelegatee Delegatee
delegatee)
RegDepositDelegTxCert StakeCredential
stakeCred Delegatee
delegatee Coin
deposit ->
Credential -> Delegatee -> Lovelace -> TxCert
PV3.TxCertRegDeleg
(StakeCredential -> Credential
forall (kr :: KeyRole). Credential kr -> Credential
transCred StakeCredential
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
_ -> [Char] -> TxCert
forall a. HasCallStack => [Char] -> a
error [Char]
"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 (ConwayContextError DijkstraEra) TxCert
forall a. a -> Either (ConwayContextError DijkstraEra) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TxCert -> Either (ConwayContextError DijkstraEra) TxCert)
-> (DijkstraTxCert DijkstraEra -> TxCert)
-> DijkstraTxCert DijkstraEra
-> Either (ConwayContextError 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
_ = [Char]
-> ProtVer
-> DijkstraPlutusPurpose AsIxItem DijkstraEra
-> Either (ConwayContextError DijkstraEra) ScriptPurpose
forall a. HasCallStack => [Char] -> a
error [Char]
"stub: PlutusV4 not yet implemented"
toPlutusTxInfo :: forall (proxy :: Language -> *).
proxy 'PlutusV4
-> LedgerTxInfo DijkstraEra
-> Either (ContextError DijkstraEra) (PlutusTxInfo 'PlutusV4)
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 DijkstraEra
ltiTx :: forall era. LedgerTxInfo era -> Tx era
ltiTx :: Tx DijkstraEra
ltiTx} = do
POSIXTimeRange
timeRange <-
Tx DijkstraEra
-> EpochInfo (Either Text)
-> SystemStart
-> ValidityInterval
-> Either (ConwayContextError DijkstraEra) POSIXTimeRange
forall (proxy :: * -> *) era a.
Inject (AlonzoContextError era) a =>
proxy era
-> EpochInfo (Either Text)
-> SystemStart
-> ValidityInterval
-> Either a POSIXTimeRange
Conway.transValidityInterval Tx DijkstraEra
ltiTx EpochInfo (Either Text)
ltiEpochInfo SystemStart
ltiSystemStart (TxBody DijkstraEra
txBody TxBody DijkstraEra
-> Getting ValidityInterval (TxBody DijkstraEra) ValidityInterval
-> ValidityInterval
forall s a. s -> Getting a s a -> a
^. Getting ValidityInterval (TxBody DijkstraEra) ValidityInterval
forall era.
AllegraEraTxBody era =>
Lens' (TxBody era) ValidityInterval
Lens' (TxBody DijkstraEra) ValidityInterval
vldtTxBodyL)
let
txInputs :: Set TxIn
txInputs = TxBody DijkstraEra
txBody TxBody DijkstraEra
-> Getting (Set TxIn) (TxBody DijkstraEra) (Set TxIn) -> Set TxIn
forall s a. s -> Getting a s a -> a
^. Getting (Set TxIn) (TxBody DijkstraEra) (Set TxIn)
forall era. EraTxBody era => Lens' (TxBody era) (Set TxIn)
Lens' (TxBody DijkstraEra) (Set TxIn)
inputsTxBodyL
refInputs :: Set TxIn
refInputs = TxBody DijkstraEra
txBody TxBody DijkstraEra
-> Getting (Set TxIn) (TxBody DijkstraEra) (Set TxIn) -> Set TxIn
forall s a. s -> Getting a s a -> a
^. Getting (Set TxIn) (TxBody DijkstraEra) (Set TxIn)
forall era. BabbageEraTxBody era => Lens' (TxBody era) (Set TxIn)
Lens' (TxBody DijkstraEra) (Set TxIn)
referenceInputsTxBodyL
[TxInInfo]
inputsInfo <- (TxIn -> Either (ConwayContextError DijkstraEra) TxInInfo)
-> [TxIn] -> Either (ConwayContextError DijkstraEra) [TxInInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (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
Conway.transTxInInfoV3 UTxO DijkstraEra
ltiUTxO) (Set TxIn -> [TxIn]
forall a. Set a -> [a]
Set.toList Set TxIn
txInputs)
[TxInInfo]
refInputsInfo <- (TxIn -> Either (ConwayContextError DijkstraEra) TxInInfo)
-> [TxIn] -> Either (ConwayContextError DijkstraEra) [TxInInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (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
Conway.transTxInInfoV3 UTxO DijkstraEra
ltiUTxO) (Set TxIn -> [TxIn]
forall a. Set a -> [a]
Set.toList Set TxIn
refInputs)
let
commonInputs :: Set TxIn
commonInputs = Set TxIn
txInputs Set TxIn -> Set TxIn -> Set TxIn
forall a. Ord a => Set a -> Set a -> Set a
`Set.intersection` Set TxIn
refInputs
case Set TxIn -> [TxIn]
forall a. Set a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Set TxIn
commonInputs of
(TxIn
x : [TxIn]
xs) -> ConwayContextError DijkstraEra
-> Either (ConwayContextError DijkstraEra) ()
forall a b. a -> Either a b
Left (ConwayContextError DijkstraEra
-> Either (ConwayContextError DijkstraEra) ())
-> ConwayContextError DijkstraEra
-> Either (ConwayContextError DijkstraEra) ()
forall a b. (a -> b) -> a -> b
$ NonEmpty TxIn -> ConwayContextError DijkstraEra
forall era. NonEmpty TxIn -> ConwayContextError era
ReferenceInputsNotDisjointFromInputs (NonEmpty TxIn -> ConwayContextError DijkstraEra)
-> NonEmpty TxIn -> ConwayContextError DijkstraEra
forall a b. (a -> b) -> a -> b
$ TxIn
x TxIn -> [TxIn] -> NonEmpty TxIn
forall a. a -> [a] -> NonEmpty a
:| [TxIn]
xs
[TxIn]
_ -> () -> Either (ConwayContextError DijkstraEra) ()
forall a b. b -> Either a b
Right ()
[TxOut]
outputs <-
(TxIx
-> TxOut DijkstraEra
-> Either (ConwayContextError DijkstraEra) TxOut)
-> [TxIx]
-> [TxOut DijkstraEra]
-> Either (ConwayContextError DijkstraEra) [TxOut]
forall (m :: * -> *) a b c.
Applicative m =>
(a -> b -> m c) -> [a] -> [b] -> m [c]
zipWithM
(TxOutSource
-> TxOut DijkstraEra -> Either (ContextError DijkstraEra) TxOut
TxOutSource
-> TxOut DijkstraEra
-> Either (ConwayContextError DijkstraEra) TxOut
forall era.
(Inject (BabbageContextError era) (ContextError era),
Value era ~ MaryValue, BabbageEraTxOut era) =>
TxOutSource -> TxOut era -> Either (ContextError era) TxOut
Babbage.transTxOutV2 (TxOutSource
-> TxOut DijkstraEra
-> Either (ConwayContextError DijkstraEra) TxOut)
-> (TxIx -> TxOutSource)
-> TxIx
-> TxOut DijkstraEra
-> Either (ConwayContextError DijkstraEra) TxOut
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxIx -> TxOutSource
TxOutFromOutput)
[TxIx
forall a. Bounded a => a
minBound ..]
(StrictSeq (TxOut DijkstraEra) -> [TxOut DijkstraEra]
forall a. StrictSeq a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
F.toList (TxBody DijkstraEra
txBody TxBody DijkstraEra
-> Getting
(StrictSeq (TxOut DijkstraEra))
(TxBody DijkstraEra)
(StrictSeq (TxOut DijkstraEra))
-> StrictSeq (TxOut DijkstraEra)
forall s a. s -> Getting a s a -> a
^. Getting
(StrictSeq (TxOut DijkstraEra))
(TxBody DijkstraEra)
(StrictSeq (TxOut DijkstraEra))
forall era.
EraTxBody era =>
Lens' (TxBody era) (StrictSeq (TxOut era))
Lens' (TxBody DijkstraEra) (StrictSeq (TxOut DijkstraEra))
outputsTxBodyL))
[TxCert]
txCerts <- proxy 'PlutusV4
-> ProtVer
-> TxBody DijkstraEra
-> Either (ContextError DijkstraEra) [PlutusTxCert 'PlutusV4]
forall (l :: Language) era (proxy :: Language -> *).
(EraPlutusTxInfo l era, EraTxBody era) =>
proxy l
-> ProtVer
-> TxBody era
-> Either (ContextError era) [PlutusTxCert l]
Alonzo.transTxBodyCerts proxy 'PlutusV4
proxy ProtVer
ltiProtVer TxBody DijkstraEra
txBody
Map ScriptPurpose Redeemer
plutusRedeemers <- proxy 'PlutusV4
-> ProtVer
-> Tx DijkstraEra
-> Either
(ContextError DijkstraEra)
(Map (PlutusScriptPurpose 'PlutusV4) Redeemer)
forall (l :: Language) era (proxy :: Language -> *).
(EraPlutusTxInfo l era, AlonzoEraTxBody era, EraTx era,
AlonzoEraTxWits era,
Inject (BabbageContextError era) (ContextError era)) =>
proxy l
-> ProtVer
-> Tx era
-> Either (ContextError era) (Map (PlutusScriptPurpose l) Redeemer)
Babbage.transTxRedeemers proxy 'PlutusV4
proxy ProtVer
ltiProtVer Tx DijkstraEra
ltiTx
TxInfo -> Either (ConwayContextError DijkstraEra) TxInfo
forall a. a -> Either (ConwayContextError DijkstraEra) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
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 DijkstraEra
txBody TxBody DijkstraEra
-> Getting Coin (TxBody DijkstraEra) Coin -> Coin
forall s a. s -> Getting a s a -> a
^. Getting Coin (TxBody DijkstraEra) Coin
forall era. EraTxBody era => Lens' (TxBody era) Coin
Lens' (TxBody DijkstraEra) Coin
feeTxBodyL)
, txInfoMint :: MintValue
PV3.txInfoMint = MultiAsset -> MintValue
Conway.transMintValue (TxBody DijkstraEra
txBody TxBody DijkstraEra
-> Getting MultiAsset (TxBody DijkstraEra) MultiAsset -> MultiAsset
forall s a. s -> Getting a s a -> a
^. Getting MultiAsset (TxBody DijkstraEra) MultiAsset
forall era. MaryEraTxBody era => Lens' (TxBody era) MultiAsset
Lens' (TxBody DijkstraEra) MultiAsset
mintTxBodyL)
, txInfoTxCerts :: [TxCert]
PV3.txInfoTxCerts = [TxCert]
txCerts
, txInfoWdrl :: Map Credential Lovelace
PV3.txInfoWdrl = TxBody DijkstraEra -> Map Credential Lovelace
forall era. EraTxBody era => TxBody era -> Map Credential Lovelace
Conway.transTxBodyWithdrawals TxBody DijkstraEra
txBody
, txInfoValidRange :: POSIXTimeRange
PV3.txInfoValidRange = POSIXTimeRange
timeRange
, txInfoSignatories :: [PubKeyHash]
PV3.txInfoSignatories = TxBody DijkstraEra -> [PubKeyHash]
forall era. AlonzoEraTxBody era => TxBody era -> [PubKeyHash]
Alonzo.transTxBodyReqSignerHashes TxBody 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 DijkstraEra
ltiTx Tx DijkstraEra
-> Getting
(TxWits DijkstraEra) (Tx DijkstraEra) (TxWits DijkstraEra)
-> TxWits DijkstraEra
forall s a. s -> Getting a s a -> a
^. Getting (TxWits DijkstraEra) (Tx DijkstraEra) (TxWits DijkstraEra)
forall era. EraTx era => Lens' (Tx era) (TxWits era)
Lens' (Tx DijkstraEra) (TxWits DijkstraEra)
witsTxL)
, txInfoId :: TxId
PV3.txInfoId = TxBody DijkstraEra -> TxId
forall era. EraTxBody era => TxBody era -> TxId
Conway.transTxBodyId TxBody 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 DijkstraEra
txBody TxBody DijkstraEra
-> Getting
(VotingProcedures DijkstraEra)
(TxBody DijkstraEra)
(VotingProcedures DijkstraEra)
-> VotingProcedures DijkstraEra
forall s a. s -> Getting a s a -> a
^. Getting
(VotingProcedures DijkstraEra)
(TxBody DijkstraEra)
(VotingProcedures DijkstraEra)
forall era.
ConwayEraTxBody era =>
Lens' (TxBody era) (VotingProcedures era)
Lens' (TxBody DijkstraEra) (VotingProcedures DijkstraEra)
votingProceduresTxBodyL)
, txInfoProposalProcedures :: [ProposalProcedure]
PV3.txInfoProposalProcedures =
(ProposalProcedure DijkstraEra -> ProposalProcedure)
-> [ProposalProcedure DijkstraEra] -> [ProposalProcedure]
forall a b. (a -> b) -> [a] -> [b]
map (proxy 'PlutusV4
-> ProposalProcedure DijkstraEra -> ProposalProcedure
forall (l :: Language) era (proxy :: Language -> *).
ConwayEraPlutusTxInfo l era =>
proxy l -> ProposalProcedure era -> ProposalProcedure
Conway.transProposal proxy 'PlutusV4
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 DijkstraEra
txBody TxBody DijkstraEra
-> Getting
(OSet (ProposalProcedure DijkstraEra))
(TxBody DijkstraEra)
(OSet (ProposalProcedure DijkstraEra))
-> OSet (ProposalProcedure DijkstraEra)
forall s a. s -> Getting a s a -> a
^. Getting
(OSet (ProposalProcedure DijkstraEra))
(TxBody DijkstraEra)
(OSet (ProposalProcedure DijkstraEra))
forall era.
ConwayEraTxBody era =>
Lens' (TxBody era) (OSet (ProposalProcedure era))
Lens' (TxBody 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 DijkstraEra
txBody TxBody DijkstraEra
-> Getting
(StrictMaybe Coin) (TxBody DijkstraEra) (StrictMaybe Coin)
-> StrictMaybe Coin
forall s a. s -> Getting a s a -> a
^. Getting (StrictMaybe Coin) (TxBody DijkstraEra) (StrictMaybe Coin)
forall era.
ConwayEraTxBody era =>
Lens' (TxBody era) (StrictMaybe Coin)
Lens' (TxBody DijkstraEra) (StrictMaybe Coin)
currentTreasuryValueTxBodyL
, txInfoTreasuryDonation :: Maybe Lovelace
PV3.txInfoTreasuryDonation =
case TxBody DijkstraEra
txBody TxBody DijkstraEra
-> Getting Coin (TxBody DijkstraEra) Coin -> Coin
forall s a. s -> Getting a s a -> a
^. Getting Coin (TxBody DijkstraEra) Coin
forall era. ConwayEraTxBody era => Lens' (TxBody era) Coin
Lens' (TxBody 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
}
where
txBody :: TxBody DijkstraEra
txBody = Tx DijkstraEra
ltiTx Tx DijkstraEra
-> Getting
(TxBody DijkstraEra) (Tx DijkstraEra) (TxBody DijkstraEra)
-> TxBody DijkstraEra
forall s a. s -> Getting a s a -> a
^. Getting (TxBody DijkstraEra) (Tx DijkstraEra) (TxBody DijkstraEra)
forall era. EraTx era => Lens' (Tx era) (TxBody era)
Lens' (Tx DijkstraEra) (TxBody DijkstraEra)
bodyTxL
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
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 :: ScriptInfo
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)
PlutusArgs 'PlutusV4
-> Either (ContextError era) (PlutusArgs 'PlutusV4)
forall a. a -> Either (ContextError era) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PlutusArgs 'PlutusV4
-> Either (ContextError era) (PlutusArgs 'PlutusV4))
-> PlutusArgs 'PlutusV4
-> Either (ContextError era) (PlutusArgs 'PlutusV4)
forall a b. (a -> b) -> a -> b
$
ScriptContext -> PlutusArgs 'PlutusV4
PlutusV4Args (ScriptContext -> PlutusArgs 'PlutusV4)
-> ScriptContext -> PlutusArgs 'PlutusV4
forall a b. (a -> b) -> a -> b
$
PV3.ScriptContext
{ scriptContextTxInfo :: TxInfo
PV3.scriptContextTxInfo = TxInfo
txInfo
, scriptContextRedeemer :: Redeemer
PV3.scriptContextRedeemer = Data era -> Redeemer
forall era. Data era -> Redeemer
Babbage.transRedeemer Data era
redeemerData
, scriptContextScriptInfo :: ScriptInfo
PV3.scriptContextScriptInfo = ScriptInfo
scriptInfo
}