From 90a0d10b3928668456d9371bcf8c5993de17f8df Mon Sep 17 00:00:00 2001 From: Alberto Fanton Date: Thu, 18 Jul 2024 13:14:31 +0200 Subject: [PATCH] Add util to add stake wit with tx body --- src/base/lib/Convex/BuildTx.hs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/base/lib/Convex/BuildTx.hs b/src/base/lib/Convex/BuildTx.hs index c5a69850..9c0f96ab 100644 --- a/src/base/lib/Convex/BuildTx.hs +++ b/src/base/lib/Convex/BuildTx.hs @@ -37,6 +37,7 @@ module Convex.BuildTx( addInputWithTxBody, addMintWithTxBody, addWithdrawalWithTxBody, + addStakeWitnessWithTxBody, addReference, addCollateral, addAuxScript, @@ -333,6 +334,12 @@ addWithdrawalWithTxBody :: MonadBuildTx m => C.StakeAddress -> C.Quantity -> (T addWithdrawalWithTxBody address amount f = addTxBuilder (TxBuilder $ \body -> (over (L.txWithdrawals . L._TxWithdrawals) ((address, C.quantityToLovelace amount, C.BuildTxWith $ f body) :))) +{- | Like @addStakeWitness@ but uses a function that takes a @TxBody@ to build the witness. +-} +addStakeWitnessWithTxBody :: MonadBuildTx m => C.StakeCredential -> (TxBody -> C.Witness C.WitCtxStake C.BabbageEra) -> m () +addStakeWitnessWithTxBody credential buildWitness = + addTxBuilder (TxBuilder $ \body -> (set (L.txCertificates . L._TxCertificates . _2 . at credential) (Just $ buildWitness body))) + {-| Spend an output locked by a public key -} spendPublicKeyOutput :: MonadBuildTx m => C.TxIn -> m ()