Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! cardan…
Browse files Browse the repository at this point in the history
…o-cli: Add withdrawals to transaction-view
  • Loading branch information
cblp committed Apr 15, 2021
1 parent 0a2f3f7 commit f86ebf5
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 33 deletions.
11 changes: 7 additions & 4 deletions cardano-api/src/Cardano/Api/TxBody.hs
Expand Up @@ -1270,9 +1270,12 @@ makeShelleyTransactionBody era@ShelleyBasedEraMary
TxAuxScriptsNone -> []
TxAuxScripts _ ss' -> ss'

getShelleyTxBodyContent :: Shelley.TxBody era
-> Maybe (Shelley.Metadata aux)
-> TxBodyContent ShelleyEra
getShelleyTxBodyContent :: Shelley.TxBody (ShelleyLedgerEra ShelleyEra)
-> Maybe
(Shelley.Metadata (ShelleyLedgerEra ShelleyEra))
-> Either
(TxBodyError ShelleyEra)
(TxBodyContent ShelleyEra)
getShelleyTxBodyContent body auxData = do
guard (Shelley._mdHash body == adHash') ?! TxBodyAuxDataHashInvalidError
pure
Expand Down Expand Up @@ -1308,7 +1311,7 @@ getShelleyTxBodyContent body auxData = do
TxMetadataNone
else
TxMetadataInEra TxMetadataInShelleyEra (TxMetadata ms)
withdrawals = Shelley._wdrls body
Shelley.Wdrl withdrawals = Shelley._wdrls body
txWithdrawals
| null withdrawals = TxWithdrawalsNone
| otherwise =
Expand Down
30 changes: 15 additions & 15 deletions cardano-cli/src/Cardano/CLI/Run/Friendly.hs
Expand Up @@ -23,25 +23,18 @@ import Cardano.Api as Api (AddressInEra (..),
AddressTypeInEra (ByronAddressInAnyEra, ShelleyAddressInEra), CardanoEra,
IsCardanoEra (cardanoEra),
ShelleyBasedEra (ShelleyBasedEraAllegra, ShelleyBasedEraMary, ShelleyBasedEraShelley),
ShelleyEra, TxBody, TxBodyContent (..), TxCertificates (..), TxFee (..),
TxMetadata (..), TxMetadataInEra (..), TxMetadataValue (..), TxMintValue (..),
TxOut (..), TxOutValue (..), TxUpdateProposal (..), TxValidityLowerBound (..),
TxValidityUpperBound (..), TxWithdrawals (..), auxScriptsSupportedInEra,
certificatesSupportedInEra, displayError, getTransactionBodyContent,
multiAssetSupportedInEra, serialiseAddress, serialiseAddressForTxOut,
txMetadataSupportedInEra, updateProposalSupportedInEra,
ShelleyEra, TxAuxScripts (..), TxBody, TxBodyContent (..), TxCertificates (..),
TxFee (..), TxMetadata (..), TxMetadataInEra (..), TxMetadataValue (..),
TxMintValue (..), TxOut (..), TxOutValue (..), TxUpdateProposal (..),
TxValidityLowerBound (..), TxValidityUpperBound (..), TxWithdrawals (..),
auxScriptsSupportedInEra, certificatesSupportedInEra, displayError,
getTransactionBodyContent, multiAssetSupportedInEra, serialiseAddress,
serialiseAddressForTxOut, txMetadataSupportedInEra, updateProposalSupportedInEra,
validityLowerBoundSupportedInEra, validityUpperBoundSupportedInEra,
withdrawalsSupportedInEra)
import Cardano.Api.Byron (Lovelace (..), TxBody (ByronTxBody))
import Cardano.Api.Byron (Lovelace (..))
import Cardano.Api.Shelley (Address (ShelleyAddress), StakeAddress (..),
TxBody (ShelleyTxBody), fromShelleyAddr, fromShelleyStakeAddr)
import Cardano.Binary (Annotated)
import qualified Cardano.Chain.UTxO as Byron
import Cardano.Ledger.Shelley as Ledger (ShelleyEra)
import Cardano.Ledger.ShelleyMA (MaryOrAllegra (Allegra, Mary), ShelleyMAEra)
import qualified Cardano.Ledger.ShelleyMA.TxBody as ShelleyMA
import Ouroboros.Consensus.Shelley.Protocol.Crypto (StandardCrypto)
import Shelley.Spec.Ledger.API (Addr (..))
import qualified Shelley.Spec.Ledger.API as Shelley

import Cardano.CLI.Helpers (textShow)
Expand Down Expand Up @@ -76,6 +69,9 @@ friendlyTxBody txbody =
, "inputs" .= txIns
, "outputs" .= map friendlyTxOut txOuts
]
++ [ "auxiliary scripts" .= friendlyAuxScripts txAuxScripts
| Just _ <- [auxScriptsSupportedInEra era]
]
++ [ "certificates" .= friendlyCertificates txCertificates
| Just _ <- [certificatesSupportedInEra era]
]
Expand Down Expand Up @@ -212,3 +208,7 @@ friendlyMetadataValue = \case
TxMetaNumber int -> toJSON int
-- TxMetaBytes
TxMetaText text -> toJSON text

friendlyAuxScripts :: TxAuxScripts era -> Value
friendlyAuxScripts = \case
TxAuxScriptsNone -> Null
1 change: 1 addition & 0 deletions cardano-cli/test/data/golden/allegra/transaction-view.out
@@ -1,3 +1,4 @@
auxiliary scripts: null
certificates: null
era: Allegra
fee: 100 Lovelace
Expand Down
1 change: 1 addition & 0 deletions cardano-cli/test/data/golden/mary/transaction-view.out
@@ -1,3 +1,4 @@
auxiliary scripts: null
certificates: null
era: Mary
fee: 139 Lovelace
Expand Down
27 changes: 13 additions & 14 deletions cardano-cli/test/data/golden/shelley/transaction-view.out
@@ -1,23 +1,22 @@
auxiliary data: null
certificates: []
certificates: null
era: Shelley
fee: 32
fee: 32 Lovelace
inputs:
- fe5dd07fb576bff960d6e066eade5b26cdb5afebe29f76ea58d0a098bce5d891#29
metadata hash: null
metadata: null
outputs:
- address:
Bech32: addr_test1vz7w0r9epak6nmnh3mc8e2ypkjyu8zsc3xf7dpct6k577acxmcfyv
credential:
key hash: bce78cb90f6da9ee778ef07ca881b489c38a188993e6870bd5a9ef77
network: Testnet
stake reference: StakeRefNull
amount: 31
- address: addr_test1vz7w0r9epak6nmnh3mc8e2ypkjyu8zsc3xf7dpct6k577acxmcfyv
address era: Shelley
amount: 31 Lovelace
network: Testnet
payment credential:
key hash: bce78cb90f6da9ee778ef07ca881b489c38a188993e6870bd5a9ef77
stake reference: null
time to live: 33
update: null
update proposal: null
withdrawals:
- Bech32: stake_test1up00fz9lyqs5sjks82k22eqz7a9srym9vysjgp3h2ua2v2cm522kg
amount: 42
- address: stake_test1up00fz9lyqs5sjks82k22eqz7a9srym9vysjgp3h2ua2v2cm522kg
amount: 42 Lovelace
credential:
key hash: 5ef488bf2021484ad03aaca56402f74b0193656121240637573aa62b
network: Testnet

0 comments on commit f86ebf5

Please sign in to comment.