Skip to content

Commit

Permalink
Merge pull request #4484 from input-output-hk/jordan/4479-bug
Browse files Browse the repository at this point in the history
Update error message for incorrectly witnessed collateral inputs
  • Loading branch information
Jimbo4350 committed Oct 4, 2022
1 parent f9efd0a commit d0108de
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cardano-api/src/Cardano/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ module Cardano.Api (
getIsCardanoEraConstraint,

-- ** Misc
NotScriptLockedTxInsError(..),
ScriptLockedTxInsError(..),
TxInsExistError(..),
renderNotScriptLockedTxInsError,
renderTxInsExistError,
Expand Down
15 changes: 8 additions & 7 deletions cardano-api/src/Cardano/Api/Convenience/Construction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Cardano.Api.Convenience.Construction (

-- * Misc
TxInsExistError(..),
NotScriptLockedTxInsError(..),
ScriptLockedTxInsError(..),
notScriptLockedTxIns,
renderNotScriptLockedTxInsError,
renderTxInsExistError,
Expand Down Expand Up @@ -84,19 +84,20 @@ 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)
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


2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ data ShelleyTxCmdError
| ShelleyTxCmdPParamExecutionUnitsNotAvailable
| ShelleyTxCmdTxEraCastErr EraCastError
| ShelleyTxCmdQueryConvenienceError !QueryConvenienceError
| ShelleyTxCmdQueryNotScriptLocked !NotScriptLockedTxInsError
| ShelleyTxCmdQueryNotScriptLocked !ScriptLockedTxInsError

renderShelleyTxCmdError :: ShelleyTxCmdError -> Text
renderShelleyTxCmdError err =
Expand Down

0 comments on commit d0108de

Please sign in to comment.