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

Implement POC of same number of argumetns for PlutusV3 #4271

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import Cardano.Ledger.BaseTypes (ProtVer (pvMajor), kindObject, natVersion)
import Cardano.Ledger.Binary (DecCBOR (..), EncCBOR (..))
import Cardano.Ledger.Binary.Coders
import Cardano.Ledger.Plutus.CostModels (costModelsValid)
import Cardano.Ledger.Plutus.Data (getPlutusData)
import Cardano.Ledger.Plutus.Data (fromMaybeData, getPlutusData)
import Cardano.Ledger.Plutus.Evaluate (
PlutusDatums (..),
PlutusWithContext (..),
Expand Down Expand Up @@ -187,7 +187,9 @@ collectPlutusScriptsWithContext epochInfo sysStart pp tx utxo =
case mkPlutusScriptContext plutusScript plutusPurpose pp epochInfo sysStart utxo tx of
Right scriptContext ->
let spendingDatum = getSpendingDatum utxo tx $ hoistPlutusPurpose toAsItem plutusPurpose
datums = maybe id (:) spendingDatum [d, scriptContext]
datums
| protVerMajor < natVersion @9 = maybe id (:) spendingDatum [d, scriptContext]
| otherwise = [fromMaybeData spendingDatum, d, scriptContext]
in Right $
withPlutusScript plutusScript $ \plutus ->
PlutusWithContext
Expand Down
7 changes: 7 additions & 0 deletions libs/cardano-ledger-core/src/Cardano/Ledger/Plutus/Data.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module Cardano.Ledger.Plutus.Data (
PlutusData (..),
Data (Data),
unData,
fromMaybeData,
DataHash,
upgradeData,
hashData,
Expand Down Expand Up @@ -104,6 +105,12 @@ newtype Data era = DataConstr (MemoBytes PlutusData era)
deriving (Eq, Generic)
deriving newtype (SafeToHash, ToCBOR, NFData)

-- | Convert Maybe data to a List
fromMaybeData :: Era era => Maybe (Data era) -> Data era
fromMaybeData = \case
Nothing -> Data (PV1.List [])
Just (Data d) -> Data (PV1.List [d])

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

Expand Down
Loading