Skip to content

Commit

Permalink
Update MissingScript error in evaluateTransactionExecutionUnits
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimbo4350 committed Feb 10, 2022
1 parent 333c701 commit 3668481
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions cardano-api/src/Cardano/Api/Fees.hs
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,9 @@ data ScriptExecutionError =
-- with a script witness.
| ScriptErrorNotPlutusWitnessedTxIn ScriptWitnessIndex

-- | A RdmrPtr points to a script that does not exist.
| ScriptErrorMissingScript Alonzo.RdmrPtr

-- | A cost model was missing for a language which was used.
| ScriptErrorMissingCostModel Alonzo.Language
deriving Show
Expand Down Expand Up @@ -402,6 +405,10 @@ instance Error ScriptExecutionError where
renderScriptWitnessIndex scriptWitness <> " is not a Plutus script \
\witnessed tx input and cannot be spent using a Plutus script witness."

displayError (ScriptErrorMissingScript rdmrPtr) =
"The redeemer pointer: " <> show rdmrPtr <> " points to a script \
\that does not exist."

displayError (ScriptErrorMissingCostModel language) =
"No cost model was found for language " <> show language

Expand Down Expand Up @@ -548,14 +555,12 @@ evaluateTransactionExecutionUnits _eraInMode systemstart history pparams utxo tx
-- script witness.
Alonzo.RedeemerNotNeeded rdmrPtr ->
ScriptErrorNotPlutusWitnessedTxIn $ fromAlonzoRdmrPtr rdmrPtr
-- Some of the errors are impossible by construction, given the way we
-- build transactions in the API:
Alonzo.MissingScript rdmrPtr ->
impossible ("MissingScript " ++ show (fromAlonzoRdmrPtr rdmrPtr))
Alonzo.NoCostModel l -> ScriptErrorMissingCostModel l
-- This should not occur while using cardano-cli because we zip together
-- the Plutus script and the use site (txin, certificate etc). Therefore
-- the redeemer pointer will always point to a Plutus script.
Alonzo.MissingScript rdmrPtr -> ScriptErrorMissingScript rdmrPtr

impossible detail = error $ "evaluateTransactionExecutionUnits: "
++ "the impossible happened: " ++ detail
Alonzo.NoCostModel l -> ScriptErrorMissingCostModel l


-- ----------------------------------------------------------------------------
Expand Down

0 comments on commit 3668481

Please sign in to comment.