Skip to content

Commit 11fb035

Browse files
committed
Add poisoned ToPlutusData instances for Nonce and CoinPerWord
since they are not translated to Plutus, yet we would like to handle the parameters uniformly
1 parent b843423 commit 11fb035

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

eras/alonzo/impl/src/Cardano/Ledger/Alonzo/PParams.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ import Cardano.Ledger.Plutus.ExUnits (
104104
zipSemiExUnits,
105105
)
106106
import Cardano.Ledger.Plutus.Language (Language (..))
107+
import Cardano.Ledger.Plutus.ToPlutusData (ToPlutusData (..))
107108
import Cardano.Ledger.Shelley.PParams
108109
import Control.DeepSeq (NFData)
109110
import Data.Aeson as Aeson (
@@ -391,6 +392,10 @@ newtype CoinPerWord = CoinPerWord {unCoinPerWord :: Coin}
391392
deriving stock (Eq, Ord)
392393
deriving newtype (EncCBOR, DecCBOR, ToJSON, FromJSON, NFData, NoThunks, Show)
393394

395+
instance ToPlutusData CoinPerWord where
396+
toPlutusData = error "unsupported"
397+
fromPlutusData = error "unsupported"
398+
394399
-- | This is a helper type that allows us to define an `Ord` instance for executions units
395400
-- without affecting the `ExUnits` type. This is needed in order to derive an `Ord` instance`
396401
-- for PParams. This is just a helper type and should not be used directly. Both lenses

libs/cardano-ledger-core/src/Cardano/Ledger/Plutus/ToPlutusData.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import Cardano.Ledger.BaseTypes (
1212
HasZero,
1313
NonNegativeInterval,
1414
NonZero (..),
15+
Nonce,
1516
ProtVer (..),
1617
UnitInterval,
1718
nonZero,
@@ -135,3 +136,7 @@ instance ToPlutusData Word where
135136
instance (ToPlutusData a, HasZero a) => ToPlutusData (NonZero a) where
136137
toPlutusData = toPlutusData . unNonZero
137138
fromPlutusData x = nonZero =<< fromPlutusData x
139+
140+
instance ToPlutusData Nonce where
141+
toPlutusData = error "unsupported"
142+
fromPlutusData = error "unsupported"

0 commit comments

Comments
 (0)