@@ -28,6 +28,7 @@ import BotPlutusInterface.Types (PABConfig)
2828import BotPlutusInterface.UtxoParser qualified as UtxoParser
2929import Cardano.Api.Shelley (NetworkId (Mainnet , Testnet ), NetworkMagic (.. ), serialiseAddress )
3030import Codec.Serialise qualified as Codec
31+ import Control.Monad (join )
3132import Control.Monad.Freer (Eff , Member )
3233import Data.Aeson.Extras (encodeByteString )
3334import Data.Attoparsec.Text (parseOnly )
@@ -99,7 +100,7 @@ utxosAt ::
99100 Member (PABEffect w ) effs =>
100101 PABConfig ->
101102 Address ->
102- Eff effs (Map TxOutRef ChainIndexTxOut )
103+ Eff effs (Either Text ( Map TxOutRef ChainIndexTxOut ) )
103104utxosAt pabConf address =
104105 callCommand @ w
105106 ShellArgs
@@ -125,17 +126,18 @@ calculateMinUtxo ::
125126 TxOut ->
126127 Eff effs (Either Text Integer )
127128calculateMinUtxo pabConf datums txOut =
128- callCommand @ w
129- ShellArgs
130- { cmdName = " cardano-cli"
131- , cmdArgs =
132- mconcat
133- [ [" transaction" , " calculate-min-required-utxo" , " --alonzo-era" ]
134- , txOutOpts pabConf datums [txOut]
135- , [" --protocol-params-file" , pabConf. pcProtocolParamsFile]
136- ]
137- , cmdOutParser = mapLeft Text. pack . parseOnly UtxoParser. feeParser . Text. pack
138- }
129+ join
130+ <$> callCommand @ w
131+ ShellArgs
132+ { cmdName = " cardano-cli"
133+ , cmdArgs =
134+ mconcat
135+ [ [" transaction" , " calculate-min-required-utxo" , " --alonzo-era" ]
136+ , txOutOpts pabConf datums [txOut]
137+ , [" --protocol-params-file" , pabConf. pcProtocolParamsFile]
138+ ]
139+ , cmdOutParser = mapLeft Text. pack . parseOnly UtxoParser. feeParser . Text. pack
140+ }
139141
140142-- | Calculating fee for an unbalanced transaction
141143calculateMinFee ::
@@ -145,21 +147,22 @@ calculateMinFee ::
145147 Tx ->
146148 Eff effs (Either Text Integer )
147149calculateMinFee pabConf tx =
148- callCommand @ w
149- ShellArgs
150- { cmdName = " cardano-cli"
151- , cmdArgs =
152- mconcat
153- [ [" transaction" , " calculate-min-fee" ]
154- , [" --tx-body-file" , txFilePath pabConf " raw" tx]
155- , [" --tx-in-count" , showText $ length $ txInputs tx]
156- , [" --tx-out-count" , showText $ length $ txOutputs tx]
157- , [" --witness-count" , showText $ length $ txSignatures tx]
158- , [" --protocol-params-file" , pabConf. pcProtocolParamsFile]
159- , networkOpt pabConf
160- ]
161- , cmdOutParser = mapLeft Text. pack . parseOnly UtxoParser. feeParser . Text. pack
162- }
150+ join
151+ <$> callCommand @ w
152+ ShellArgs
153+ { cmdName = " cardano-cli"
154+ , cmdArgs =
155+ mconcat
156+ [ [" transaction" , " calculate-min-fee" ]
157+ , [" --tx-body-file" , txFilePath pabConf " raw" tx]
158+ , [" --tx-in-count" , showText $ length $ txInputs tx]
159+ , [" --tx-out-count" , showText $ length $ txOutputs tx]
160+ , [" --witness-count" , showText $ length $ txSignatures tx]
161+ , [" --protocol-params-file" , pabConf. pcProtocolParamsFile]
162+ , networkOpt pabConf
163+ ]
164+ , cmdOutParser = mapLeft Text. pack . parseOnly UtxoParser. feeParser . Text. pack
165+ }
163166
164167data BuildMode = BuildRaw Integer | BuildAuto
165168 deriving stock (Show )
@@ -178,7 +181,7 @@ buildTx ::
178181 PubKeyHash ->
179182 BuildMode ->
180183 Tx ->
181- Eff effs ()
184+ Eff effs (Either Text () )
182185buildTx pabConf ownPkh buildMode tx =
183186 callCommand @ w $ ShellArgs " cardano-cli" opts (const () )
184187 where
@@ -215,7 +218,7 @@ signTx ::
215218 PABConfig ->
216219 Tx ->
217220 [PubKey ] ->
218- Eff effs ()
221+ Eff effs (Either Text () )
219222signTx pabConf tx pubKeys =
220223 callCommand @ w $
221224 ShellArgs
@@ -240,7 +243,7 @@ submitTx ::
240243 Member (PABEffect w ) effs =>
241244 PABConfig ->
242245 Tx ->
243- Eff effs (Maybe Text )
246+ Eff effs (Either Text () )
244247submitTx pabConf tx =
245248 callCommand @ w $
246249 ShellArgs
@@ -251,13 +254,7 @@ submitTx pabConf tx =
251254 , networkOpt pabConf
252255 ]
253256 )
254- ( ( \ out ->
255- if " Transaction successfully submitted." `Text.isPrefixOf` out
256- then Nothing
257- else Just out
258- )
259- . Text. pack
260- )
257+ (const () )
261258
262259txInOpts :: PABConfig -> BuildMode -> Set TxIn -> [Text ]
263260txInOpts pabConf buildMode =
0 commit comments