Compare commits
No commits in common. "9bb42bd7c9428c48153a86544cb67013036256a0" and "80f873cffdaf11e4fc99ee3d73a19b40af442a52" have entirely different histories.
9bb42bd7c9
...
80f873cffd
10 changed files with 20 additions and 165 deletions
|
@ -5,15 +5,6 @@ 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).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## Added
|
||||
|
||||
- `Core` module
|
||||
- `CLI` module
|
||||
- `DB` module
|
||||
- Command line arguments to switch to legacy version
|
||||
|
||||
## [0.4.1]
|
||||
|
||||
### Fixed
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
module Main where
|
||||
|
||||
import Brick (simpleMain)
|
||||
import Control.Monad (void)
|
||||
import Control.Monad.IO.Class (liftIO)
|
||||
import qualified Data.ByteString as B
|
||||
|
@ -199,7 +200,6 @@ main :: IO ()
|
|||
main = do
|
||||
config <- load ["zenith.cfg"]
|
||||
args <- getArgs
|
||||
dbName <- require config "dbName"
|
||||
nodeUser <- require config "nodeUser"
|
||||
nodePwd <- require config "nodePwd"
|
||||
if not (null args)
|
||||
|
@ -215,7 +215,7 @@ main = do
|
|||
" ______ _ _ _ \n |___ / (_) | | | \n / / ___ _ __ _| |_| |__ \n / / / _ \\ '_ \\| | __| '_ \\ \n / /_| __/ | | | | |_| | | |\n /_____\\___|_| |_|_|\\__|_| |_|\n Zcash Full Node CLI v0.4.0"
|
||||
}
|
||||
(root nodeUser nodePwd)
|
||||
"cli" -> runZenithCLI dbName
|
||||
"cli" -> simpleMain ui
|
||||
_ -> printUsage
|
||||
else printUsage
|
||||
|
||||
|
|
|
@ -44,11 +44,6 @@ library:
|
|||
- persistent-sqlite
|
||||
- persistent-template
|
||||
- brick
|
||||
- mtl
|
||||
- microlens
|
||||
- microlens-mtl
|
||||
- microlens-th
|
||||
- vty
|
||||
- zcash-haskell
|
||||
|
||||
executables:
|
||||
|
|
|
@ -1,122 +1,13 @@
|
|||
{-# LANGUAGE TemplateHaskell #-}
|
||||
|
||||
module Zenith.CLI where
|
||||
|
||||
import Control.Monad (void)
|
||||
import Control.Monad.State (modify)
|
||||
import Data.Maybe (fromMaybe)
|
||||
import qualified Data.Text as T
|
||||
import qualified Graphics.Vty as V
|
||||
import Lens.Micro ((^.))
|
||||
import Lens.Micro.Mtl
|
||||
import Lens.Micro.TH
|
||||
|
||||
import qualified Brick.AttrMap as A
|
||||
import qualified Brick.Main as M
|
||||
import qualified Brick.Types as BT
|
||||
import Brick.Types (Widget)
|
||||
import Brick.Util (fg, on)
|
||||
import qualified Brick.Widgets.Border as B
|
||||
import Brick (Widget, (<+>), joinBorders, simpleMain, str, withBorderStyle)
|
||||
import Brick.Widgets.Border (borderWithLabel, vBorder)
|
||||
import Brick.Widgets.Border.Style (unicode)
|
||||
import qualified Brick.Widgets.Center as C
|
||||
import Brick.Widgets.Core
|
||||
( (<+>)
|
||||
, hLimit
|
||||
, joinBorders
|
||||
, str
|
||||
, vBox
|
||||
, vLimit
|
||||
, withAttr
|
||||
, withBorderStyle
|
||||
)
|
||||
import qualified Brick.Widgets.List as L
|
||||
import qualified Data.Vector as Vec
|
||||
import Zenith.Core
|
||||
import Brick.Widgets.Center (center)
|
||||
|
||||
data Name
|
||||
= WList
|
||||
| AList
|
||||
| TList
|
||||
deriving (Eq, Show, Ord)
|
||||
|
||||
data State = State
|
||||
{ _network :: String
|
||||
, _wallets :: L.List Name String
|
||||
, _addresses :: L.List Name String
|
||||
, _transactions :: L.List Name String
|
||||
} deriving (Show)
|
||||
|
||||
makeLenses ''State
|
||||
|
||||
drawUI :: State -> [Widget Name]
|
||||
drawUI s = [ui s]
|
||||
where
|
||||
ui :: State -> Widget Name
|
||||
ui s =
|
||||
ui :: Widget ()
|
||||
ui =
|
||||
joinBorders $
|
||||
withBorderStyle unicode $
|
||||
B.borderWithLabel (str $ "Zenith - " <> s ^. network) $
|
||||
(C.center (listBox "Addresses" (s ^. addresses)) <+>
|
||||
B.vBorder <+> C.center (listBox "Transactions" (s ^. transactions)))
|
||||
listBox :: String -> L.List Name String -> Widget Name
|
||||
listBox titleLabel l =
|
||||
C.vCenter $
|
||||
vBox
|
||||
[ C.hCenter
|
||||
(B.borderWithLabel (str titleLabel) $
|
||||
hLimit 25 $ vLimit 15 $ L.renderList listDrawElement True l)
|
||||
, str " "
|
||||
, C.hCenter $ str "Select "
|
||||
]
|
||||
|
||||
listDrawElement :: (Show a) => Bool -> a -> Widget Name
|
||||
listDrawElement sel a =
|
||||
let selStr s =
|
||||
if sel
|
||||
then withAttr customAttr (str $ "<" <> s <> ">")
|
||||
else str s
|
||||
in C.hCenter $ selStr $ show a
|
||||
|
||||
initialState :: State
|
||||
initialState =
|
||||
State
|
||||
"Main"
|
||||
(L.list WList (Vec.fromList ["wall1"]) 1)
|
||||
(L.list AList (Vec.fromList ["addr1", "addr2"]) 1)
|
||||
(L.list TList (Vec.fromList ["tx1", "tx2", "tx3"]) 1)
|
||||
|
||||
customAttr :: A.AttrName
|
||||
customAttr = L.listSelectedAttr <> A.attrName "custom"
|
||||
|
||||
appEvent :: BT.BrickEvent Name e -> BT.EventM Name State ()
|
||||
appEvent (BT.VtyEvent e) =
|
||||
case e of
|
||||
V.EvKey V.KEsc [] -> M.halt
|
||||
ev -> BT.zoom addresses $ L.handleListEvent ev
|
||||
|
||||
theMap :: A.AttrMap
|
||||
theMap =
|
||||
A.attrMap
|
||||
V.defAttr
|
||||
[ (L.listAttr, V.white `on` V.blue)
|
||||
, (L.listSelectedAttr, V.blue `on` V.white)
|
||||
, (customAttr, fg V.cyan)
|
||||
]
|
||||
|
||||
theApp :: M.App State e Name
|
||||
theApp =
|
||||
M.App
|
||||
{ M.appDraw = drawUI
|
||||
, M.appChooseCursor = M.showFirstCursor
|
||||
, M.appHandleEvent = appEvent
|
||||
, M.appStartEvent = return ()
|
||||
, M.appAttrMap = const theMap
|
||||
}
|
||||
|
||||
runZenithCLI :: T.Text -> IO ()
|
||||
runZenithCLI dbName = do
|
||||
w <- checkWallets dbName
|
||||
if (null w)
|
||||
then void $ M.defaultMain theApp initialState
|
||||
else do
|
||||
print "No wallet found. Create one? Y/N"
|
||||
borderWithLabel (str "Zenith") $
|
||||
(center (str "Addresses") <+> vBorder <+> center (str "Transactions"))
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
module Zenith.Core where
|
||||
|
||||
import qualified Data.Text as T
|
||||
import Database.Persist
|
||||
import Database.Persist.Sqlite
|
||||
import Zenith.DB
|
||||
|
||||
checkWallets :: T.Text -> IO [Entity ZcashWallet]
|
||||
checkWallets dbName = do
|
||||
runSqlite dbName $ do runMigration migrateAll
|
||||
wallets <- runSqlite dbName $ selectList [ZcashWalletBirthdayHeight >. 0] []
|
||||
return wallets
|
|
@ -21,9 +21,7 @@ import qualified Data.Text as T
|
|||
import Database.Persist
|
||||
import Database.Persist.Sqlite
|
||||
import Database.Persist.TH
|
||||
import ZcashHaskell.Types (Phrase, ZcashNet)
|
||||
|
||||
derivePersistField "ZcashNet"
|
||||
import ZcashHaskell.Types (Phrase)
|
||||
|
||||
share
|
||||
[mkPersist sqlSettings, mkMigrate "migrateAll"]
|
||||
|
@ -34,6 +32,5 @@ share
|
|||
tPrivateKey BS.ByteString
|
||||
birthdayHeight Int
|
||||
name T.Text
|
||||
network ZcashNet
|
||||
deriving Show
|
||||
|]
|
||||
|
|
|
@ -44,9 +44,9 @@ packages:
|
|||
# extra-deps: []
|
||||
extra-deps:
|
||||
- git: https://git.vergara.tech/Vergara_Tech/zcash-haskell.git
|
||||
commit: c4f345b1deb876e19a51c5f7ae1b4402fae14126
|
||||
commit: 6ea8698ccb5e44f9900ba0e61c6ffe6cba900139
|
||||
- git: https://git.vergara.tech/Vergara_Tech/haskell-hexstring.git
|
||||
commit: fd1ddce73c0ad18a2a4509a299c6e93f8c6c383d
|
||||
commit: fe2df6f7d63272ac147911c1573550bed1d38a37
|
||||
- git: https://git.vergara.tech/Vergara_Tech/haskell-foreign-rust.git
|
||||
commit: 787c2e813eb3a5d16c375d4b37dfefbd2adcdf05
|
||||
- git: https://github.com/well-typed/borsh.git
|
||||
|
|
|
@ -5,26 +5,26 @@
|
|||
|
||||
packages:
|
||||
- completed:
|
||||
commit: c4f345b1deb876e19a51c5f7ae1b4402fae14126
|
||||
commit: 6ea8698ccb5e44f9900ba0e61c6ffe6cba900139
|
||||
git: https://git.vergara.tech/Vergara_Tech/zcash-haskell.git
|
||||
name: zcash-haskell
|
||||
pantry-tree:
|
||||
sha256: 1bf709484bc488e51e18aa11001abdc06100ed7086b9bbd765d28c4a3d8e9113
|
||||
sha256: 0506f9f095dbb134a4e7b3ba73a60a21c6298cbea01409871141b31cd0cf9c46
|
||||
size: 1366
|
||||
version: 0.4.1
|
||||
original:
|
||||
commit: c4f345b1deb876e19a51c5f7ae1b4402fae14126
|
||||
commit: 6ea8698ccb5e44f9900ba0e61c6ffe6cba900139
|
||||
git: https://git.vergara.tech/Vergara_Tech/zcash-haskell.git
|
||||
- completed:
|
||||
commit: fd1ddce73c0ad18a2a4509a299c6e93f8c6c383d
|
||||
commit: fe2df6f7d63272ac147911c1573550bed1d38a37
|
||||
git: https://git.vergara.tech/Vergara_Tech/haskell-hexstring.git
|
||||
name: hexstring
|
||||
pantry-tree:
|
||||
sha256: 05af6ec085b0c8ac00e0c3043652095a6a9c9d3bd2112ffdcb4c4e28206e0b1c
|
||||
sha256: 71f12a60e85f7e1897b07bb2d4c77794faee50df250d68b0c47b3d343dd4625a
|
||||
size: 741
|
||||
version: 0.12.0
|
||||
original:
|
||||
commit: fd1ddce73c0ad18a2a4509a299c6e93f8c6c383d
|
||||
commit: fe2df6f7d63272ac147911c1573550bed1d38a37
|
||||
git: https://git.vergara.tech/Vergara_Tech/haskell-hexstring.git
|
||||
- completed:
|
||||
commit: 787c2e813eb3a5d16c375d4b37dfefbd2adcdf05
|
||||
|
|
|
@ -26,7 +26,6 @@ source-repository head
|
|||
library
|
||||
exposed-modules:
|
||||
Zenith.CLI
|
||||
Zenith.Core
|
||||
Zenith.DB
|
||||
Zenith.Types
|
||||
Zenith.Utils
|
||||
|
@ -45,10 +44,6 @@ library
|
|||
, bytestring
|
||||
, http-conduit
|
||||
, http-types
|
||||
, microlens
|
||||
, microlens-mtl
|
||||
, microlens-th
|
||||
, mtl
|
||||
, persistent
|
||||
, persistent-sqlite
|
||||
, persistent-template
|
||||
|
@ -59,7 +54,6 @@ library
|
|||
, scientific
|
||||
, text
|
||||
, vector
|
||||
, vty
|
||||
, zcash-haskell
|
||||
default-language: Haskell2010
|
||||
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
nodeUser = "user"
|
||||
nodePwd = "superSecret"
|
||||
dbName = "zenith.db"
|
||||
|
|
Loading…
Reference in a new issue