@@ -226,9 +226,8 @@ readScriptWitness era' (SimpleScriptWitnessFile (ScriptFile scriptFile)) = do
226
226
readFileScriptInAnyLang scriptFile
227
227
ScriptInEra langInEra script' <- validateScriptSupportedInEra era' script
228
228
case script' of
229
- SimpleScript version sscript ->
230
- return . SimpleScriptWitness
231
- langInEra version $ SScript sscript
229
+ SimpleScript sscript ->
230
+ return . SimpleScriptWitness langInEra $ SScript sscript
232
231
233
232
-- If the supplied cli flags were for a simple script (i.e. the user did
234
233
-- not supply the datum, redeemer or ex units), but the script file turns
@@ -277,7 +276,7 @@ readScriptWitness era' (PlutusReferenceScriptWitnessFiles refTxIn
277
276
case scriptLanguageSupportedInEra era' anyScriptLanguage of
278
277
Just sLangInEra ->
279
278
case languageOfScriptLanguageInEra sLangInEra of
280
- SimpleScriptLanguage _v ->
279
+ SimpleScriptLanguage ->
281
280
-- TODO: We likely need another datatype eg data ReferenceScriptWitness lang
282
281
-- in order to make this branch unrepresentable.
283
282
error " readScriptWitness: Should not be possible to specify a simple script"
@@ -302,8 +301,8 @@ readScriptWitness era' (SimpleReferenceScriptWitnessFiles refTxIn
302
301
case scriptLanguageSupportedInEra era' anyScriptLanguage of
303
302
Just sLangInEra ->
304
303
case languageOfScriptLanguageInEra sLangInEra of
305
- SimpleScriptLanguage v ->
306
- return . SimpleScriptWitness sLangInEra v
304
+ SimpleScriptLanguage ->
305
+ return . SimpleScriptWitness sLangInEra
307
306
$ SReferenceScript refTxIn (unPolicyId <$> mPid)
308
307
PlutusScriptLanguage {} ->
309
308
error " readScriptWitness: Should not be possible to specify a plutus script"
@@ -415,12 +414,11 @@ deserialiseScriptInAnyLang bs =
415
414
--
416
415
case deserialiseFromJSON AsTextEnvelope bs of
417
416
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
424
422
425
423
Right te ->
426
424
case deserialiseFromTextEnvelopeAnyOf textEnvTypes te of
@@ -432,11 +430,8 @@ deserialiseScriptInAnyLang bs =
432
430
-- script version.
433
431
textEnvTypes :: [FromSomeType HasTextEnvelope ScriptInAnyLang ]
434
432
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 )
440
435
441
436
, FromSomeType (AsScript AsPlutusScriptV1 )
442
437
(ScriptInAnyLang (PlutusScriptLanguage PlutusScriptV1 ))
@@ -445,19 +440,6 @@ deserialiseScriptInAnyLang bs =
445
440
(ScriptInAnyLang (PlutusScriptLanguage PlutusScriptV2 ))
446
441
]
447
442
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
-
461
443
-- Tx & TxBody
462
444
463
445
newtype CddlTx = CddlTx { unCddlTx :: InAnyCardanoEra Tx } deriving (Show , Eq )
0 commit comments