diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c78b5a7..b1545b7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,9 @@ to pay back an existing output with a slight modification. - A new tweak `modifySpendRedeemersOfTypeTweak` to apply an optional modification of all redeemers of a certain type within the skeleton inputs. +- Two new helpers `paysScriptNoValue` and `paysScriptOnlyAddress` to allow + payments to script with 0-ADA value, to be used alongside `txOptEnsureMinAda = + True` to avoid specifying an explicit amount of ADA. ### Removed diff --git a/src/Cooked/Skeleton.hs b/src/Cooked/Skeleton.hs index 7610bc33..b340b53d 100644 --- a/src/Cooked/Skeleton.hs +++ b/src/Cooked/Skeleton.hs @@ -100,6 +100,8 @@ module Cooked.Skeleton someTxSkelRedeemer, emptyTxSkelRedeemer, toTypedRedeemer, + paysScriptNoValue, + paysScriptOnlyAddress, ) where @@ -910,7 +912,7 @@ txSkelOutTypedDatum = Api.fromBuiltinData . Api.getDatum <=< txSkelOutUntypedDat -- ** Smart constructors for transaction outputs --- | Pay a certain value to a public key. +-- | Pays a certain value to a public key. paysPK :: (ToPubKeyHash a) => a -> Api.Value -> TxSkelOut paysPK pkh value = Pays @@ -947,6 +949,51 @@ paysScript validator datum value = (Nothing @(Script.Versioned Script.Script)) ) +-- | Pays a script with a certain datum and a 0-ADA value. To be used with the +-- automated minimal ADA adjustment 'txOptEnsureMinAda = True'. +paysScriptNoValue :: + ( Api.ToData (Script.DatumType a), + Show (Script.DatumType a), + Typeable (Script.DatumType a), + PlutusTx.Eq (Script.DatumType a), + PrettyCooked (Script.DatumType a), + Typeable a + ) => + Script.TypedValidator a -> + Script.DatumType a -> + TxSkelOut +paysScriptNoValue validator datum = + Pays + ( ConcreteOutput + validator + Nothing + (TxSkelOutDatum datum) + (Script.ada 0) + (Nothing @(Script.Versioned Script.Script)) + ) + +-- | Pays a script with no datum and a 0-ADA value. To be used with the +-- automated minimal ADA adjustment 'txOptEnsureMinAda = True'. +paysScriptOnlyAddress :: + ( Api.ToData (Script.DatumType a), + Show (Script.DatumType a), + Typeable (Script.DatumType a), + PlutusTx.Eq (Script.DatumType a), + PrettyCooked (Script.DatumType a), + Typeable a + ) => + Script.TypedValidator a -> + TxSkelOut +paysScriptOnlyAddress validator = + Pays + ( ConcreteOutput + validator + Nothing + TxSkelOutNoDatum + (Script.ada 0) + (Nothing @(Script.Versioned Script.Script)) + ) + -- | Pays a script a certain value with a certain inlined datum. paysScriptInlineDatum :: ( Api.ToData (Script.DatumType a),