Fix assets placement for binary #91
5 changed files with 139 additions and 110 deletions
|
@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Upgraded to GHC 9.6.5
|
- Upgraded to GHC 9.6.5
|
||||||
|
- Implemented config and data folder
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|
|
@ -202,7 +202,7 @@ processUri user pwd =
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
config <- load ["zenith.cfg"]
|
config <- load ["$(HOME)/Zenith/zenith.cfg"]
|
||||||
args <- getArgs
|
args <- getArgs
|
||||||
dbFilePath <- require config "dbFilePath"
|
dbFilePath <- require config "dbFilePath"
|
||||||
{-nodeUser <- require config "nodeUser"-}
|
{-nodeUser <- require config "nodeUser"-}
|
||||||
|
|
|
@ -25,6 +25,8 @@ import Lens.Micro ((&), (+~), (.~), (?~), (^.), set)
|
||||||
import Lens.Micro.TH
|
import Lens.Micro.TH
|
||||||
import Monomer
|
import Monomer
|
||||||
import qualified Monomer.Lens as L
|
import qualified Monomer.Lens as L
|
||||||
|
import System.Directory (getHomeDirectory)
|
||||||
|
import System.FilePath ((</>))
|
||||||
import System.Hclip
|
import System.Hclip
|
||||||
import Text.Printf
|
import Text.Printf
|
||||||
import Text.Wrap (FillScope(..), FillStrategy(..), WrapSettings(..), wrapText)
|
import Text.Wrap (FillScope(..), FillStrategy(..), WrapSettings(..), wrapText)
|
||||||
|
@ -141,6 +143,7 @@ data AppModel = AppModel
|
||||||
, _recipientValid :: !Bool
|
, _recipientValid :: !Bool
|
||||||
, _amountValid :: !Bool
|
, _amountValid :: !Bool
|
||||||
, _showId :: !(Maybe T.Text)
|
, _showId :: !(Maybe T.Text)
|
||||||
|
, _home :: !FilePath
|
||||||
} deriving (Eq, Show)
|
} deriving (Eq, Show)
|
||||||
|
|
||||||
makeLenses ''AppModel
|
makeLenses ''AppModel
|
||||||
|
@ -440,7 +443,11 @@ buildUI wenv model = widgetTree
|
||||||
(fromIntegral $ qrCodeWidth qr))
|
(fromIntegral $ qrCodeWidth qr))
|
||||||
[fitWidth]
|
[fitWidth]
|
||||||
Nothing ->
|
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]
|
[bgColor white, height 100, width 100]
|
||||||
, filler
|
, filler
|
||||||
] `styleBasic`
|
] `styleBasic`
|
||||||
|
@ -504,7 +511,9 @@ buildUI wenv model = widgetTree
|
||||||
, spacer
|
, spacer
|
||||||
, label (showt $ model ^. timer) `styleBasic` [padding 3, textSize 8]
|
, label (showt $ model ^. timer) `styleBasic` [padding 3, textSize 8]
|
||||||
, filler
|
, filler
|
||||||
, image_ "./assets/1F993.png" [fitHeight] `styleBasic`
|
, image_
|
||||||
|
(T.pack $ (model ^. home) </> "Zenith/assets/1F993.png")
|
||||||
|
[fitHeight] `styleBasic`
|
||||||
[height 24, width 24] `nodeVisible`
|
[height 24, width 24] `nodeVisible`
|
||||||
(model ^. zebraOn)
|
(model ^. zebraOn)
|
||||||
, label
|
, label
|
||||||
|
@ -1242,66 +1251,121 @@ txtWrap = wrapText (WrapSettings False True NoFill FillAfterFirst) 32
|
||||||
|
|
||||||
runZenithGUI :: Config -> IO ()
|
runZenithGUI :: Config -> IO ()
|
||||||
runZenithGUI config = do
|
runZenithGUI config = do
|
||||||
let host = c_zebraHost config
|
homeDir <- try getHomeDirectory :: IO (Either IOError FilePath)
|
||||||
let port = c_zebraPort config
|
case homeDir of
|
||||||
let dbFilePath = c_dbPath config
|
Left e -> print e
|
||||||
pool <- runNoLoggingT $ initPool dbFilePath
|
Right hD -> do
|
||||||
w <- try $ checkZebra host port :: IO (Either IOError ZebraGetInfo)
|
let host = c_zebraHost config
|
||||||
case w of
|
let port = c_zebraPort config
|
||||||
Right zebra -> do
|
let dbFilePath = c_dbPath config
|
||||||
bc <-
|
pool <- runNoLoggingT $ initPool dbFilePath
|
||||||
try $ checkBlockChain host port :: IO
|
w <- try $ checkZebra host port :: IO (Either IOError ZebraGetInfo)
|
||||||
(Either IOError ZebraGetBlockChainInfo)
|
case w of
|
||||||
case bc of
|
Right zebra -> do
|
||||||
Left e1 -> throwIO e1
|
bc <-
|
||||||
Right chainInfo -> do
|
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
|
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 =
|
let model =
|
||||||
AppModel
|
AppModel
|
||||||
config
|
config
|
||||||
(zgb_net chainInfo)
|
TestNet
|
||||||
walList
|
[]
|
||||||
0
|
0
|
||||||
accList
|
[]
|
||||||
0
|
0
|
||||||
addrList
|
[]
|
||||||
0
|
0
|
||||||
txList
|
[]
|
||||||
0
|
0
|
||||||
Nothing
|
(Just $
|
||||||
True
|
"Couldn't connect to Zebra on " <>
|
||||||
bal
|
host <> ":" <> showt port <> ". Check your configuration.")
|
||||||
(if unconfBal == 0
|
False
|
||||||
then Nothing
|
314259000
|
||||||
else Just unconfBal)
|
(Just 30000)
|
||||||
Orchard
|
Orchard
|
||||||
qr
|
Nothing
|
||||||
False
|
False
|
||||||
False
|
False
|
||||||
False
|
False
|
||||||
|
@ -1310,10 +1374,7 @@ runZenithGUI config = do
|
||||||
Nothing
|
Nothing
|
||||||
""
|
""
|
||||||
""
|
""
|
||||||
(SaveAddress $
|
(SaveAddress Nothing)
|
||||||
if not (null accList)
|
|
||||||
then Just (head accList)
|
|
||||||
else Nothing)
|
|
||||||
False
|
False
|
||||||
False
|
False
|
||||||
Nothing
|
Nothing
|
||||||
|
@ -1327,61 +1388,26 @@ runZenithGUI config = do
|
||||||
False
|
False
|
||||||
False
|
False
|
||||||
Nothing
|
Nothing
|
||||||
startApp model handleEvent buildUI params
|
hD
|
||||||
Left e -> do
|
startApp model handleEvent buildUI (params hD)
|
||||||
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
|
|
||||||
where
|
where
|
||||||
params =
|
params hd =
|
||||||
[ appWindowTitle "Zenith - Zcash Full Node Wallet"
|
[ appWindowTitle "Zenith - Zcash Full Node Wallet"
|
||||||
, appWindowState $ MainWindowNormal (1000, 700)
|
, appWindowState $ MainWindowNormal (1000, 700)
|
||||||
, appTheme zenithTheme
|
, appTheme zenithTheme
|
||||||
, appFontDef "Regular" "./assets/Atkinson-Hyperlegible-Regular-102.ttf" --"./assets/DejaVuSansMono.ttf"
|
, appFontDef
|
||||||
, appFontDef "Bold" "./assets/Atkinson-Hyperlegible-Bold-102.ttf"
|
"Regular"
|
||||||
, appFontDef "Italic" "./assets/Atkinson-Hyperlegible-Italic-102.ttf"
|
(T.pack $
|
||||||
, appFontDef "Remix" "./assets/remixicon.ttf"
|
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
|
, appDisableAutoScale True
|
||||||
, appScaleFactor 2.0
|
, appScaleFactor 2.0
|
||||||
, appInitEvent AppInit
|
, appInitEvent AppInit
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 90c8a7c3028bd6836dea5655221277a25d457653
|
Subproject commit e8074419cfb54559a4c09731ad2448d5930869a2
|
|
@ -47,6 +47,8 @@ library
|
||||||
, brick
|
, brick
|
||||||
, bytestring
|
, bytestring
|
||||||
, data-default
|
, data-default
|
||||||
|
, directory
|
||||||
|
, filepath
|
||||||
, esqueleto
|
, esqueleto
|
||||||
, resource-pool
|
, resource-pool
|
||||||
, binary
|
, binary
|
||||||
|
|
Loading…
Reference in a new issue