IntersectMBO / IntersectMBO/cardano-cli
Only output valid JSON upon transaction submit result
- Dominant language
- Haskell
- Stars
- 71
- Forks
- 24
- Avg merge
- 23h 40m
- Merged PRs (30d)
- 14
Description
When one successfully submits a transaction:
```
% cardano-cli conway transaction submit --tx-file build/mint-scopes.tx.signed.json --testnet-magic 1
```
the output is:
```
Transaction successfully submitted. Transaction hash is:
{"txhash":"bdaa860ac0422ad83e67f8957ab230a7f4586d3050a7ab987ed5e40aa79a3fe6"}
```
which cannot be directly piped into eg. a `jq` script as it's not valid JSON. It seems to me a single JSON object would be much more useful as part of scriptable process, something like:
```
{ "result": "success", "success": true, "txhash":"bdaa860ac0422ad83e67f8957ab230a7f4586d3050a7ab987ed5e40aa79a3fe6"}
```
* `result`: a descriptive string or object in case of failures
* `success`: a boolean telling whether or not the tx was accepted by the node
* `txhash`: the transaction hash if `success: true`
Upon failure, instead of
```
% cardano-cli conway transaction submit --tx-file build/mint-scopes.tx.signed.json --testnet-magic 1
Command failed: transaction submit
Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraConway (ApplyTxError (ConwayUtxowFailure (UtxoFailure (UtxosFailure (CollectErrors [BadTranslation (BabbageContextError (AlonzoContextError (TranslationLogicMissingInput (TxIn (TxId {unTxId = SafeHash "2178565983a3125c608f7dea381d5b70d064be6b21879de86d4765e8ad3361f1"}) (TxIx {unTxIx = 0})))))]))) :| [ConwayUtxowFailure (UtxoFailure (ValueNotConservedUTxO (Mismatch {mismatchSupplied = MaryValue (Coin 0) (MultiAsset (fromList [(PolicyID {policyID = ScriptHash "dd15ae2bafb5528ab7146630a40095468363b903b3cbd8c967eddcec"},fromList [("616d6172752073636f706573",1)])])), mismatchExpected = MaryValue (Coin 8730146) (MultiAsset (fromList [(PolicyID {policyID = ScriptHash "dd15ae2bafb5528ab7146630a40095468363b903b3cbd8c967eddcec"},fromList [("616d6172752073636f706573",1)])]))}))),ConwayUtxowFailure (UtxoFailure (BadInputsUTxO (fromList [TxIn (TxId {unTxId = SafeHash "2178565983a3125c608f7dea381d5b70d064be6b21879de86d4765e8ad3361f1"}) (TxIx {unTxIx = 0})]))),ConwayUtxowFailure (UtxoFailure NoCollateralInputs),ConwayUtxowFailure (UtxoFailure (IncorrectTotalCollateralField (DeltaCoin (-8270846)) (Coin 459300))),ConwayUtxowFailure (UtxoFailure (InsufficientCollateral (DeltaCoin (-8270846)) (Coin 459300)))]))
```
one would have
```
% cardano-cli conway transaction submit --tx-file build/mint-scopes.tx.signed.json --testnet-magic 1
{"success":false, "result": "Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraConway (ApplyTxError (ConwayUtxowFailure (UtxoFailure (UtxosFailure (CollectErrors [BadTranslation (BabbageContextError (AlonzoContextError (TranslationLogicMissingInput (TxIn (TxId {unTxId = SafeHash \"2178565983a3125c608f7dea381d5b70d064be6b21879de86d4765e8ad3361f1\"}) (TxIx {unTxIx = 0})))))]))) :| [ConwayUtxowFailure (UtxoFailure (ValueNotConservedUTxO (Mismatch {mismatchSupplied = MaryValue (Coin 0) (MultiAsset (fromList [(PolicyID {policyID = ScriptHash \"dd15ae2bafb5528ab7146630a40095468363b903b3cbd8c967eddcec\"},fromList [(\"616d6172752073636f706573\",1)])])), mismatchExpected = MaryValue (Coin 8730146) (MultiAsset (fromList [(PolicyID {policyID = ScriptHash \"dd15ae2bafb5528ab7146630a40095468363b903b3cbd8c967eddcec\"},fromList [(\"616d6172752073636f706573\",1)])]))}))),ConwayUtxowFailure (UtxoFailure (BadInputsUTxO (fromList [TxIn (TxId {unTxId = SafeHash \"2178565983a3125c608f7dea381d5b70d064be6b21879de86d4765e8ad3361f1\"}) (TxIx {unTxIx = 0})]))),ConwayUtxowFailure (UtxoFailure NoCollateralInputs),ConwayUtxowFailure (UtxoFailure (IncorrectTotalCollateralField (DeltaCoin (-8270846)) (Coin 459300))),ConwayUtxowFailure (UtxoFailure (InsufficientCollateral (DeltaCoin (-8270846)) (Coin 459300)))]))"}
```
or even better: A JSON representation of the error .
Contributor guide
Assessment
This issue has not been assessed yet.