Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bot-plutus-interface.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ library
, data-default
, data-default-class
, directory
, prettyprinter
, either
, vector
, filepath
, freer-extras
, freer-simple
Expand Down Expand Up @@ -173,6 +175,7 @@ test-suite bot-plutus-interface-test
, data-default-class
, either
, extra
, prettyprinter
, filepath
, freer-extras
, freer-simple
Expand Down
137 changes: 114 additions & 23 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
description = "bot-plutus-interface";

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

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

Expand Down
9 changes: 5 additions & 4 deletions src/BotPlutusInterface/Balance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module BotPlutusInterface.Balance (
) where

import BotPlutusInterface.CardanoCLI qualified as CardanoCLI
import BotPlutusInterface.Effects (PABEffect, createDirectoryIfMissingCLI, printLog)
import BotPlutusInterface.Effects (PABEffect, createDirectoryIfMissingCLI, printBpiLog)
import BotPlutusInterface.Files (DummyPrivKey, unDummyPrivateKey)
import BotPlutusInterface.Files qualified as Files
import BotPlutusInterface.Types (LogLevel (Debug), PABConfig)
Expand Down Expand Up @@ -60,6 +60,7 @@ import Plutus.V1.Ledger.Api (
)

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

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

lift $ printLog @w Debug $ show utxoIndex
lift $ printBpiLog @w Debug $ viaShow utxoIndex

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

let minUtxos = prevMinUtxos ++ nextMinUtxos

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

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

let fees = nonBudgettedFees + getBudgetPrice (getExecutionUnitPrices pabConf) exBudget

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

-- Rebalance the initial tx with the above fees
balancedTx <- hoistEither $ balanceTxStep minUtxos utxoIndex changeAddr $ tx `withFee` fees
Expand Down
Loading