diff --git a/lib/cli/src/Cardano/CLI.hs b/lib/cli/src/Cardano/CLI.hs index 342e98e3f6c..ff14b661b98 100644 --- a/lib/cli/src/Cardano/CLI.hs +++ b/lib/cli/src/Cardano/CLI.hs @@ -491,6 +491,7 @@ cmdWalletDelete = command "delete" $ info (helper <*> cmd) $ mempty cardano-wallet transaction create [--port=INT] --payment=PAYMENT... cardano-wallet transaction fees [--port=INT] --payment=PAYMENT... + cardano-wallet transaction list [--port=INT] [--after=TIME] [--before=TIME] -------------------------------------------------------------------------------} -- | cardano-wallet transaction @@ -502,6 +503,7 @@ cmdTransaction = command "transaction" $ info (helper <*> cmds) mempty cmds = subparser $ mempty <> cmdTransactionCreate @t <> cmdTransactionFees @t + <> cmdTransactionList @t -- | Arguments for 'transaction create' command data TransactionCreateArgs t = TransactionCreateArgs @@ -554,6 +556,34 @@ cmdTransactionFees = command "fees" $ info (helper <*> cmd) $ mempty Left _ -> handleResponse Aeson.encodePretty res +-- | Arguments for 'transaction list' command. +data TransactionListArgs = TransactionListArgs + { _port :: Port "Wallet" + , _walletId :: WalletId + , _timeAfter :: Maybe Iso8601Time + , _timeBefore :: Maybe Iso8601Time + } + +-- cardano-wallet transaction list [--port=INT] [--after=TIME] [--before=TIME] +cmdTransactionList + :: forall t. (DecodeAddress t, EncodeAddress t) + => Mod CommandFields (IO ()) +cmdTransactionList = command "list" $ info (helper <*> cmd) $ mempty + <> progDesc "List the transactions associated with a wallet" + where + cmd = fmap exec $ TransactionListArgs + <$> portOption + <*> walletIdArgument + <*> optional timeAfterOption + <*> optional timeBeforeOption + exec (TransactionListArgs wPort wId mTimeAfter mTimeBefore) = + runClient wPort Aeson.encodePretty $ listTransactions + (walletClient @t) + (ApiT wId) + (pure $ Iso8601Range + (getIso8601Time <$> mTimeAfter) + (getIso8601Time <$> mTimeBefore)) + {------------------------------------------------------------------------------- Commands - 'address' @@ -717,6 +747,22 @@ stateDirOption = optionT $ mempty <> value "$HOME/.cardano-wallet" <> showDefaultWith show +-- | [--after=TIME] +timeAfterOption :: Parser Iso8601Time +timeAfterOption = optionT $ mempty + <> long "after" + <> metavar "TIME" + <> help "specifies an earliest time" + <> showDefaultWith showT + +-- | [--before=TIME] +timeBeforeOption :: Parser Iso8601Time +timeBeforeOption = optionT $ mempty + <> long "before" + <> metavar "TIME" + <> help "specifies a latest time" + <> showDefaultWith showT + -- | [(--quiet|--verbose)] verbosityOption :: Parser Verbosity verbosityOption = (Quiet <$ quiet) <|> (Verbose <$ verbose) <|> (pure Default)