Skip to content

Commit b8aa9dc

Browse files
committed
Propagate removal of type level tags SimpleScriptV1 and SimpleSccriptV2
in cardano-cli
1 parent fa38b7b commit b8aa9dc

File tree

6 files changed

+21
-39
lines changed

6 files changed

+21
-39
lines changed

cardano-api/ChangeLog.md

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

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

3032
### Bugs
3133

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

-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ import qualified Data.ByteString.Short as SBS
125125
import Data.Coerce
126126
import Data.Int (Int64)
127127
import Data.Map.Strict (Map)
128-
import Data.Maybe (maybeToList)
129128
import Data.Ratio (Ratio, (%))
130129
import Data.String
131130
import Data.Word (Word64)

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 <|>

cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs

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

21242124
pPlutusReferenceScriptWitness :: BalanceTxExecUnits -> Parser (ScriptWitnessFiles WitCtxTxIn)
@@ -2331,7 +2331,7 @@ pMintMultiAsset balanceExecUnits =
23312331
-> PolicyId
23322332
-> ScriptWitnessFiles WitCtxMint
23332333
createSimpleMintingReferenceScriptWitnessFiles refTxIn pid =
2334-
let simpleLang = AnyScriptLanguage (SimpleScriptLanguage SimpleScriptV2)
2334+
let simpleLang = AnyScriptLanguage SimpleScriptLanguage
23352335
in SimpleReferenceScriptWitnessFiles refTxIn simpleLang (Just pid)
23362336

23372337
pPlutusMintReferenceScriptWitnessFiles

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

+12-30
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,8 @@ readScriptWitness era' (SimpleScriptWitnessFile (ScriptFile scriptFile)) = do
226226
readFileScriptInAnyLang scriptFile
227227
ScriptInEra langInEra script' <- validateScriptSupportedInEra era' script
228228
case script' of
229-
SimpleScript version sscript ->
230-
return . SimpleScriptWitness
231-
langInEra version $ SScript sscript
229+
SimpleScript sscript ->
230+
return . SimpleScriptWitness langInEra $ SScript sscript
232231

233232
-- If the supplied cli flags were for a simple script (i.e. the user did
234233
-- not supply the datum, redeemer or ex units), but the script file turns
@@ -277,7 +276,7 @@ readScriptWitness era' (PlutusReferenceScriptWitnessFiles refTxIn
277276
case scriptLanguageSupportedInEra era' anyScriptLanguage of
278277
Just sLangInEra ->
279278
case languageOfScriptLanguageInEra sLangInEra of
280-
SimpleScriptLanguage _v ->
279+
SimpleScriptLanguage ->
281280
-- TODO: We likely need another datatype eg data ReferenceScriptWitness lang
282281
-- in order to make this branch unrepresentable.
283282
error "readScriptWitness: Should not be possible to specify a simple script"
@@ -302,8 +301,8 @@ readScriptWitness era' (SimpleReferenceScriptWitnessFiles refTxIn
302301
case scriptLanguageSupportedInEra era' anyScriptLanguage of
303302
Just sLangInEra ->
304303
case languageOfScriptLanguageInEra sLangInEra of
305-
SimpleScriptLanguage v ->
306-
return . SimpleScriptWitness sLangInEra v
304+
SimpleScriptLanguage ->
305+
return . SimpleScriptWitness sLangInEra
307306
$ SReferenceScript refTxIn (unPolicyId <$> mPid)
308307
PlutusScriptLanguage{} ->
309308
error "readScriptWitness: Should not be possible to specify a plutus script"
@@ -415,12 +414,11 @@ deserialiseScriptInAnyLang bs =
415414
--
416415
case deserialiseFromJSON AsTextEnvelope bs of
417416
Left _ ->
418-
-- The SimpleScript language has the property that it is backwards
419-
-- compatible, so we can parse as the latest version and then downgrade
420-
-- to the minimum version that has all the features actually used.
421-
case deserialiseFromJSON (AsSimpleScript AsSimpleScriptV2) bs of
422-
Left err -> Left (ScriptDecodeSimpleScriptError err)
423-
Right script -> Right (toMinimumSimpleScriptVersion script)
417+
-- In addition to the TextEnvelope format, we also try to
418+
-- deserialize the JSON representation of SimpleScripts.
419+
case Aeson.eitherDecodeStrict' bs of
420+
Left err -> Left (ScriptDecodeSimpleScriptError $ JsonDecodeError err)
421+
Right script -> Right $ ScriptInAnyLang SimpleScriptLanguage $ SimpleScript script
424422

425423
Right te ->
426424
case deserialiseFromTextEnvelopeAnyOf textEnvTypes te of
@@ -432,11 +430,8 @@ deserialiseScriptInAnyLang bs =
432430
-- script version.
433431
textEnvTypes :: [FromSomeType HasTextEnvelope ScriptInAnyLang]
434432
textEnvTypes =
435-
[ FromSomeType (AsScript AsSimpleScriptV1)
436-
(ScriptInAnyLang (SimpleScriptLanguage SimpleScriptV1))
437-
438-
, FromSomeType (AsScript AsSimpleScriptV2)
439-
(ScriptInAnyLang (SimpleScriptLanguage SimpleScriptV2))
433+
[ FromSomeType (AsScript AsSimpleScript)
434+
(ScriptInAnyLang SimpleScriptLanguage)
440435

441436
, FromSomeType (AsScript AsPlutusScriptV1)
442437
(ScriptInAnyLang (PlutusScriptLanguage PlutusScriptV1))
@@ -445,19 +440,6 @@ deserialiseScriptInAnyLang bs =
445440
(ScriptInAnyLang (PlutusScriptLanguage PlutusScriptV2))
446441
]
447442

448-
toMinimumSimpleScriptVersion :: SimpleScript SimpleScriptV2
449-
-> ScriptInAnyLang
450-
toMinimumSimpleScriptVersion s =
451-
-- TODO alonzo: this will need to be adjusted when more versions are added
452-
-- with appropriate helper functions it can probably be done in an
453-
-- era-generic style
454-
case adjustSimpleScriptVersion SimpleScriptV1 s of
455-
Nothing -> ScriptInAnyLang (SimpleScriptLanguage SimpleScriptV2)
456-
(SimpleScript SimpleScriptV2 s)
457-
Just s' -> ScriptInAnyLang (SimpleScriptLanguage SimpleScriptV1)
458-
(SimpleScript SimpleScriptV1 s')
459-
460-
461443
-- Tx & TxBody
462444

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

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)