Skip to content

Commit

Permalink
Merge #4089
Browse files Browse the repository at this point in the history
4089: Update tx view to render inline datums and reference inputs r=Jimbo4350 a=Jimbo4350

Resolves: #4045 and #4039

Co-authored-by: Jordan Millar <[email protected]>
  • Loading branch information
iohk-bors[bot] and Jimbo4350 authored Jun 24, 2022
2 parents fd7eccf + 519ab7a commit 624ec84
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cardano-cli/src/Cardano/CLI/Run/Friendly.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ friendlyTxBody
, txMetadata
, txMintValue
, txOuts
, txInsReference
, txUpdateProposal
, txValidityRange
, txWithdrawals
Expand All @@ -85,6 +86,7 @@ friendlyTxBody
, "metadata" .= friendlyMetadata txMetadata
, "mint" .= friendlyMintValue txMintValue
, "outputs" .= map friendlyTxOut txOuts
, "reference inputs" .= friendlyReferenceInputs txInsReference
, "required signers (payment key hashes needed for scripts)" .=
friendlyExtraKeyWits txExtraKeyWits
, "update proposal" .= friendlyUpdateProposal txUpdateProposal
Expand Down Expand Up @@ -179,7 +181,9 @@ friendlyTxOut (TxOut addr amount mdatum script) =
Aeson.String $ serialiseToRawBytesHexText h
renderDatum (TxOutDatumInTx _ sData) =
scriptDataToJson ScriptDataJsonDetailedSchema sData
renderDatum (TxOutDatumInline _ _) = panic "TODO: Babbage"
renderDatum (TxOutDatumInline _ sData) =
scriptDataToJson ScriptDataJsonDetailedSchema sData


-- datum ShelleyBasedEraBabbage = panic "TODO: Babbage"

Expand Down Expand Up @@ -452,6 +456,10 @@ friendlyAuxScripts = \case
TxAuxScriptsNone -> Null
TxAuxScripts _ scripts -> String $ textShow scripts

friendlyReferenceInputs :: TxInsReference build era -> Aeson.Value
friendlyReferenceInputs TxInsReferenceNone = Null
friendlyReferenceInputs (TxInsReference _ txins) = toJSON txins

friendlyInputs :: [(TxIn, build)] -> Aeson.Value
friendlyInputs = toJSON . map fst

Expand Down
3 changes: 3 additions & 0 deletions cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1655,6 +1655,9 @@ runTxView = \case
UnwitnessedCliFormattedTxBody anyTxBody -> pure anyTxBody
IncompleteCddlFormattedTx (InAnyCardanoEra era tx) ->
pure $ InAnyCardanoEra era (getTxBody tx)
--TODO: Why are we maintaining friendlyTxBodyBS and friendlyTxBS?
-- In the case of a transaction body, we can simply call makeSignedTransaction []
-- to get a transaction which allows us to reuse friendlyTxBS!
liftIO $ BS.putStr $ friendlyTxBodyBS era txbody
InputTxFile (TxFile txFile) -> do
InAnyCardanoEra era tx <- readFileTx txFile
Expand Down
2 changes: 2 additions & 0 deletions cardano-cli/test/Test/Utilities.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import Data.Algorithm.DiffOutput (ppDiff)
import Hedgehog (MonadTest)
import Hedgehog.Extras.Test.Base (failMessage)

-- TODO: Improve the help output by saying the difference of
-- each input.
diffVsGoldenFile
:: (MonadIO m, MonadTest m)
=> String -- ^ actual content
Expand Down
1 change: 1 addition & 0 deletions cardano-cli/test/data/golden/allegra/transaction-view.out
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ outputs:
reference script: null
stake reference:
stake credential key hash: c0a060899d6806f810547e2cb66f92d5c817a16af2a20f269e258ee0
reference inputs: null
required signers (payment key hashes needed for scripts): null
update proposal: null
validity range:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ inputs:
metadata: null
mint: null
outputs: []
reference inputs: null
required signers (payment key hashes needed for scripts):
- 98717eaba8105a50a2a71831267552e337dfdc893bef5e40b8676d27
- fafaaac8681b5050a8987f95bce4a7f99362f189879258fdbf733fa4
Expand Down
1 change: 1 addition & 0 deletions cardano-cli/test/data/golden/alonzo/transaction-view.out
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ inputs:
metadata: null
mint: null
outputs: []
reference inputs: null
required signers (payment key hashes needed for scripts):
- 98717eaba8105a50a2a71831267552e337dfdc893bef5e40b8676d27
- fafaaac8681b5050a8987f95bce4a7f99362f189879258fdbf733fa4
Expand Down
1 change: 1 addition & 0 deletions cardano-cli/test/data/golden/byron/transaction-view.out
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ outputs:
- address: 5oP9ib6ym3XfwXuy3ksXZzgtBzXSArXAACQVXKqcPhiLnHVYjXJNu2T6Zomh8LAWLV
address era: Byron
amount: 68 Lovelace
reference inputs: null
required signers (payment key hashes needed for scripts): null
update proposal: null
validity range: null
Expand Down
1 change: 1 addition & 0 deletions cardano-cli/test/data/golden/mary/transaction-view.out
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ outputs:
reference script: null
stake reference:
stake credential key hash: c0a060899d6806f810547e2cb66f92d5c817a16af2a20f269e258ee0
reference inputs: null
required signers (payment key hashes needed for scripts): null
update proposal: null
validity range:
Expand Down
1 change: 1 addition & 0 deletions cardano-cli/test/data/golden/shelley/transaction-view.out
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ outputs:
payment credential key hash: bce78cb90f6da9ee778ef07ca881b489c38a188993e6870bd5a9ef77
reference script: null
stake reference: null
reference inputs: null
required signers (payment key hashes needed for scripts): null
update proposal:
epoch: 64
Expand Down

0 comments on commit 624ec84

Please sign in to comment.