From c0520bcbc7387ea077dc78c9f6bbadb2db5cbd88 Mon Sep 17 00:00:00 2001 From: Rene Vergara A Date: Mon, 9 Dec 2024 21:58:34 -0500 Subject: [PATCH] rvv001 - Added currency code to config File Currency Code is required to get ZEC price from CoinGecho Codes are in IS 4217 alphabetic 3 character format --- app/Main.hs | 9 ++++++++- app/Server.hs | 3 ++- src/Zenith/CLI.hs | 6 +++++- src/Zenith/RPC.hs | 2 +- src/Zenith/Types.hs | 1 + 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index f3d4b4c..fc3964f 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -210,9 +210,16 @@ main = do zebraPort <- require config "zebraPort" zebraHost <- require config "zebraHost" nodePort <- require config "nodePort" + currencyCode <- require config "currencyCode" dbFP <- getZenithPath let dbFilePath = T.pack $ dbFP ++ dbFileName - let myConfig = Config dbFilePath zebraHost zebraPort nodeUser nodePwd nodePort + let myConfig = Config dbFilePath + zebraHost + zebraPort + nodeUser + nodePwd + nodePort + currencyCode if not (null args) then do case head args diff --git a/app/Server.hs b/app/Server.hs index 7944fe3..f4f4c96 100644 --- a/app/Server.hs +++ b/app/Server.hs @@ -35,9 +35,10 @@ main = do zebraPort <- require config "zebraPort" zebraHost <- require config "zebraHost" nodePort <- require config "nodePort" + currencyCode <- require config "currencyCode" dbFP <- getZenithPath let dbFilePath = T.pack $ dbFP ++ dbFileName - let myConfig = Config dbFilePath zebraHost zebraPort nodeUser nodePwd nodePort + let myConfig = Config dbFilePath zebraHost zebraPort nodeUser nodePwd nodePort currencyCode let ctx = authenticate myConfig :. EmptyContext w <- try $ checkZebra zebraHost zebraPort :: IO (Either IOError ZebraGetInfo) case w of diff --git a/src/Zenith/CLI.hs b/src/Zenith/CLI.hs index c2fa1a7..a89b439 100644 --- a/src/Zenith/CLI.hs +++ b/src/Zenith/CLI.hs @@ -245,6 +245,7 @@ data State = State , _deshieldForm :: !(Form ShDshEntry () Name) , _tBalance :: !Integer , _sBalance :: !Integer + , _currencyCode :: !T.Text } makeLenses ''State @@ -948,7 +949,8 @@ appEvent (BT.AppEvent t) = do (s ^. zebraPort) "user" "pwd" - 8080) + 8080 + (s ^. currencyCode)) selWallet updatedState <- BT.get ns <- liftIO $ refreshWallet updatedState @@ -1703,6 +1705,7 @@ runZenithTUI config = do let host = c_zebraHost config let port = c_zebraPort config let dbFilePath = c_dbPath config + let currencyCode = c_currencyCode config pool <- runNoLoggingT $ initPool dbFilePath w <- try $ checkZebra host port :: IO (Either IOError ZebraGetInfo) case w of @@ -1800,6 +1803,7 @@ runZenithTUI config = do (mkDeshieldForm 0 (ShDshEntry 0.0)) tBal sBal + currencyCode Left _e -> do print $ "No Zebra node available on port " <> diff --git a/src/Zenith/RPC.hs b/src/Zenith/RPC.hs index a32fb8f..f0e6e30 100644 --- a/src/Zenith/RPC.hs +++ b/src/Zenith/RPC.hs @@ -916,7 +916,7 @@ scanZebra dbPath zHost zPort net = do updateCommitmentTrees pool zHost zPort $ ZcashNetDB net runNoLoggingT $ mapM_ - (syncWallet (Config dbPath zHost zPort "user" "pwd" 8080)) + (syncWallet (Config dbPath zHost zPort "user" "pwd" 8080 "usd")) wals _ <- completeSync pool Successful return () diff --git a/src/Zenith/Types.hs b/src/Zenith/Types.hs index f71b6c3..e20f5a0 100644 --- a/src/Zenith/Types.hs +++ b/src/Zenith/Types.hs @@ -112,6 +112,7 @@ data Config = Config , c_zenithUser :: !BS.ByteString , c_zenithPwd :: !BS.ByteString , c_zenithPort :: !Int + , c_currencyCode :: !T.Text } deriving (Eq, Prelude.Show) data ZcashPool