Skip to content

Commit a3a252f

Browse files
committed
Fix transaction witness set 'attach' functions
1 parent b13dac4 commit a3a252f

File tree

1 file changed

+16
-27
lines changed

1 file changed

+16
-27
lines changed

src/Internal/Transaction.purs

+16-27
Original file line numberDiff line numberDiff line change
@@ -90,43 +90,32 @@ setScriptDataHash costModels rs ds tx@(Transaction { body, witnessSet })
9090
attachDatum :: PlutusData -> Transaction -> Transaction
9191
attachDatum d = attachDatums [ d ]
9292

93-
attachDatums
94-
:: Array PlutusData -> Transaction -> Transaction
93+
attachDatums :: Array PlutusData -> Transaction -> Transaction
9594
attachDatums [] tx = tx
9695
attachDatums datums tx@(Transaction { witnessSet: TransactionWitnessSet ws }) =
97-
do
98-
updateTxWithWitnesses tx $ TransactionWitnessSet $ ws
99-
{ plutusData = nub $ ws.plutusData <> datums }
96+
updateTxWithWitnesses tx $ TransactionWitnessSet $ ws
97+
{ plutusData = nub $ ws.plutusData <> datums
98+
}
10099

101100
-- | Attach a `PlutusScript` to a transaction by modifying its existing witness
102101
-- | set
103-
attachPlutusScript
104-
:: PlutusScript -> Transaction -> Transaction
102+
attachPlutusScript :: PlutusScript -> Transaction -> Transaction
105103
attachPlutusScript ps = attachPlutusScripts [ ps ]
106104

107-
attachPlutusScripts
108-
:: Array PlutusScript
109-
-> Transaction
110-
-> Transaction
105+
attachPlutusScripts :: Array PlutusScript -> Transaction -> Transaction
111106
attachPlutusScripts ps tx@(Transaction { witnessSet: TransactionWitnessSet ws }) =
112-
do
113-
updateTxWithWitnesses tx
114-
$ TransactionWitnessSet
115-
$ ws { plutusScripts = nub $ ws.plutusScripts <> ps }
107+
updateTxWithWitnesses tx $ TransactionWitnessSet $ ws
108+
{ plutusScripts = nub $ ws.plutusScripts <> ps
109+
}
116110

117111
-- | Attach a `NativeScript` to a transaction by modifying its existing witness
118112
-- | set
119-
attachNativeScript
120-
:: NativeScript -> Transaction -> Transaction
113+
attachNativeScript :: NativeScript -> Transaction -> Transaction
121114
attachNativeScript ns tx@(Transaction { witnessSet: TransactionWitnessSet ws }) =
122-
do
123-
updateTxWithWitnesses tx
124-
$ TransactionWitnessSet
125-
$ ws { nativeScripts = nub $ ws.nativeScripts <> [ ns ] }
115+
updateTxWithWitnesses tx $ TransactionWitnessSet $ ws
116+
{ nativeScripts = nub $ ws.nativeScripts <> [ ns ]
117+
}
126118

127-
updateTxWithWitnesses
128-
:: Transaction
129-
-> TransactionWitnessSet
130-
-> Transaction
131-
updateTxWithWitnesses tx@(Transaction t) ws =
132-
over Transaction _ { witnessSet = t.witnessSet <> ws } tx
119+
updateTxWithWitnesses :: Transaction -> TransactionWitnessSet -> Transaction
120+
updateTxWithWitnesses tx ws =
121+
over Transaction _ { witnessSet = ws } tx

0 commit comments

Comments
 (0)