Skip to content

Commit 43ea07d

Browse files
authored
Merge pull request #1427 from IntersectMBO/support-dijkstra-simple-scripts
Support Dijkstra simple scripts read from JSON
2 parents ae17805 + f8281e5 commit 43ea07d

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
description: |
2+
Simple scripts read from JSON files now work in the Dijkstra era, instead of aborting with an internal TODO error.
3+
kind:
4+
- feature
5+
pr: 1427
6+
project: cardano-cli

cardano-cli/src/Cardano/CLI/EraBased/Script/Read/Common.hs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import Cardano.CLI.Read (readFileCli)
2121
import Cardano.CLI.Type.Common
2222
import Cardano.CLI.Type.Error.ScriptDataError
2323
import Cardano.Ledger.Core qualified as L
24+
import Cardano.Ledger.Dijkstra.Scripts qualified as Dijkstra
2425

2526
import Prelude
2627

@@ -38,14 +39,16 @@ readFileSimpleScript
3839
readFileSimpleScript file era = do
3940
bs <- readFileCli file
4041
case deserialiseFromJSON bs of
41-
Left _ -> case era of
42-
Exp.DijkstraEra -> error "TODO Dijkstra: Simple script not supported"
43-
Exp.ConwayEra -> Exp.obtainConwayConstraints era $ do
44-
-- In addition to the TextEnvelope format, we also try to
45-
-- deserialize the JSON representation of SimpleScripts..
46-
script :: SimpleScript <- fromEitherCli $ Aeson.eitherDecodeStrict' bs
47-
let s :: L.NativeScript (Exp.LedgerEra era) = obtainCommonConstraints era $ toAllegraTimelock script
48-
return $ Exp.SimpleScript s
42+
Left _ -> do
43+
-- In addition to the TextEnvelope format, we also try to
44+
-- deserialize the JSON representation of SimpleScripts.
45+
script :: SimpleScript <- fromEitherCli $ Aeson.eitherDecodeStrict' bs
46+
let conwayTimelock :: L.NativeScript (Exp.LedgerEra Exp.ConwayEra)
47+
conwayTimelock = toAllegraTimelock script
48+
Exp.obtainCommonConstraints era $
49+
pure . Exp.SimpleScript $ case era of
50+
Exp.DijkstraEra -> Dijkstra.upgradeTimelock conwayTimelock
51+
Exp.ConwayEra -> conwayTimelock
4952
Right te -> do
5053
let scriptBs = teRawCBOR te
5154
obtainCommonConstraints era $

0 commit comments

Comments
 (0)