-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
transaction submit: print transaction hash #925
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,7 @@ import Data.Maybe (catMaybes, fromMaybe, mapMaybe) | |
import Data.Set (Set) | ||
import qualified Data.Set as Set | ||
import qualified Data.Text as Text | ||
import qualified Data.Text.Encoding as T | ||
import qualified Data.Text.IO as Text | ||
import Data.Type.Equality (TestEquality (..)) | ||
import GHC.Exts (IsList (..)) | ||
|
@@ -1483,7 +1484,10 @@ runTransactionSubmitCmd | |
|
||
res <- liftIO $ submitTxToNodeLocal localNodeConnInfo txInMode | ||
case res of | ||
Net.Tx.SubmitSuccess -> liftIO $ Text.putStrLn "Transaction successfully submitted." | ||
Net.Tx.SubmitSuccess -> do | ||
liftIO $ Text.putStrLn "Transaction successfully submitted. Transaction hash is:" | ||
let hashText = T.decodeUtf8 $ serialiseToRawBytesHex (getTxId $ getTxBody tx) | ||
liftIO $ LBS.putStrLn $ Aeson.encode $ TxIdSubmission hashText | ||
Comment on lines
+1488
to
+1490
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The message should go to stderr, the hash should go to stdout. Otherwise it'll be a hassle to separate one from the other. |
||
Net.Tx.SubmitFail reason -> | ||
case reason of | ||
TxValidationErrorInCardanoMode err -> left . TxCmdTxSubmitError . Text.pack $ show err | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE DerivingStrategies #-} | ||
{-# LANGUAGE GADTs #-} | ||
{-# LANGUAGE GeneralisedNewtypeDeriving #-} | ||
|
@@ -68,6 +69,7 @@ module Cardano.CLI.Types.Common | |
, TxBuildOutputOptions (..) | ||
, TxByronWitnessCount (..) | ||
, TxFile | ||
, TxIdSubmission (..) | ||
, TxTreasuryDonation (..) | ||
, TxInCount (..) | ||
, TxMempoolQuery (..) | ||
|
@@ -100,8 +102,10 @@ import Data.Aeson (FromJSON (..), ToJSON (..), object, pairs, (.=)) | |
import qualified Data.Aeson as Aeson | ||
import Data.String (IsString) | ||
import Data.Text (Text) | ||
import qualified Data.Text as T | ||
import qualified Data.Text as Text | ||
import Data.Word (Word64) | ||
import GHC.Generics (Generic) | ||
|
||
-- | Determines the direction in which the MIR certificate will transfer ADA. | ||
data TransferDirection | ||
|
@@ -663,3 +667,12 @@ data PotentiallyCheckedAnchor anchorType anchor | |
-- ^ Whether to check the hash or not (CheckHash for checking or TrustHash for not checking) | ||
} | ||
deriving (Eq, Show) | ||
|
||
-- | Type used for serialization when printing the hash of a transaction | ||
-- after having submitted it. | ||
newtype TxIdSubmission = TxIdSubmission {txhash :: T.Text} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
newtype TxSubmissionResult = TxSubmissionResult {txhash :: TxId} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
^^ this |
||
deriving (Show, Generic) | ||
|
||
instance FromJSON TxIdSubmission | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've put the |
||
|
||
instance ToJSON TxIdSubmission |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This duplicates the
ToJSON TxId
instance. Can we avoid that?