Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
description: |
Simple scripts read from JSON files now work in the Dijkstra era, instead of aborting with an internal TODO error.
kind:
- feature
pr: 1427
project: cardano-cli
19 changes: 11 additions & 8 deletions cardano-cli/src/Cardano/CLI/EraBased/Script/Read/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import Cardano.CLI.Read (readFileCli)
import Cardano.CLI.Type.Common
import Cardano.CLI.Type.Error.ScriptDataError
import Cardano.Ledger.Core qualified as L
import Cardano.Ledger.Dijkstra.Scripts qualified as Dijkstra

import Prelude

Expand All @@ -38,14 +39,16 @@ readFileSimpleScript
readFileSimpleScript file era = do
bs <- readFileCli file
case deserialiseFromJSON bs of
Left _ -> case era of
Exp.DijkstraEra -> error "TODO Dijkstra: Simple script not supported"
Exp.ConwayEra -> Exp.obtainConwayConstraints era $ do
-- In addition to the TextEnvelope format, we also try to
-- deserialize the JSON representation of SimpleScripts..
script :: SimpleScript <- fromEitherCli $ Aeson.eitherDecodeStrict' bs
let s :: L.NativeScript (Exp.LedgerEra era) = obtainCommonConstraints era $ toAllegraTimelock script
return $ Exp.SimpleScript s
Left _ -> do
-- In addition to the TextEnvelope format, we also try to
-- deserialize the JSON representation of SimpleScripts.
script :: SimpleScript <- fromEitherCli $ Aeson.eitherDecodeStrict' bs
let conwayTimelock :: L.NativeScript (Exp.LedgerEra Exp.ConwayEra)
conwayTimelock = toAllegraTimelock script
Exp.obtainCommonConstraints era $
pure . Exp.SimpleScript $ case era of
Exp.DijkstraEra -> Dijkstra.upgradeTimelock conwayTimelock
Exp.ConwayEra -> conwayTimelock
Right te -> do
let scriptBs = teRawCBOR te
obtainCommonConstraints era $
Expand Down
Loading