Skip to content

Commit 168d740

Browse files
committed
move stats collection
- move stats collection to point before Tx submission
1 parent 629023e commit 168d740

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/BotPlutusInterface/Contract.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,9 @@ writeBalancedTx contractEnv (Right tx) = do
274274
, "Signatories (pkh): " <> Text.unwords (map pkhToText requiredSigners)
275275
]
276276

277+
when (pabConf.pcCollectStats && signable) $
278+
collectBudgetStats (Tx.txId tx) pabConf
279+
277280
when (not pabConf.pcDryRun && signable) $ do
278281
newEitherT $ CardanoCLI.submitTx @w pabConf tx
279282

@@ -284,9 +287,6 @@ writeBalancedTx contractEnv (Right tx) = do
284287
mvFiles (Files.txFilePath pabConf "raw" (Tx.txId tx)) (Files.txFilePath pabConf "raw" cardanoTxId)
285288
when signable $ mvFiles signedSrcPath signedDstPath
286289

287-
when contractEnv.cePABConfig.pcCollectStats $
288-
collectBudgetStats cardanoTxId signedDstPath
289-
290290
pure cardanoTx
291291
where
292292
mvFiles :: Text -> Text -> EitherT Text (Eff effs) ()
@@ -299,8 +299,8 @@ writeBalancedTx contractEnv (Right tx) = do
299299
, cmdOutParser = const ()
300300
}
301301

302-
collectBudgetStats txId txPath = do
303-
let path = Text.unpack txPath
302+
collectBudgetStats txId pabConf = do
303+
let path = Text.unpack (Files.txFilePath pabConf "signed" (Tx.txId tx))
304304
b <- firstEitherT (Text.pack . show) $ newEitherT $ estimateBudget @w (Signed path)
305305
void $ newEitherT (Right <$> saveBudget @w txId b)
306306

0 commit comments

Comments
 (0)