From c6e006edf3e45cdc13cc5c86c5082362204ac995 Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Mon, 3 Jun 2024 11:33:43 -0500 Subject: [PATCH 1/3] Fix issue 015 --- CHANGELOG.md | 6 ++++++ src/Zenith/CLI.hs | 10 +++++++--- zenith.cabal | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a865617..b8ddb47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.5.3.0-beta] + +## Fixed + +- Wallet sync when no new block has been detected on-chain. + ## [0.5.2.0-beta] ### Changed diff --git a/src/Zenith/CLI.hs b/src/Zenith/CLI.hs index b46d04b..953b0a8 100644 --- a/src/Zenith/CLI.hs +++ b/src/Zenith/CLI.hs @@ -348,7 +348,7 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s] (str " _____ _ _ _ \n|__ /___ _ __ (_) |_| |__\n / // _ \\ '_ \\| | __| '_ \\\n / /| __/ | | | | |_| | | |\n/____\\___|_| |_|_|\\__|_| |_|") <=> C.hCenter - (withAttr titleAttr (str "Zcash Wallet v0.5.2.0-beta")) <=> + (withAttr titleAttr (str "Zcash Wallet v0.5.3.0-beta")) <=> C.hCenter (withAttr blinkAttr $ str "Press any key...")) else emptyWidget capCommand :: String -> String -> Widget Name @@ -590,8 +590,12 @@ scanZebra dbP zHost zPort b eChan = do liftIO $ BC.writeBChan eChan $ TickMsg "Invalid starting block for scan" else do let bList = [(sb + 1) .. (zgb_blocks bStatus)] - let step = (1.0 :: Float) / fromIntegral (zgb_blocks bStatus - (sb + 1)) - mapM_ (processBlock pool step) bList + if not (null bList) + then do + let step = + (1.0 :: Float) / fromIntegral (zgb_blocks bStatus - (sb + 1)) + mapM_ (processBlock pool step) bList + else liftIO $ BC.writeBChan eChan $ TickVal 1.0 where processBlock :: ConnectionPool -> Float -> Int -> IO () processBlock pool step bl = do diff --git a/zenith.cabal b/zenith.cabal index 09a664c..c7dedb1 100644 --- a/zenith.cabal +++ b/zenith.cabal @@ -1,6 +1,6 @@ cabal-version: 3.0 name: zenith -version: 0.5.2.0-beta +version: 0.5.3.0-beta license: MIT license-file: LICENSE author: Rene Vergara From 006c101c0605e6d63f15d7cbbd0ce9840e5b8cf3 Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Mon, 3 Jun 2024 12:18:18 -0500 Subject: [PATCH 2/3] Fix issue 010 --- CHANGELOG.md | 6 +++++- src/Zenith/CLI.hs | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8ddb47..8daee9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.5.3.0-beta] -## Fixed +### Changed + +- Improved formatting of sync progress + +### Fixed - Wallet sync when no new block has been detected on-chain. diff --git a/src/Zenith/CLI.hs b/src/Zenith/CLI.hs index 953b0a8..dcc2e7f 100644 --- a/src/Zenith/CLI.hs +++ b/src/Zenith/CLI.hs @@ -76,6 +76,7 @@ import Lens.Micro ((&), (.~), (^.), set) import Lens.Micro.Mtl import Lens.Micro.TH import System.Hclip +import Text.Printf import Text.Wrap (FillScope(..), FillStrategy(..), WrapSettings(..), wrapText) import ZcashHaskell.Keys (generateWalletSeedPhrase, getWalletSeed) import ZcashHaskell.Orchard (getSaplingFromUA, isValidUnifiedAddress) @@ -453,7 +454,7 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s] , (barToDoAttr, P.progressIncompleteAttr) ]) (P.progressBar - (Just $ show (st ^. barValue * 100)) + (Just $ printf "%.2f%%" (st ^. barValue * 100)) (_barValue st)))) SendDisplay -> withBorderStyle unicodeBold $ From 0ae6e1d45823a026a52a57b8c9bab3ce5a5b9d38 Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Mon, 3 Jun 2024 14:12:47 -0500 Subject: [PATCH 3/3] Enable copying transaction ID --- src/Zenith/CLI.hs | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/Zenith/CLI.hs b/src/Zenith/CLI.hs index dcc2e7f..cfef49d 100644 --- a/src/Zenith/CLI.hs +++ b/src/Zenith/CLI.hs @@ -62,7 +62,7 @@ import Control.Monad (forever, void) import Control.Monad.IO.Class (liftIO) import Control.Monad.Logger (LoggingT, runFileLoggingT, runNoLoggingT) import Data.Aeson -import Data.HexString (toText) +import Data.HexString (HexString(..), toText) import Data.Maybe import qualified Data.Text as T import qualified Data.Text.Encoding as E @@ -139,6 +139,7 @@ data DisplayType | MsgDisplay | PhraseDisplay | TxDisplay + | TxIdDisplay | SyncDisplay | SendDisplay | BlankDisplay @@ -146,6 +147,7 @@ data DisplayType data Tick = TickVal !Float | TickMsg !String + | TickTx !HexString data State = State { _network :: !ZcashNet @@ -170,6 +172,7 @@ data State = State , _eventDispatch :: !(BC.BChan Tick) , _timer :: !Int , _txForm :: !(Form SendInput () Name) + , _sentTx :: !(Maybe HexString) } makeLenses ''State @@ -413,6 +416,16 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s] D.renderDialog (D.dialog (Just $ txt "Message") Nothing 50) (padAll 1 $ strWrap $ st ^. msg) + TxIdDisplay -> + withBorderStyle unicodeBold $ + D.renderDialog + (D.dialog (Just $ txt "Success") Nothing 50) + (padAll 1 $ + (txt "Tx ID: " <+> + txtWrapWith + (WrapSettings False True NoFill FillAfterFirst) + (maybe "None" toText (st ^. sentTx))) <=> + C.hCenter (hBox [capCommand "C" "opy", xCommand])) TxDisplay -> case L.listSelectedElement $ st ^. transactions of Nothing -> emptyWidget @@ -645,16 +658,21 @@ appEvent (BT.AppEvent t) = do MsgDisplay -> return () PhraseDisplay -> return () TxDisplay -> return () + TxIdDisplay -> return () SyncDisplay -> return () SendDisplay -> do BT.modify $ set msg m BlankDisplay -> return () + TickTx txid -> do + BT.modify $ set sentTx (Just txid) + BT.modify $ set displayBox TxIdDisplay TickVal v -> do case s ^. displayBox of AddrDisplay -> return () MsgDisplay -> return () PhraseDisplay -> return () TxDisplay -> return () + TxIdDisplay -> return () SendDisplay -> return () SyncDisplay -> do if s ^. barValue == 1.0 @@ -775,6 +793,16 @@ appEvent (BT.VtyEvent e) = do MsgDisplay -> BT.modify $ set displayBox BlankDisplay PhraseDisplay -> BT.modify $ set displayBox BlankDisplay TxDisplay -> BT.modify $ set displayBox BlankDisplay + TxIdDisplay -> do + case e of + V.EvKey (V.KChar 'x') [] -> + BT.modify $ set displayBox BlankDisplay + V.EvKey (V.KChar 'c') [] -> do + liftIO $ + setClipboard $ + T.unpack $ maybe "None" toText (s ^. sentTx) + BT.modify $ set msg "Copied transaction ID!" + _ev -> return () SendDisplay -> BT.modify $ set displayBox BlankDisplay SyncDisplay -> BT.modify $ set displayBox BlankDisplay BlankDisplay -> do @@ -1063,6 +1091,7 @@ runZenithCLI config = do eventChan 0 (mkSendForm 0 $ SendInput "" 0.0 "") + Nothing Left e -> do print $ "No Zebra node available on port " <> @@ -1272,7 +1301,7 @@ sendTransaction pool chan zHost zPort znet accId bl amt ua memo = do [Data.Aeson.String $ toText rawTx] case resp of Left e1 -> BC.writeBChan chan $ TickMsg $ "Zebra error: " ++ show e1 - Right txId -> BC.writeBChan chan $ TickMsg $ "Tx ID: " ++ txId + Right txId -> BC.writeBChan chan $ TickTx txId where parseAddress :: T.Text -> IO UnifiedAddress parseAddress a =