diff --git a/.gitignore b/.gitignore index 00967d7..9a0f49a 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ zenith.db zenith.log zenith.db-shm zenith.db-wal +installer/*.tar.gz +installer/*.tar.gz.prev +docker_files/zenith-docker_* diff --git a/CHANGELOG.md b/CHANGELOG.md index c8a191c..3432612 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Upgraded to GHC 9.6.5 +- Implemented config and data folder ### Fixed diff --git a/app/Main.hs b/app/Main.hs index 2fafb7d..2823ba4 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -202,7 +202,7 @@ processUri user pwd = main :: IO () main = do - config <- load [ "$(HOME)/Zenith/zenith.cfg" ] + config <- load ["$(HOME)/Zenith/zenith.cfg"] args <- getArgs dbFileName <- require config "dbFileName" {-nodeUser <- require config "nodeUser"-} diff --git a/docker_files/Dockerfile b/docker_files/Dockerfile index 5d51067..57d7008 100644 --- a/docker_files/Dockerfile +++ b/docker_files/Dockerfile @@ -28,9 +28,9 @@ RUN echo "1234\n1234\n" | passwd zenusr RUN mkdir /home/zenusr/Zenith RUN chown zenusr:zenusr -R /home/zenusr/Zenith -RUN mkdir /home/zenusr/assets -COPY assets/* /home/zenusr/assets/ -RUN chown zenusr:zenusr -R /home/zenusr/assets +#RUN mkdir /home/zenusr/Zenith/assets +#COPY assets/* /home/zenusr/Zenith/assets/ +#RUN chown zenusr:zenusr -R /home/zenusr/Zenith/assets COPY scripts/bash_rc_adm /root/.bashrc COPY scripts/bash_rc_usr /home/zenusr/.bashrc diff --git a/docker_files/setup_docker b/docker_files/setup_docker index 8c8bf2d..a1c1308 100644 --- a/docker_files/setup_docker +++ b/docker_files/setup_docker @@ -1,4 +1,4 @@ -#/bin/bash +#!/bin/bash ZVERSION="0.6.0.0" echo echo "Zenith Full Node Docker Image Setup" @@ -27,8 +27,10 @@ if systemctl is-active --quiet docker; then docker load < zenith-docker_$ZVERSION.tar echo "... docker image zenith-docker:"$ZVERSION" loaded." echo "... creating Zenith folder" - mkdir $HOME/Zenith + mkdir -p $HOME/Zenith/assets + echo "... creating default configuration" cp cfg/zenith.cfg $HOME/Zenith/ + cp -r /assets/ $HOME/Zenith/assets if ! [ -d $HOME/.local/bin ]; then echo "... creating $HOME/.local/bin folder" mkdir -p $HOME/.local/bin @@ -38,10 +40,10 @@ if systemctl is-active --quiet docker; then if [ -f $HOME/.local/bin/runzenith ]; then rm $HOME/.local/bin/runzenith fi - echo "... copying runzenith to $HOME/.local/bin " + echo "... copying runzenith to $HOME/.local/bin" cp cfg/runzenith $HOME/.local/bin/ if echo $PATH | grep -q $HOME/.local/bin ; then - echo PATH=$PATH:$HOME/.local/bin' | tee -a $HOME/.bashrc + echo PATH=$PATH:$HOME/.local/bin | tee -a $HOME/.bashrc echo "Reloading configuration ...." source $HOME/.bashrc fi diff --git a/installer/zenith-0.6.0.0-amd64.tar.gz b/installer/zenith-0.6.0.0-amd64.tar.gz index 473edde..9ef4bb1 100644 Binary files a/installer/zenith-0.6.0.0-amd64.tar.gz and b/installer/zenith-0.6.0.0-amd64.tar.gz differ diff --git a/installer/zenith-0.6.0.0-amd64/bin/1F616_color.png b/installer/zenith-0.6.0.0-amd64/bin/1F616_color.png deleted file mode 100644 index ac48165..0000000 Binary files a/installer/zenith-0.6.0.0-amd64/bin/1F616_color.png and /dev/null differ diff --git a/installer/zenith-0.6.0.0-amd64/bin/1F928_color.png b/installer/zenith-0.6.0.0-amd64/bin/1F928_color.png deleted file mode 100644 index 10095c0..0000000 Binary files a/installer/zenith-0.6.0.0-amd64/bin/1F928_color.png and /dev/null differ diff --git a/installer/zenith-0.6.0.0-amd64/bin/1F993.png b/installer/zenith-0.6.0.0-amd64/bin/1F993.png deleted file mode 100644 index 290f365..0000000 Binary files a/installer/zenith-0.6.0.0-amd64/bin/1F993.png and /dev/null differ diff --git a/installer/zenith-0.6.0.0-amd64/bin/2620_color.png b/installer/zenith-0.6.0.0-amd64/bin/2620_color.png deleted file mode 100644 index ecfdc10..0000000 Binary files a/installer/zenith-0.6.0.0-amd64/bin/2620_color.png and /dev/null differ diff --git a/installer/zenith-0.6.0.0-amd64/bin/Atkinson-Hyperlegible-Bold-102.ttf b/installer/zenith-0.6.0.0-amd64/bin/Atkinson-Hyperlegible-Bold-102.ttf deleted file mode 100644 index 14b7196..0000000 Binary files a/installer/zenith-0.6.0.0-amd64/bin/Atkinson-Hyperlegible-Bold-102.ttf and /dev/null differ diff --git a/installer/zenith-0.6.0.0-amd64/bin/Atkinson-Hyperlegible-BoldItalic-102.ttf b/installer/zenith-0.6.0.0-amd64/bin/Atkinson-Hyperlegible-BoldItalic-102.ttf deleted file mode 100644 index 4532705..0000000 Binary files a/installer/zenith-0.6.0.0-amd64/bin/Atkinson-Hyperlegible-BoldItalic-102.ttf and /dev/null differ diff --git a/installer/zenith-0.6.0.0-amd64/bin/Atkinson-Hyperlegible-Font-License-2020-1104.pdf b/installer/zenith-0.6.0.0-amd64/bin/Atkinson-Hyperlegible-Font-License-2020-1104.pdf deleted file mode 100644 index afe27dc..0000000 Binary files a/installer/zenith-0.6.0.0-amd64/bin/Atkinson-Hyperlegible-Font-License-2020-1104.pdf and /dev/null differ diff --git a/installer/zenith-0.6.0.0-amd64/bin/Atkinson-Hyperlegible-Italic-102.ttf b/installer/zenith-0.6.0.0-amd64/bin/Atkinson-Hyperlegible-Italic-102.ttf deleted file mode 100644 index 89e5ce4..0000000 Binary files a/installer/zenith-0.6.0.0-amd64/bin/Atkinson-Hyperlegible-Italic-102.ttf and /dev/null differ diff --git a/installer/zenith-0.6.0.0-amd64/bin/Atkinson-Hyperlegible-Regular-102.ttf b/installer/zenith-0.6.0.0-amd64/bin/Atkinson-Hyperlegible-Regular-102.ttf deleted file mode 100644 index c4fa6fb..0000000 Binary files a/installer/zenith-0.6.0.0-amd64/bin/Atkinson-Hyperlegible-Regular-102.ttf and /dev/null differ diff --git a/installer/zenith-0.6.0.0-amd64/bin/DejaVuSansMono-Bold.ttf b/installer/zenith-0.6.0.0-amd64/bin/DejaVuSansMono-Bold.ttf deleted file mode 100644 index b210eb5..0000000 Binary files a/installer/zenith-0.6.0.0-amd64/bin/DejaVuSansMono-Bold.ttf and /dev/null differ diff --git a/installer/zenith-0.6.0.0-amd64/bin/DejaVuSansMono-BoldOblique.ttf b/installer/zenith-0.6.0.0-amd64/bin/DejaVuSansMono-BoldOblique.ttf deleted file mode 100644 index 3211064..0000000 Binary files a/installer/zenith-0.6.0.0-amd64/bin/DejaVuSansMono-BoldOblique.ttf and /dev/null differ diff --git a/installer/zenith-0.6.0.0-amd64/bin/DejaVuSansMono-Oblique.ttf b/installer/zenith-0.6.0.0-amd64/bin/DejaVuSansMono-Oblique.ttf deleted file mode 100644 index ff83b15..0000000 Binary files a/installer/zenith-0.6.0.0-amd64/bin/DejaVuSansMono-Oblique.ttf and /dev/null differ diff --git a/installer/zenith-0.6.0.0-amd64/bin/DejaVuSansMono.ttf b/installer/zenith-0.6.0.0-amd64/bin/DejaVuSansMono.ttf deleted file mode 100644 index 041cffc..0000000 Binary files a/installer/zenith-0.6.0.0-amd64/bin/DejaVuSansMono.ttf and /dev/null differ diff --git a/installer/zenith-0.6.0.0-amd64/bin/OpenMoji-color-glyf_colr_1.ttf b/installer/zenith-0.6.0.0-amd64/bin/OpenMoji-color-glyf_colr_1.ttf deleted file mode 100644 index 86cf85b..0000000 Binary files a/installer/zenith-0.6.0.0-amd64/bin/OpenMoji-color-glyf_colr_1.ttf and /dev/null differ diff --git a/installer/zenith-0.6.0.0-amd64/bin/Roboto-Regular.ttf b/installer/zenith-0.6.0.0-amd64/bin/Roboto-Regular.ttf deleted file mode 100644 index 8c082c8..0000000 Binary files a/installer/zenith-0.6.0.0-amd64/bin/Roboto-Regular.ttf and /dev/null differ diff --git a/installer/zenith-0.6.0.0-amd64/bin/remixicon.ttf b/installer/zenith-0.6.0.0-amd64/bin/remixicon.ttf deleted file mode 100644 index 22ce6de..0000000 Binary files a/installer/zenith-0.6.0.0-amd64/bin/remixicon.ttf and /dev/null differ diff --git a/installer/zenith-0.6.0.0-amd64/bin/zenith b/installer/zenith-0.6.0.0-amd64/bin/zenith index 49a0648..f8e0773 100755 Binary files a/installer/zenith-0.6.0.0-amd64/bin/zenith and b/installer/zenith-0.6.0.0-amd64/bin/zenith differ diff --git a/installer/zenith-0.6.0.0-amd64/zenconfig b/installer/zenith-0.6.0.0-amd64/zenconfig index 8202fc5..584e6e1 100755 --- a/installer/zenith-0.6.0.0-amd64/zenconfig +++ b/installer/zenith-0.6.0.0-amd64/zenconfig @@ -15,12 +15,11 @@ else mkdir -p $HOME/Zenith echo "Copying default configuration ...." cp ./cfg/zenith.cfg $HOME/Zenith/ - chown -R $USER $HOME/Zenith echo "Creating assets folder ...." - mkdir -p $HOME/assets + mkdir -p $HOME/Zenith/assets echo "Transfering assets to new folder ...." - cp ./assets/* $HOME/assets - chown -R $USER $HOME/assets + cp ./assets/* $HOME/Zenith/assets + chown -R $USER $HOME/Zenith echo "Configuring library path ...." if [ ! grep -q "LD_LIBRARY_PATH" "$HOME/.bashrc" ]; then echo 'export LD_LIBRARY_PATH=/usr/local/lib' | tee -a $HOME/.bashrc diff --git a/src/Zenith/GUI.hs b/src/Zenith/GUI.hs index 0227002..c0b4623 100644 --- a/src/Zenith/GUI.hs +++ b/src/Zenith/GUI.hs @@ -25,6 +25,8 @@ import Lens.Micro ((&), (+~), (.~), (?~), (^.), set) import Lens.Micro.TH import Monomer import qualified Monomer.Lens as L +import System.Directory (getHomeDirectory) +import System.FilePath (()) import System.Hclip import Text.Printf import Text.Wrap (FillScope(..), FillStrategy(..), WrapSettings(..), wrapText) @@ -141,6 +143,7 @@ data AppModel = AppModel , _recipientValid :: !Bool , _amountValid :: !Bool , _showId :: !(Maybe T.Text) + , _home :: !FilePath } deriving (Eq, Show) makeLenses ''AppModel @@ -440,7 +443,11 @@ buildUI wenv model = widgetTree (fromIntegral $ qrCodeWidth qr)) [fitWidth] Nothing -> - image_ "./assets/1F928_color.png" [fitEither]) `styleBasic` + image_ + (T.pack $ + (model ^. home) + "Zenith/assets/1F928_color.png") + [fitEither]) `styleBasic` [bgColor white, height 100, width 100] , filler ] `styleBasic` @@ -504,7 +511,9 @@ buildUI wenv model = widgetTree , spacer , label (showt $ model ^. timer) `styleBasic` [padding 3, textSize 8] , filler - , image_ "./assets/1F993.png" [fitHeight] `styleBasic` + , image_ + (T.pack $ (model ^. home) "Zenith/assets/1F993.png") + [fitHeight] `styleBasic` [height 24, width 24] `nodeVisible` (model ^. zebraOn) , label @@ -1242,66 +1251,121 @@ txtWrap = wrapText (WrapSettings False True NoFill FillAfterFirst) 32 runZenithGUI :: Config -> IO () runZenithGUI config = do - let host = c_zebraHost config - let port = c_zebraPort config - let dbFilePath = c_dbPath config - pool <- runNoLoggingT $ initPool dbFilePath - w <- try $ checkZebra host port :: IO (Either IOError ZebraGetInfo) - case w of - Right zebra -> do - bc <- - try $ checkBlockChain host port :: IO - (Either IOError ZebraGetBlockChainInfo) - case bc of - Left e1 -> throwIO e1 - Right chainInfo -> do + homeDir <- try getHomeDirectory :: IO (Either IOError FilePath) + case homeDir of + Left e -> print e + Right hD -> do + let host = c_zebraHost config + let port = c_zebraPort config + let dbFilePath = c_dbPath config + pool <- runNoLoggingT $ initPool dbFilePath + w <- try $ checkZebra host port :: IO (Either IOError ZebraGetInfo) + case w of + Right zebra -> do + bc <- + try $ checkBlockChain host port :: IO + (Either IOError ZebraGetBlockChainInfo) + case bc of + Left e1 -> throwIO e1 + Right chainInfo -> do + initDb dbFilePath + generateQRCodes config + walList <- getWallets pool $ zgb_net chainInfo + accList <- + if not (null walList) + then runNoLoggingT $ + getAccounts pool $ entityKey $ head walList + else return [] + addrList <- + if not (null accList) + then runNoLoggingT $ + getAddresses pool $ entityKey $ head accList + else return [] + txList <- + if not (null addrList) + then getUserTx pool $ entityKey $ head addrList + else return [] + qr <- + if not (null addrList) + then getQrCode pool Orchard $ entityKey $ head addrList + else return Nothing + bal <- + if not (null accList) + then getBalance pool $ entityKey $ head accList + else return 0 + unconfBal <- + if not (null accList) + then getUnconfirmedBalance pool $ entityKey $ head accList + else return 0 + let model = + AppModel + config + (zgb_net chainInfo) + walList + 0 + accList + 0 + addrList + 0 + txList + 0 + Nothing + True + bal + (if unconfBal == 0 + then Nothing + else Just unconfBal) + Orchard + qr + False + False + False + False + "" + Nothing + "" + "" + (SaveAddress $ + if not (null accList) + then Just (head accList) + else Nothing) + False + False + Nothing + Nothing + 0 + 1.0 + False + "" + 0.0 + "" + False + False + Nothing + hD + startApp model handleEvent buildUI (params hD) + Left e -> do initDb dbFilePath - generateQRCodes config - walList <- getWallets pool $ zgb_net chainInfo - accList <- - if not (null walList) - then runNoLoggingT $ getAccounts pool $ entityKey $ head walList - else return [] - addrList <- - if not (null accList) - then runNoLoggingT $ getAddresses pool $ entityKey $ head accList - else return [] - txList <- - if not (null addrList) - then getUserTx pool $ entityKey $ head addrList - else return [] - qr <- - if not (null addrList) - then getQrCode pool Orchard $ entityKey $ head addrList - else return Nothing - bal <- - if not (null accList) - then getBalance pool $ entityKey $ head accList - else return 0 - unconfBal <- - if not (null accList) - then getUnconfirmedBalance pool $ entityKey $ head accList - else return 0 let model = AppModel config - (zgb_net chainInfo) - walList + TestNet + [] 0 - accList + [] 0 - addrList + [] 0 - txList + [] 0 - Nothing - True - bal - (if unconfBal == 0 - then Nothing - else Just unconfBal) + (Just $ + "Couldn't connect to Zebra on " <> + host <> ":" <> showt port <> ". Check your configuration.") + False + 314259000 + (Just 30000) Orchard - qr + Nothing False False False @@ -1310,10 +1374,7 @@ runZenithGUI config = do Nothing "" "" - (SaveAddress $ - if not (null accList) - then Just (head accList) - else Nothing) + (SaveAddress Nothing) False False Nothing @@ -1327,61 +1388,26 @@ runZenithGUI config = do False False Nothing - startApp model handleEvent buildUI params - Left e -> do - initDb dbFilePath - let model = - AppModel - config - TestNet - [] - 0 - [] - 0 - [] - 0 - [] - 0 - (Just $ - "Couldn't connect to Zebra on " <> - host <> ":" <> showt port <> ". Check your configuration.") - False - 314259000 - (Just 30000) - Orchard - Nothing - False - False - False - False - "" - Nothing - "" - "" - (SaveAddress Nothing) - False - False - Nothing - Nothing - 0 - 1.0 - False - "" - 0.0 - "" - False - False - Nothing - startApp model handleEvent buildUI params + hD + startApp model handleEvent buildUI (params hD) where - params = + params hd = [ appWindowTitle "Zenith - Zcash Full Node Wallet" , appWindowState $ MainWindowNormal (1000, 700) , appTheme zenithTheme - , appFontDef "Regular" "./assets/Atkinson-Hyperlegible-Regular-102.ttf" --"./assets/DejaVuSansMono.ttf" - , appFontDef "Bold" "./assets/Atkinson-Hyperlegible-Bold-102.ttf" - , appFontDef "Italic" "./assets/Atkinson-Hyperlegible-Italic-102.ttf" - , appFontDef "Remix" "./assets/remixicon.ttf" + , appFontDef + "Regular" + (T.pack $ + hd + "Zenith/assets/Atkinson-Hyperlegible-Regular-102.ttf" --"./assets/DejaVuSansMono.ttf" + ) + , appFontDef + "Bold" + (T.pack $ hd "Zenith/assets/Atkinson-Hyperlegible-Bold-102.ttf") + , appFontDef + "Italic" + (T.pack $ hd "Zenith/assets/Atkinson-Hyperlegible-Italic-102.ttf") + , appFontDef "Remix" (T.pack $ hd "Zenith/assets/remixicon.ttf") , appDisableAutoScale True , appScaleFactor 2.0 , appInitEvent AppInit diff --git a/zenith.cabal b/zenith.cabal index 61b090c..526c1af 100644 --- a/zenith.cabal +++ b/zenith.cabal @@ -47,6 +47,8 @@ library , brick , bytestring , data-default + , directory + , filepath , esqueleto , resource-pool , binary