Skip to content

Commit 720128a

Browse files
Merge pull request #104 from ChaseAtMLabs/trace-logs
Handle contract logs correctly
2 parents 17072f2 + eaf7637 commit 720128a

File tree

8 files changed

+234
-52
lines changed

8 files changed

+234
-52
lines changed

bot-plutus-interface.cabal

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ library
103103
, data-default
104104
, data-default-class
105105
, directory
106+
, prettyprinter
106107
, either
108+
, vector
107109
, filepath
108110
, freer-extras
109111
, freer-simple
@@ -173,6 +175,7 @@ test-suite bot-plutus-interface-test
173175
, data-default-class
174176
, either
175177
, extra
178+
, prettyprinter
176179
, filepath
177180
, freer-extras
178181
, freer-simple

flake.lock

Lines changed: 114 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
description = "bot-plutus-interface";
33

44
inputs = {
5-
haskell-nix.url = "github:L-as/haskell.nix";
5+
haskell-nix.url = "github:mlabs-haskell/haskell.nix";
66

77
nixpkgs.follows = "haskell-nix/nixpkgs-unstable";
88

src/BotPlutusInterface/Balance.hs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module BotPlutusInterface.Balance (
77
) where
88

99
import BotPlutusInterface.CardanoCLI qualified as CardanoCLI
10-
import BotPlutusInterface.Effects (PABEffect, createDirectoryIfMissingCLI, printLog)
10+
import BotPlutusInterface.Effects (PABEffect, createDirectoryIfMissingCLI, printBpiLog)
1111
import BotPlutusInterface.Files (DummyPrivKey, unDummyPrivateKey)
1212
import BotPlutusInterface.Files qualified as Files
1313
import BotPlutusInterface.Types (LogLevel (Debug), PABConfig)
@@ -60,6 +60,7 @@ import Plutus.V1.Ledger.Api (
6060
)
6161

6262
import BotPlutusInterface.BodyBuilder qualified as BodyBuilder
63+
import Prettyprinter (pretty, viaShow, (<+>))
6364
import Prelude
6465

6566
{- | Collect necessary tx inputs and collaterals, add minimum lovelace values and balance non ada
@@ -86,7 +87,7 @@ balanceTxIO pabConf ownPkh unbalancedTx =
8687
(unBalancedTxValidityTimeRange unbalancedTx)
8788
(unBalancedTxTx unbalancedTx)
8889

89-
lift $ printLog @w Debug $ show utxoIndex
90+
lift $ printBpiLog @w Debug $ viaShow utxoIndex
9091

9192
-- We need this folder on the CLI machine, which may not be the local machine
9293
lift $ createDirectoryIfMissingCLI @w False (Text.unpack pabConf.pcTxFileDir)
@@ -130,7 +131,7 @@ balanceTxIO pabConf ownPkh unbalancedTx =
130131

131132
let minUtxos = prevMinUtxos ++ nextMinUtxos
132133

133-
lift $ printLog @w Debug $ "Min utxos: " ++ show minUtxos
134+
lift $ printBpiLog @w Debug $ "Min utxos:" <+> pretty minUtxos
134135

135136
-- Calculate fees by pre-balancing the tx, building it, and running the CLI on result
136137
txWithoutFees <-
@@ -142,7 +143,7 @@ balanceTxIO pabConf ownPkh unbalancedTx =
142143

143144
let fees = nonBudgettedFees + getBudgetPrice (getExecutionUnitPrices pabConf) exBudget
144145

145-
lift $ printLog @w Debug $ "Fees: " ++ show fees
146+
lift $ printBpiLog @w Debug $ "Fees:" <+> pretty fees
146147

147148
-- Rebalance the initial tx with the above fees
148149
balancedTx <- hoistEither $ balanceTxStep minUtxos utxoIndex changeAddr $ tx `withFee` fees

0 commit comments

Comments
 (0)