Skip to content

Commit 913c867

Browse files
authored
SCP-2771: Plutus V2 interface (IntersectMBO#3952)
* Init v2 * Use AssocMap in V2 TxInfo * Include redeemers in V2 TxInfo * Transfer over functions that need to operate on the new context types * Fix nix
1 parent 715f21d commit 913c867

File tree

8 files changed

+395
-1
lines changed

8 files changed

+395
-1
lines changed

nix/pkgs/haskell/materialized-darwin/.plan.nix/plutus-ledger-api.nix

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nix/pkgs/haskell/materialized-linux/.plan.nix/plutus-ledger-api.nix

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nix/pkgs/haskell/materialized-windows/.plan.nix/plutus-ledger-api.nix

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plutus-ledger-api/plutus-ledger-api.cabal

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ library
3737
Data.Aeson.Extras
3838
Data.Either.Extras
3939
Data.Text.Prettyprint.Doc.Extras
40+
4041
Plutus.V1.Ledger.Address
4142
Plutus.V1.Ledger.Ada
4243
Plutus.V1.Ledger.Api
@@ -54,6 +55,9 @@ library
5455
Plutus.V1.Ledger.TxId
5556
Plutus.V1.Ledger.Time
5657
Plutus.V1.Ledger.Value
58+
59+
Plutus.V2.Ledger.Api
60+
Plutus.V2.Ledger.Contexts
5761
build-depends:
5862
base >=4.9 && <5,
5963
aeson -any,

plutus-ledger-api/src/Plutus/V1/Ledger/Scripts.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ instance BA.ByteArrayAccess Datum where
275275
-- | 'Redeemer' is a wrapper around 'Data' values that are used as redeemers in transaction inputs.
276276
newtype Redeemer = Redeemer { getRedeemer :: BuiltinData }
277277
deriving stock (Generic, Haskell.Show)
278-
deriving newtype (Haskell.Eq, Haskell.Ord, Eq)
278+
deriving newtype (Haskell.Eq, Haskell.Ord, Eq, ToData, FromData, UnsafeFromData)
279279
deriving (ToJSON, FromJSON, Serialise, NFData, Pretty) via PLC.Data
280280

281281
instance BA.ByteArrayAccess Redeemer where
@@ -439,3 +439,5 @@ makeLift ''DatumHash
439439
makeLift ''RedeemerHash
440440

441441
makeLift ''Datum
442+
443+
makeLift ''Redeemer
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
{-# LANGUAGE DerivingStrategies #-}
2+
{-# LANGUAGE OverloadedStrings #-}
3+
{-# LANGUAGE TypeApplications #-}
4+
{- |
5+
The interface to Plutus V2 for the ledger.
6+
-}
7+
module Plutus.V2.Ledger.Api (
8+
-- * Scripts
9+
SerializedScript
10+
, Script
11+
, fromCompiledCode
12+
-- * Validating scripts
13+
, validateScript
14+
-- * Running scripts
15+
, evaluateScriptRestricting
16+
, evaluateScriptCounting
17+
-- ** Verbose mode and log output
18+
, VerboseMode (..)
19+
, LogOutput
20+
-- * Serialising scripts
21+
, plutusScriptEnvelopeType
22+
, plutusDatumEnvelopeType
23+
, plutusRedeemerEnvelopeType
24+
-- * Costing-related types
25+
, ExBudget (..)
26+
, ExCPU (..)
27+
, ExMemory (..)
28+
, SatInt
29+
-- ** Cost model
30+
, validateCostModelParams
31+
, defaultCostModelParams
32+
, CostModelParams
33+
-- * Context types
34+
, ScriptContext(..)
35+
, ScriptPurpose(..)
36+
-- ** Supporting types used in the context types
37+
-- *** ByteStrings
38+
, BuiltinByteString
39+
, toBuiltin
40+
, fromBuiltin
41+
-- *** Bytes
42+
, LedgerBytes (..)
43+
, fromBytes
44+
-- *** Certificates
45+
, DCert(..)
46+
-- *** Credentials
47+
, StakingCredential(..)
48+
, Credential(..)
49+
-- *** Value
50+
, Value (..)
51+
, CurrencySymbol (..)
52+
, TokenName (..)
53+
, singleton
54+
, unionWith
55+
, adaSymbol
56+
, adaToken
57+
-- *** Time
58+
, POSIXTime (..)
59+
, POSIXTimeRange
60+
-- *** Types for representing transactions
61+
, Address (..)
62+
, PubKeyHash (..)
63+
, TxId (..)
64+
, TxInfo (..)
65+
, TxOut(..)
66+
, TxOutRef(..)
67+
, TxInInfo(..)
68+
-- *** Intervals
69+
, Interval (..)
70+
, Extended (..)
71+
, Closure
72+
, UpperBound (..)
73+
, LowerBound (..)
74+
, always
75+
, from
76+
, to
77+
, lowerBound
78+
, upperBound
79+
, strictLowerBound
80+
, strictUpperBound
81+
-- *** Newtypes for script/datum types and hash types
82+
, Validator (..)
83+
, mkValidatorScript
84+
, unValidatorScript
85+
, ValidatorHash (..)
86+
, MintingPolicy (..)
87+
, mkMintingPolicyScript
88+
, unMintingPolicyScript
89+
, MintingPolicyHash (..)
90+
, StakeValidator (..)
91+
, mkStakeValidatorScript
92+
, unStakeValidatorScript
93+
, StakeValidatorHash (..)
94+
, Redeemer (..)
95+
, RedeemerHash (..)
96+
, Datum (..)
97+
, DatumHash (..)
98+
-- * Data
99+
, Data (..)
100+
, BuiltinData (..)
101+
, ToData (..)
102+
, FromData (..)
103+
, UnsafeFromData (..)
104+
, toData
105+
, fromData
106+
, dataToBuiltinData
107+
, builtinDataToData
108+
-- * Errors
109+
, EvaluationError (..)
110+
) where
111+
112+
import Data.Text (Text)
113+
114+
import Plutus.V1.Ledger.Api hiding (ScriptContext (..), TxInfo (..), plutusScriptEnvelopeType)
115+
import Plutus.V2.Ledger.Contexts
116+
117+
plutusScriptEnvelopeType :: Text
118+
plutusScriptEnvelopeType = "PlutusV2Script"

0 commit comments

Comments
 (0)