From de3f8bf3cd79e2f00a3a3d72e771e396e3b6ed4c Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Tue, 27 Sep 2022 12:27:40 +0100 Subject: [PATCH] Update error message for incorrectly witnessed collateral inputs --- cardano-api/src/Cardano/Api.hs | 2 +- .../src/Cardano/Api/Convenience/Construction.hs | 16 +++++++++------- .../src/Cardano/CLI/Shelley/Run/Transaction.hs | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/cardano-api/src/Cardano/Api.hs b/cardano-api/src/Cardano/Api.hs index 00d26e94462..243eba3a1e1 100644 --- a/cardano-api/src/Cardano/Api.hs +++ b/cardano-api/src/Cardano/Api.hs @@ -694,7 +694,7 @@ module Cardano.Api ( getIsCardanoEraConstraint, -- ** Misc - NotScriptLockedTxInsError(..), + ScriptLockedTxInsError(..), TxInsExistError(..), renderNotScriptLockedTxInsError, renderTxInsExistError, diff --git a/cardano-api/src/Cardano/Api/Convenience/Construction.hs b/cardano-api/src/Cardano/Api/Convenience/Construction.hs index dd47898a817..6c815e9b275 100644 --- a/cardano-api/src/Cardano/Api/Convenience/Construction.hs +++ b/cardano-api/src/Cardano/Api/Convenience/Construction.hs @@ -5,7 +5,7 @@ module Cardano.Api.Convenience.Construction ( -- * Misc TxInsExistError(..), - NotScriptLockedTxInsError(..), + ScriptLockedTxInsError(..), notScriptLockedTxIns, renderNotScriptLockedTxInsError, renderTxInsExistError, @@ -84,19 +84,21 @@ txInsExistInUTxO ins (UTxO utxo) then return () else Left . TxInsDoNotExist $ ins List.\\ occursInUtxo -newtype NotScriptLockedTxInsError = NotScriptLockedTxIns [TxIn] +newtype ScriptLockedTxInsError = ScriptLockedTxIns [TxIn] -renderNotScriptLockedTxInsError :: NotScriptLockedTxInsError -> Text -renderNotScriptLockedTxInsError (NotScriptLockedTxIns txins) = - "The followings tx inputs are not script locked: " <> textShow (map renderTxIn txins) +-- Fix script locked error +renderNotScriptLockedTxInsError :: ScriptLockedTxInsError -> Text +renderNotScriptLockedTxInsError (ScriptLockedTxIns txins) = + "The followings tx inputs were expected to be key witnessed but are actually script witnessed: " <> + textShow (map renderTxIn txins) -notScriptLockedTxIns :: [TxIn] -> UTxO era -> Either NotScriptLockedTxInsError () +notScriptLockedTxIns :: [TxIn] -> UTxO era -> Either ScriptLockedTxInsError () notScriptLockedTxIns collTxIns (UTxO utxo) = do let onlyCollateralUTxOs = Map.restrictKeys utxo $ Set.fromList collTxIns scriptLockedTxIns = filter (\(_, TxOut aInEra _ _ _) -> not $ isKeyAddress aInEra ) $ Map.assocs onlyCollateralUTxOs if null scriptLockedTxIns then return () - else Left . NotScriptLockedTxIns $ map fst scriptLockedTxIns + else Left . ScriptLockedTxIns $ map fst scriptLockedTxIns diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs b/cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs index 33adb99ead5..d3f8832e784 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs @@ -110,7 +110,7 @@ data ShelleyTxCmdError | ShelleyTxCmdPParamExecutionUnitsNotAvailable | ShelleyTxCmdTxEraCastErr EraCastError | ShelleyTxCmdQueryConvenienceError !QueryConvenienceError - | ShelleyTxCmdQueryNotScriptLocked !NotScriptLockedTxInsError + | ShelleyTxCmdQueryNotScriptLocked !ScriptLockedTxInsError renderShelleyTxCmdError :: ShelleyTxCmdError -> Text renderShelleyTxCmdError err =