Skip to content

Commit 015bb9e

Browse files
committed
Don't throw OutputZeroAda in toCardano translation.
1 parent 4a9a395 commit 015bb9e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/BotPlutusInterface/Effects.hs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ import Data.Text (Text)
8686
import Data.Text qualified as Text
8787
import Ledger qualified
8888
import Ledger.Ada qualified as Ada
89+
import Ledger.Tx (TxOut (TxOut))
90+
import Ledger.Tx.CardanoAPI (toCardanoAddressInEra, toCardanoValue)
8991
import Ledger.Tx.CardanoAPI qualified as TxApi
9092
import Ledger.Validation (Coin (Coin))
9193
import Plutus.Contract.Effects (ChainIndexQuery, ChainIndexResponse)
@@ -294,7 +296,7 @@ calcMinUtxo pabconf txout = do
294296

295297
ctxout <-
296298
mapLeft (Text.pack . show) $
297-
TxApi.toCardanoTxOut netId TxApi.toCardanoTxOutDatumHash txout
299+
toCardanoTxOutForked netId TxApi.toCardanoTxOutDatumHash txout
298300

299301
let (Coin minTxOut) =
300302
evaluateMinLovelaceOutput pparamsInEra $
@@ -305,6 +307,17 @@ calcMinUtxo pabconf txout = do
305307
if missingLovelace > 0
306308
then calcMinUtxo pabconf (txout {Ledger.txOutValue = Ledger.txOutValue txout <> Ada.toValue missingLovelace})
307309
else return txout
310+
where
311+
-- We need to redefine this to remove error reporting with 0 ada outputs.
312+
toCardanoTxOutValue value = do
313+
-- when (Ada.fromValue value == mempty) (Left OutputHasZeroAda)
314+
CApi.TxOutValue CApi.MultiAssetInBabbageEra <$> toCardanoValue value
315+
316+
toCardanoTxOutForked networkId fromHash (TxOut addr value datumHash) =
317+
CApi.TxOut <$> toCardanoAddressInEra networkId addr
318+
<*> toCardanoTxOutValue value
319+
<*> fromHash datumHash
320+
<*> pure CApi.S.ReferenceScriptNone
308321

309322
-- Couldn't use the template haskell makeEffect here, because it caused an OverlappingInstances problem.
310323
-- For some reason, we need to manually propagate the @w@ type variable to @send@

0 commit comments

Comments
 (0)