Skip to content

Commit

Permalink
Add addStakeScriptWitnessRef
Browse files Browse the repository at this point in the history
  • Loading branch information
koslambrou authored and j-mueller committed Nov 20, 2024
1 parent baa7e82 commit 77e5b78
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/base/lib/Convex/BuildTx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ module Convex.BuildTx(
addConwayStakeCredentialUnRegistrationCertificate,
addStakeWitness,
addStakeScriptWitness,
addStakeScriptWitnessRef,
addStakeWitnessWithTxBody,

-- ** Minting and burning tokens
Expand Down Expand Up @@ -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 ::
Expand All @@ -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.
-}
Expand Down

0 comments on commit 77e5b78

Please sign in to comment.