diff --git a/src/base/lib/Convex/BuildTx.hs b/src/base/lib/Convex/BuildTx.hs index e14c738..1d6cdc3 100644 --- a/src/base/lib/Convex/BuildTx.hs +++ b/src/base/lib/Convex/BuildTx.hs @@ -90,6 +90,7 @@ module Convex.BuildTx( addConwayStakeCredentialUnRegistrationCertificate, addStakeWitness, addStakeScriptWitness, + addStakeScriptWitnessRef, addStakeWitnessWithTxBody, -- ** Minting and burning tokens @@ -350,7 +351,6 @@ addStakeWitness :: addStakeWitness credential witness = addBtx (over (L.txCertificates . L._TxCertificates . _2) ((:) (credential, witness))) --- mintPlutus :: forall redeemer lang era m. (Plutus.ToData redeemer, MonadBuildTx era m, C.HasScriptLanguageInEra lang era, C.IsAlonzoBasedEra era, C.IsPlutusScriptLanguage lang) => PlutusScript lang -> redeemer -> C.AssetName -> C.Quantity -> m () {-| Add a stake script witness to the transaction. -} addStakeScriptWitness :: @@ -369,6 +369,24 @@ addStakeScriptWitness credential script redeemer = do let witness = C.ScriptWitness C.ScriptWitnessForStakeAddr scriptWitness addBtx (over (L.txCertificates . L._TxCertificates . _2) ((:) (credential, witness))) +{-| Add a stake script reference witness to the transaction. +-} +addStakeScriptWitnessRef :: + ( MonadBuildTx era m + , Plutus.ToData redeemer + , C.IsShelleyBasedEra era + , C.HasScriptLanguageInEra lang era + ) + => C.StakeCredential + -> C.TxIn + -> C.PlutusScriptVersion lang + -> redeemer + -> m () +addStakeScriptWitnessRef credential txIn plutusScriptVersion redeemer = do + let scriptWitness = buildRefScriptWitness txIn plutusScriptVersion C.NoScriptDatumForStake redeemer + let witness = C.ScriptWitness C.ScriptWitnessForStakeAddr scriptWitness + addBtx (over (L.txCertificates . L._TxCertificates . _2) ((:) (credential, witness))) + {- | Like @addStakeWitness@ but uses a function that takes a @TxBody@ to build the witness. TODO Give an example of why this is useful. We should just remove it. -}