Skip to content

Commit 0e5d91e

Browse files
committed
Propagate removal of type level tags SimpleScriptV1 and SimpleSccriptV2
in cardano-cli
1 parent fcd7409 commit 0e5d91e

File tree

6 files changed

+21
-39
lines changed

6 files changed

+21
-39
lines changed

Diff for: cardano-api/ChangeLog.md

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
- **Breaking change** - `queryExpr` to return `IO (Either UnsupportedNtcVersionError a)` instead of `IO a`.
2525
([PR4788](https://github.com/input-output-hk/cardano-node/pull/4788))
26+
27+
- **Breaking change** - Remove distinction between multisig and timelock scripts([PR4763](https://github.com/input-output-hk/cardano-node/pull/4763))
2628

2729
### Bugs
2830

Diff for: cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs

-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ import qualified Data.ByteString.Short as SBS
122122
import Data.Coerce
123123
import Data.Int (Int64)
124124
import Data.Map.Strict (Map)
125-
import Data.Maybe (maybeToList)
126125
import Data.Ratio (Ratio, (%))
127126
import Data.String
128127
import Data.Word (Word64)

Diff for: cardano-api/src/Cardano/Api/Script.hs

-1
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,6 @@ instance ToJSON SimpleScript where
11531153
instance FromJSON SimpleScript where
11541154
parseJSON = parseSimpleScript
11551155

1156-
-- TODO: Left off here. You need to comb through cardano-api's property tests concerning simple scripts
11571156
parseSimpleScript :: Value -> Aeson.Parser SimpleScript
11581157
parseSimpleScript v = parseScriptSig v <|>
11591158
parseScriptBefore v <|>

Diff for: cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2119,7 +2119,7 @@ pTxIn balance =
21192119
:: TxIn
21202120
-> ScriptWitnessFiles WitCtxTxIn
21212121
createSimpleReferenceScriptWitnessFiles refTxIn =
2122-
let simpleLang = AnyScriptLanguage (SimpleScriptLanguage SimpleScriptV2)
2122+
let simpleLang = AnyScriptLanguage SimpleScriptLanguage
21232123
in SimpleReferenceScriptWitnessFiles refTxIn simpleLang Nothing
21242124

21252125
pPlutusReferenceScriptWitness :: BalanceTxExecUnits -> Parser (ScriptWitnessFiles WitCtxTxIn)
@@ -2332,7 +2332,7 @@ pMintMultiAsset balanceExecUnits =
23322332
-> PolicyId
23332333
-> ScriptWitnessFiles WitCtxMint
23342334
createSimpleMintingReferenceScriptWitnessFiles refTxIn pid =
2335-
let simpleLang = AnyScriptLanguage (SimpleScriptLanguage SimpleScriptV2)
2335+
let simpleLang = AnyScriptLanguage SimpleScriptLanguage
23362336
in SimpleReferenceScriptWitnessFiles refTxIn simpleLang (Just pid)
23372337

23382338
pPlutusMintReferenceScriptWitnessFiles

Diff for: cardano-cli/src/Cardano/CLI/Shelley/Run/Read.hs

+12-30
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,8 @@ readScriptWitness era' (SimpleScriptWitnessFile (ScriptFile scriptFile)) = do
211211
readFileScriptInAnyLang scriptFile
212212
ScriptInEra langInEra script' <- validateScriptSupportedInEra era' script
213213
case script' of
214-
SimpleScript version sscript ->
215-
return . SimpleScriptWitness
216-
langInEra version $ SScript sscript
214+
SimpleScript sscript ->
215+
return . SimpleScriptWitness langInEra $ SScript sscript
217216

218217
-- If the supplied cli flags were for a simple script (i.e. the user did
219218
-- not supply the datum, redeemer or ex units), but the script file turns
@@ -262,7 +261,7 @@ readScriptWitness era' (PlutusReferenceScriptWitnessFiles refTxIn
262261
case scriptLanguageSupportedInEra era' anyScriptLanguage of
263262
Just sLangInEra ->
264263
case languageOfScriptLanguageInEra sLangInEra of
265-
SimpleScriptLanguage _v ->
264+
SimpleScriptLanguage ->
266265
-- TODO: We likely need another datatype eg data ReferenceScriptWitness lang
267266
-- in order to make this branch unrepresentable.
268267
error "readScriptWitness: Should not be possible to specify a simple script"
@@ -287,8 +286,8 @@ readScriptWitness era' (SimpleReferenceScriptWitnessFiles refTxIn
287286
case scriptLanguageSupportedInEra era' anyScriptLanguage of
288287
Just sLangInEra ->
289288
case languageOfScriptLanguageInEra sLangInEra of
290-
SimpleScriptLanguage v ->
291-
return . SimpleScriptWitness sLangInEra v
289+
SimpleScriptLanguage ->
290+
return . SimpleScriptWitness sLangInEra
292291
$ SReferenceScript refTxIn (unPolicyId <$> mPid)
293292
PlutusScriptLanguage{} ->
294293
error "readScriptWitness: Should not be possible to specify a plutus script"
@@ -399,12 +398,11 @@ deserialiseScriptInAnyLang bs =
399398
--
400399
case deserialiseFromJSON AsTextEnvelope bs of
401400
Left _ ->
402-
-- The SimpleScript language has the property that it is backwards
403-
-- compatible, so we can parse as the latest version and then downgrade
404-
-- to the minimum version that has all the features actually used.
405-
case deserialiseFromJSON (AsSimpleScript AsSimpleScriptV2) bs of
406-
Left err -> Left (ScriptDecodeSimpleScriptError err)
407-
Right script -> Right (toMinimumSimpleScriptVersion script)
401+
-- In addition to the TextEnvelope format, we also try to
402+
-- deserialize the JSON representation of SimpleScripts.
403+
case Aeson.eitherDecodeStrict' bs of
404+
Left err -> Left (ScriptDecodeSimpleScriptError $ JsonDecodeError err)
405+
Right script -> Right $ ScriptInAnyLang SimpleScriptLanguage $ SimpleScript script
408406

409407
Right te ->
410408
case deserialiseFromTextEnvelopeAnyOf textEnvTypes te of
@@ -416,11 +414,8 @@ deserialiseScriptInAnyLang bs =
416414
-- script version.
417415
textEnvTypes :: [FromSomeType HasTextEnvelope ScriptInAnyLang]
418416
textEnvTypes =
419-
[ FromSomeType (AsScript AsSimpleScriptV1)
420-
(ScriptInAnyLang (SimpleScriptLanguage SimpleScriptV1))
421-
422-
, FromSomeType (AsScript AsSimpleScriptV2)
423-
(ScriptInAnyLang (SimpleScriptLanguage SimpleScriptV2))
417+
[ FromSomeType (AsScript AsSimpleScript)
418+
(ScriptInAnyLang SimpleScriptLanguage)
424419

425420
, FromSomeType (AsScript AsPlutusScriptV1)
426421
(ScriptInAnyLang (PlutusScriptLanguage PlutusScriptV1))
@@ -429,19 +424,6 @@ deserialiseScriptInAnyLang bs =
429424
(ScriptInAnyLang (PlutusScriptLanguage PlutusScriptV2))
430425
]
431426

432-
toMinimumSimpleScriptVersion :: SimpleScript SimpleScriptV2
433-
-> ScriptInAnyLang
434-
toMinimumSimpleScriptVersion s =
435-
-- TODO alonzo: this will need to be adjusted when more versions are added
436-
-- with appropriate helper functions it can probably be done in an
437-
-- era-generic style
438-
case adjustSimpleScriptVersion SimpleScriptV1 s of
439-
Nothing -> ScriptInAnyLang (SimpleScriptLanguage SimpleScriptV2)
440-
(SimpleScript SimpleScriptV2 s)
441-
Just s' -> ScriptInAnyLang (SimpleScriptLanguage SimpleScriptV1)
442-
(SimpleScript SimpleScriptV1 s')
443-
444-
445427
-- Tx & TxBody
446428

447429
newtype CddlTx = CddlTx {unCddlTx :: InAnyCardanoEra Tx} deriving (Show, Eq)

Diff for: cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs

+5-5
Original file line numberDiff line numberDiff line change
@@ -883,8 +883,8 @@ getAllReferenceInputs txins mintWitnesses certFiles withdrawals readOnlyRefIns =
883883
case sWit of
884884
PlutusScriptWitness _ _ (PReferenceScript refIn _) _ _ _ -> Just refIn
885885
PlutusScriptWitness _ _ PScript{} _ _ _ -> Nothing
886-
SimpleScriptWitness _ _ (SReferenceScript refIn _) -> Just refIn
887-
SimpleScriptWitness _ _ SScript{} -> Nothing
886+
SimpleScriptWitness _ (SReferenceScript refIn _) -> Just refIn
887+
SimpleScriptWitness _ SScript{} -> Nothing
888888

889889
toAddressInAnyEra
890890
:: CardanoEra era
@@ -1037,9 +1037,9 @@ createTxMintValue era (val, scriptWitnesses) =
10371037
witnessesExtra = Set.elems (witnessesProvided Set.\\ witnessesNeeded)
10381038

10391039
scriptWitnessPolicyId :: ScriptWitness witctx era -> Maybe PolicyId
1040-
scriptWitnessPolicyId (SimpleScriptWitness _ version (SScript script)) =
1041-
Just . scriptPolicyId $ SimpleScript version script
1042-
scriptWitnessPolicyId (SimpleScriptWitness _ _ (SReferenceScript _ mPid)) =
1040+
scriptWitnessPolicyId (SimpleScriptWitness _ (SScript script)) =
1041+
Just . scriptPolicyId $ SimpleScript script
1042+
scriptWitnessPolicyId (SimpleScriptWitness _ (SReferenceScript _ mPid)) =
10431043
PolicyId <$> mPid
10441044
scriptWitnessPolicyId (PlutusScriptWitness _ version (PScript script) _ _ _) =
10451045
Just . scriptPolicyId $ PlutusScript version script

0 commit comments

Comments
 (0)