@@ -143,18 +143,23 @@ calculateMinUtxo ::
143143 TxOut ->
144144 Eff effs (Either Text Integer )
145145calculateMinUtxo pabConf datums txOut = do
146- join
147- <$> callCommand @ w
148- ShellArgs
149- { cmdName = " cardano-cli"
150- , cmdArgs =
151- mconcat
152- [ [" transaction" , " calculate-min-required-utxo" , " --alonzo-era" ]
153- , txOutOpts pabConf datums [txOut]
154- , [" --protocol-params-file" , pabConf. pcProtocolParamsFile]
155- ]
156- , cmdOutParser = mapLeft Text. pack . parseOnly UtxoParser. feeParser . Text. pack
157- }
146+ let outs = txOutOpts pabConf datums [txOut]
147+
148+ case outs of
149+ [] -> pure $ Left " When constructing the transaction, no output values were specified."
150+ _ ->
151+ join
152+ <$> callCommand @ w
153+ ShellArgs
154+ { cmdName = " cardano-cli"
155+ , cmdArgs =
156+ mconcat
157+ [ [" transaction" , " calculate-min-required-utxo" , " --alonzo-era" ]
158+ , outs
159+ , [" --protocol-params-file" , pabConf. pcProtocolParamsFile]
160+ ]
161+ , cmdOutParser = mapLeft Text. pack . parseOnly UtxoParser. feeParser . Text. pack
162+ }
158163
159164-- | Calculating fee for an unbalanced transaction
160165calculateMinFee ::
@@ -191,40 +196,46 @@ buildTx ::
191196 Tx ->
192197 Eff effs (Either Text ExBudget )
193198buildTx pabConf privKeys txBudget tx = do
194- let (ins, valBudget) = txInOpts (spendBudgets txBudget) pabConf (txInputs tx)
195- (mints, mintBudget) = mintOpts (mintBudgets txBudget) pabConf (txMintScripts tx) (txRedeemers tx) (txMint tx)
196- callCommand @ w $ ShellArgs " cardano-cli" (opts ins mints) (const $ valBudget <> mintBudget)
197- where
198- requiredSigners =
199- concatMap
200- ( \ pubKey ->
201- let pkh = Ledger. pubKeyHash pubKey
202- in case Map. lookup pkh privKeys of
203- Just (FromSKey _) ->
204- [" --required-signer" , signingKeyFilePath pabConf pkh]
205- Just (FromVKey _) ->
206- [" --required-signer-hash" , encodeByteString $ fromBuiltin $ getPubKeyHash pkh]
207- Nothing ->
208- []
209- )
210- (Map. keys (Ledger. txSignatures tx))
199+ let outs = txOutOpts pabConf (txData tx) (txOutputs tx)
211200
212- opts ins mints =
213- mconcat
214- [ [" transaction" , " build-raw" , " --alonzo-era" ]
215- , ins
216- , txInCollateralOpts (txCollateral tx)
217- , txOutOpts pabConf (txData tx) (txOutputs tx)
218- , mints
219- , validRangeOpts (txValidRange tx)
220- , metadataOpts pabConf (txMetadata tx)
221- , requiredSigners
222- , [" --fee" , showText . getLovelace . fromValue $ txFee tx]
223- , mconcat
224- [ [" --protocol-params-file" , pabConf. pcProtocolParamsFile]
225- , [" --out-file" , txFilePath pabConf " raw" (txId tx)]
201+ case outs of
202+ [] -> pure $ Left " When constructing the transaction, no output values were specified."
203+ _ ->
204+ callCommand @ w $ ShellArgs " cardano-cli" opts (const $ valBudget <> mintBudget)
205+ where
206+ (ins, valBudget) = txInOpts (spendBudgets txBudget) pabConf (txInputs tx)
207+ (mints, mintBudget) = mintOpts (mintBudgets txBudget) pabConf (txMintScripts tx) (txRedeemers tx) (txMint tx)
208+
209+ requiredSigners =
210+ concatMap
211+ ( \ pubKey ->
212+ let pkh = Ledger. pubKeyHash pubKey
213+ in case Map. lookup pkh privKeys of
214+ Just (FromSKey _) ->
215+ [" --required-signer" , signingKeyFilePath pabConf pkh]
216+ Just (FromVKey _) ->
217+ [" --required-signer-hash" , encodeByteString $ fromBuiltin $ getPubKeyHash pkh]
218+ Nothing ->
219+ []
220+ )
221+ (Map. keys (Ledger. txSignatures tx))
222+
223+ opts =
224+ mconcat
225+ [ [" transaction" , " build-raw" , " --alonzo-era" ]
226+ , ins
227+ , txInCollateralOpts (txCollateral tx)
228+ , outs
229+ , mints
230+ , validRangeOpts (txValidRange tx)
231+ , metadataOpts pabConf (txMetadata tx)
232+ , requiredSigners
233+ , [" --fee" , showText . getLovelace . fromValue $ txFee tx]
234+ , mconcat
235+ [ [" --protocol-params-file" , pabConf. pcProtocolParamsFile]
236+ , [" --out-file" , txFilePath pabConf " raw" (txId tx)]
237+ ]
226238 ]
227- ]
228239
229240-- Signs and writes a tx (uses the tx body written to disk as input)
230241signTx ::
0 commit comments