Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PlutusV2 -> PlutusV3 #1523

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions hydra-cardano-api/src/Hydra/Cardano/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
-- also get rid of era witnesses.
--
-- NOTE: This module also uses the **latest plutus version** available
-- (currently 'PlutusScriptV2'). So make sure that you give it a plutus script
-- (currently 'PlutusScriptV3'). So make sure that you give it a plutus script
-- of the right version (e.g. when compiling and serializing plutus-tx).
module Hydra.Cardano.Api (
-- * Common type-alias
Expand Down Expand Up @@ -230,7 +230,7 @@ pattern ShelleyKeyWitness{shelleyKeyWitness} <-

-- ** PlutusScript

type PlutusScript = Cardano.Api.PlutusScript PlutusScriptV2
type PlutusScript = Cardano.Api.PlutusScript PlutusScriptV3
{-# COMPLETE PlutusScriptSerialised #-}

pattern PlutusScriptSerialised :: ShortByteString -> PlutusScript
Expand All @@ -242,31 +242,31 @@ pattern PlutusScriptSerialised{plutusScriptSerialised} <-

-- ** Script

type Script = Cardano.Api.Script PlutusScriptV2
type Script = Cardano.Api.Script PlutusScriptV3
{-# COMPLETE PlutusScript #-}

pattern PlutusScript :: PlutusScript -> Script
pattern PlutusScript{plutusScript} <-
Cardano.Api.Shelley.PlutusScript _ plutusScript
where
PlutusScript =
Cardano.Api.Shelley.PlutusScript PlutusScriptV2
Cardano.Api.Shelley.PlutusScript PlutusScriptV3

-- ** ScriptInEra

type ScriptInEra = Cardano.Api.ScriptInEra Era

-- ** ScriptLanguage

type ScriptLanguage = Cardano.Api.ScriptLanguage PlutusScriptV2
type ScriptLanguage = Cardano.Api.ScriptLanguage PlutusScriptV3
{-# COMPLETE PlutusScriptLanguage #-}

pattern PlutusScriptLanguage :: ScriptLanguage
pattern PlutusScriptLanguage <-
Cardano.Api.Shelley.PlutusScriptLanguage _
where
PlutusScriptLanguage =
Cardano.Api.Shelley.PlutusScriptLanguage PlutusScriptV2
Cardano.Api.Shelley.PlutusScriptLanguage PlutusScriptV3

-- ** ScriptWitness

Expand All @@ -287,7 +287,7 @@ pattern PlutusScriptWitness
} <-
Cardano.Api.PlutusScriptWitness
_
PlutusScriptV2
PlutusScriptV3
(PScript plutusScriptWitnessScript)
plutusScriptWitnessDatum
plutusScriptWitnessRedeemer
Expand All @@ -296,7 +296,7 @@ pattern PlutusScriptWitness
PlutusScriptWitness =
Cardano.Api.PlutusScriptWitness
scriptLanguageInEra
PlutusScriptV2
PlutusScriptV3
. PScript

-- ** Tx
Expand Down
4 changes: 2 additions & 2 deletions hydra-cardano-api/src/Hydra/Cardano/Api/AddressInEra.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import Cardano.Ledger.Credential qualified as Ledger
import Cardano.Ledger.Hashes qualified as Ledger
import Cardano.Ledger.Keys qualified as Ledger
import Hydra.Cardano.Api.Network (Network)
import PlutusLedgerApi.V2 (
import PlutusLedgerApi.V3 (
Address (..),
Credential (..),
StakingCredential (StakingHash, StakingPtr),
fromBuiltin,
)
import PlutusLedgerApi.V2 qualified as Plutus
import PlutusLedgerApi.V3 qualified as Plutus

-- * Extras

Expand Down
2 changes: 1 addition & 1 deletion hydra-cardano-api/src/Hydra/Cardano/Api/Hash.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Cardano.Ledger.Plutus.TxInfo (transKeyHash)
import Cardano.Ledger.SafeHash (unsafeMakeSafeHash)
import Cardano.Ledger.Shelley.Scripts qualified as Ledger
import Data.ByteString qualified as BS
import PlutusLedgerApi.V2 qualified as Plutus
import PlutusLedgerApi.V3 qualified as Plutus

-- * Type conversions

Expand Down
2 changes: 1 addition & 1 deletion hydra-cardano-api/src/Hydra/Cardano/Api/PolicyId.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Cardano.Ledger.Alonzo.Plutus.TxInfo qualified as Ledger
import Cardano.Ledger.Hashes qualified as Ledger
import Cardano.Ledger.Mary.Value qualified as Ledger
import Hydra.Cardano.Api.ScriptHash ()
import PlutusLedgerApi.V2 (CurrencySymbol, fromBuiltin, unCurrencySymbol)
import PlutusLedgerApi.V3 (CurrencySymbol, fromBuiltin, unCurrencySymbol)

-- * Orphans

Expand Down
2 changes: 1 addition & 1 deletion hydra-cardano-api/src/Hydra/Cardano/Api/ReferenceScript.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Hydra.Cardano.Api.ReferenceScript where
import Hydra.Cardano.Api.Prelude

import Hydra.Cardano.Api.PlutusScript (fromPlutusScript)
import PlutusLedgerApi.V2 qualified as Plutus
import PlutusLedgerApi.V3 qualified as Plutus

-- | Construct a 'ReferenceScript' from any given Plutus script.
--
Expand Down
2 changes: 1 addition & 1 deletion hydra-cardano-api/src/Hydra/Cardano/Api/ScriptData.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Data.Aeson (Value (String), withText)
import Data.ByteString qualified as BS
import Data.ByteString.Base16 qualified as Base16
import Data.Map qualified as Map
import PlutusLedgerApi.V2 qualified as Plutus
import PlutusLedgerApi.V3 qualified as Plutus
import Test.QuickCheck (arbitrarySizedNatural, choose, oneof, scale, sized, vector)

-- * Extras
Expand Down
2 changes: 1 addition & 1 deletion hydra-cardano-api/src/Hydra/Cardano/Api/TxBody.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Data.Map qualified as Map
import Hydra.Cardano.Api.PlutusScript (fromLedgerScript)
import Hydra.Cardano.Api.PolicyId (toLedgerPolicyID, toLedgerScriptHash)
import Hydra.Cardano.Api.TxIn (toLedgerTxIn)
import PlutusLedgerApi.V2 qualified as Plutus
import PlutusLedgerApi.V3 qualified as Plutus

-- | Find and deserialise from 'ScriptData', a redeemer from the transaction
-- associated to the given input.
Expand Down
11 changes: 8 additions & 3 deletions hydra-cardano-api/src/Hydra/Cardano/Api/TxIn.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ module Hydra.Cardano.Api.TxIn where

import Hydra.Cardano.Api.Prelude

import Cardano.Ledger.BaseTypes (txIxToInt)
import Cardano.Ledger.BaseTypes qualified as Ledger
import Cardano.Ledger.Binary qualified as Ledger
import Cardano.Ledger.Plutus (transTxIn)
import Cardano.Ledger.Plutus (transSafeHash)
import Cardano.Ledger.TxIn qualified as Ledger
import Data.ByteString qualified as BS
import Data.Set qualified as Set
import PlutusLedgerApi.V2 qualified as Plutus
import PlutusLedgerApi.V3 qualified as Plutus
import Test.QuickCheck (choose, vectorOf)

-- * Extras
Expand Down Expand Up @@ -54,7 +55,11 @@ fromPlutusTxOutRef (Plutus.TxOutRef (Plutus.TxId bytes) ix) =

-- | Convert a cardano-api 'TxIn' into a plutus 'TxOutRef'.
toPlutusTxOutRef :: TxIn -> Plutus.TxOutRef
toPlutusTxOutRef = transTxIn . toLedgerTxIn
toPlutusTxOutRef txIn =
-- XXX: The upstream 'transTxIn' works only with the the PlutusV1 type, so we
-- needed to vendor its definition here.
let (Ledger.TxIn (Ledger.TxId safe) txIx) = toLedgerTxIn txIn
in Plutus.TxOutRef (Plutus.TxId $ transSafeHash safe) (toInteger $ txIxToInt txIx)

-- * Arbitrary values

Expand Down
4 changes: 2 additions & 2 deletions hydra-cardano-api/src/Hydra/Cardano/Api/TxOut.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import Hydra.Cardano.Api.Hash (unsafeScriptDataHashFromBytes)
import Hydra.Cardano.Api.Network (Network)
import Hydra.Cardano.Api.ScriptData (toScriptData)
import Hydra.Cardano.Api.Value (fromPlutusValue, minUTxOValue)
import PlutusLedgerApi.V2 (OutputDatum (..), fromBuiltin)
import PlutusLedgerApi.V2 qualified as Plutus
import PlutusLedgerApi.V3 (OutputDatum (..), fromBuiltin)
import PlutusLedgerApi.V3 qualified as Plutus

-- * Extras

Expand Down
4 changes: 2 additions & 2 deletions hydra-cardano-api/src/Hydra/Cardano/Api/Value.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import Data.Word (Word64)
import Hydra.Cardano.Api.CtxUTxO (ToUTxOContext (..))
import Hydra.Cardano.Api.PolicyId (fromPlutusCurrencySymbol)
import PlutusLedgerApi.V1.Value (flattenValue)
import PlutusLedgerApi.V2 (adaSymbol, adaToken, fromBuiltin, unTokenName)
import PlutusLedgerApi.V2 qualified as Plutus
import PlutusLedgerApi.V3 (adaSymbol, adaToken, fromBuiltin, unTokenName)
import PlutusLedgerApi.V3 qualified as Plutus

-- * Extras

Expand Down
Loading
Loading