diff --git a/cardano-api/ChangeLog.md b/cardano-api/ChangeLog.md index 17a47dd79ea..e38ad2b8c43 100644 --- a/cardano-api/ChangeLog.md +++ b/cardano-api/ChangeLog.md @@ -26,6 +26,8 @@ - **Breaking change** - `queryExpr` to return `IO (Either UnsupportedNtcVersionError a)` instead of `IO a`. ([PR4788](https://github.com/input-output-hk/cardano-node/pull/4788)) + +- **Breaking change** - Remove distinction between multisig and timelock scripts([PR4763](https://github.com/input-output-hk/cardano-node/pull/4763)) ### Bugs diff --git a/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs b/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs index 86f4ef10ef0..83284d2e27b 100644 --- a/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs +++ b/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs @@ -125,7 +125,6 @@ import qualified Data.ByteString.Short as SBS import Data.Coerce import Data.Int (Int64) import Data.Map.Strict (Map) -import Data.Maybe (maybeToList) import Data.Ratio (Ratio, (%)) import Data.String import Data.Word (Word64) diff --git a/cardano-api/src/Cardano/Api/Script.hs b/cardano-api/src/Cardano/Api/Script.hs index 68b03597c9f..272dc715aa2 100644 --- a/cardano-api/src/Cardano/Api/Script.hs +++ b/cardano-api/src/Cardano/Api/Script.hs @@ -1153,7 +1153,6 @@ instance ToJSON SimpleScript where instance FromJSON SimpleScript where parseJSON = parseSimpleScript --- TODO: Left off here. You need to comb through cardano-api's property tests concerning simple scripts parseSimpleScript :: Value -> Aeson.Parser SimpleScript parseSimpleScript v = parseScriptSig v <|> parseScriptBefore v <|> diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs b/cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs index 6d7b2cbc9fc..abcc7eda2a6 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs @@ -2118,7 +2118,7 @@ pTxIn balance = :: TxIn -> ScriptWitnessFiles WitCtxTxIn createSimpleReferenceScriptWitnessFiles refTxIn = - let simpleLang = AnyScriptLanguage (SimpleScriptLanguage SimpleScriptV2) + let simpleLang = AnyScriptLanguage SimpleScriptLanguage in SimpleReferenceScriptWitnessFiles refTxIn simpleLang Nothing pPlutusReferenceScriptWitness :: BalanceTxExecUnits -> Parser (ScriptWitnessFiles WitCtxTxIn) @@ -2331,7 +2331,7 @@ pMintMultiAsset balanceExecUnits = -> PolicyId -> ScriptWitnessFiles WitCtxMint createSimpleMintingReferenceScriptWitnessFiles refTxIn pid = - let simpleLang = AnyScriptLanguage (SimpleScriptLanguage SimpleScriptV2) + let simpleLang = AnyScriptLanguage SimpleScriptLanguage in SimpleReferenceScriptWitnessFiles refTxIn simpleLang (Just pid) pPlutusMintReferenceScriptWitnessFiles diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Run/Read.hs b/cardano-cli/src/Cardano/CLI/Shelley/Run/Read.hs index fb91b698cd3..8b6d9e94d86 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Run/Read.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Run/Read.hs @@ -226,9 +226,8 @@ readScriptWitness era' (SimpleScriptWitnessFile (ScriptFile scriptFile)) = do readFileScriptInAnyLang scriptFile ScriptInEra langInEra script' <- validateScriptSupportedInEra era' script case script' of - SimpleScript version sscript -> - return . SimpleScriptWitness - langInEra version $ SScript sscript + SimpleScript sscript -> + return . SimpleScriptWitness langInEra $ SScript sscript -- If the supplied cli flags were for a simple script (i.e. the user did -- not supply the datum, redeemer or ex units), but the script file turns @@ -277,7 +276,7 @@ readScriptWitness era' (PlutusReferenceScriptWitnessFiles refTxIn case scriptLanguageSupportedInEra era' anyScriptLanguage of Just sLangInEra -> case languageOfScriptLanguageInEra sLangInEra of - SimpleScriptLanguage _v -> + SimpleScriptLanguage -> -- TODO: We likely need another datatype eg data ReferenceScriptWitness lang -- in order to make this branch unrepresentable. error "readScriptWitness: Should not be possible to specify a simple script" @@ -302,8 +301,8 @@ readScriptWitness era' (SimpleReferenceScriptWitnessFiles refTxIn case scriptLanguageSupportedInEra era' anyScriptLanguage of Just sLangInEra -> case languageOfScriptLanguageInEra sLangInEra of - SimpleScriptLanguage v -> - return . SimpleScriptWitness sLangInEra v + SimpleScriptLanguage -> + return . SimpleScriptWitness sLangInEra $ SReferenceScript refTxIn (unPolicyId <$> mPid) PlutusScriptLanguage{} -> error "readScriptWitness: Should not be possible to specify a plutus script" @@ -415,12 +414,11 @@ deserialiseScriptInAnyLang bs = -- case deserialiseFromJSON AsTextEnvelope bs of Left _ -> - -- The SimpleScript language has the property that it is backwards - -- compatible, so we can parse as the latest version and then downgrade - -- to the minimum version that has all the features actually used. - case deserialiseFromJSON (AsSimpleScript AsSimpleScriptV2) bs of - Left err -> Left (ScriptDecodeSimpleScriptError err) - Right script -> Right (toMinimumSimpleScriptVersion script) + -- In addition to the TextEnvelope format, we also try to + -- deserialize the JSON representation of SimpleScripts. + case Aeson.eitherDecodeStrict' bs of + Left err -> Left (ScriptDecodeSimpleScriptError $ JsonDecodeError err) + Right script -> Right $ ScriptInAnyLang SimpleScriptLanguage $ SimpleScript script Right te -> case deserialiseFromTextEnvelopeAnyOf textEnvTypes te of @@ -432,11 +430,8 @@ deserialiseScriptInAnyLang bs = -- script version. textEnvTypes :: [FromSomeType HasTextEnvelope ScriptInAnyLang] textEnvTypes = - [ FromSomeType (AsScript AsSimpleScriptV1) - (ScriptInAnyLang (SimpleScriptLanguage SimpleScriptV1)) - - , FromSomeType (AsScript AsSimpleScriptV2) - (ScriptInAnyLang (SimpleScriptLanguage SimpleScriptV2)) + [ FromSomeType (AsScript AsSimpleScript) + (ScriptInAnyLang SimpleScriptLanguage) , FromSomeType (AsScript AsPlutusScriptV1) (ScriptInAnyLang (PlutusScriptLanguage PlutusScriptV1)) @@ -445,19 +440,6 @@ deserialiseScriptInAnyLang bs = (ScriptInAnyLang (PlutusScriptLanguage PlutusScriptV2)) ] - toMinimumSimpleScriptVersion :: SimpleScript SimpleScriptV2 - -> ScriptInAnyLang - toMinimumSimpleScriptVersion s = - -- TODO alonzo: this will need to be adjusted when more versions are added - -- with appropriate helper functions it can probably be done in an - -- era-generic style - case adjustSimpleScriptVersion SimpleScriptV1 s of - Nothing -> ScriptInAnyLang (SimpleScriptLanguage SimpleScriptV2) - (SimpleScript SimpleScriptV2 s) - Just s' -> ScriptInAnyLang (SimpleScriptLanguage SimpleScriptV1) - (SimpleScript SimpleScriptV1 s') - - -- Tx & TxBody newtype CddlTx = CddlTx {unCddlTx :: InAnyCardanoEra Tx} deriving (Show, Eq) diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs b/cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs index d37bc26888d..6c686e63c08 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs @@ -883,8 +883,8 @@ getAllReferenceInputs txins mintWitnesses certFiles withdrawals readOnlyRefIns = case sWit of PlutusScriptWitness _ _ (PReferenceScript refIn _) _ _ _ -> Just refIn PlutusScriptWitness _ _ PScript{} _ _ _ -> Nothing - SimpleScriptWitness _ _ (SReferenceScript refIn _) -> Just refIn - SimpleScriptWitness _ _ SScript{} -> Nothing + SimpleScriptWitness _ (SReferenceScript refIn _) -> Just refIn + SimpleScriptWitness _ SScript{} -> Nothing toAddressInAnyEra :: CardanoEra era @@ -1037,9 +1037,9 @@ createTxMintValue era (val, scriptWitnesses) = witnessesExtra = Set.elems (witnessesProvided Set.\\ witnessesNeeded) scriptWitnessPolicyId :: ScriptWitness witctx era -> Maybe PolicyId -scriptWitnessPolicyId (SimpleScriptWitness _ version (SScript script)) = - Just . scriptPolicyId $ SimpleScript version script -scriptWitnessPolicyId (SimpleScriptWitness _ _ (SReferenceScript _ mPid)) = +scriptWitnessPolicyId (SimpleScriptWitness _ (SScript script)) = + Just . scriptPolicyId $ SimpleScript script +scriptWitnessPolicyId (SimpleScriptWitness _ (SReferenceScript _ mPid)) = PolicyId <$> mPid scriptWitnessPolicyId (PlutusScriptWitness _ version (PScript script) _ _ _) = Just . scriptPolicyId $ PlutusScript version script