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/),
|
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).
|
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]
|
## [0.4.1]
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
module Main where
|
module Main where
|
||||||
|
|
||||||
|
import Brick (simpleMain)
|
||||||
import Control.Monad (void)
|
import Control.Monad (void)
|
||||||
import Control.Monad.IO.Class (liftIO)
|
import Control.Monad.IO.Class (liftIO)
|
||||||
import qualified Data.ByteString as B
|
import qualified Data.ByteString as B
|
||||||
|
@ -199,7 +200,6 @@ main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
config <- load ["zenith.cfg"]
|
config <- load ["zenith.cfg"]
|
||||||
args <- getArgs
|
args <- getArgs
|
||||||
dbName <- require config "dbName"
|
|
||||||
nodeUser <- require config "nodeUser"
|
nodeUser <- require config "nodeUser"
|
||||||
nodePwd <- require config "nodePwd"
|
nodePwd <- require config "nodePwd"
|
||||||
if not (null args)
|
if not (null args)
|
||||||
|
@ -215,7 +215,7 @@ main = do
|
||||||
" ______ _ _ _ \n |___ / (_) | | | \n / / ___ _ __ _| |_| |__ \n / / / _ \\ '_ \\| | __| '_ \\ \n / /_| __/ | | | | |_| | | |\n /_____\\___|_| |_|_|\\__|_| |_|\n Zcash Full Node CLI v0.4.0"
|
" ______ _ _ _ \n |___ / (_) | | | \n / / ___ _ __ _| |_| |__ \n / / / _ \\ '_ \\| | __| '_ \\ \n / /_| __/ | | | | |_| | | |\n /_____\\___|_| |_|_|\\__|_| |_|\n Zcash Full Node CLI v0.4.0"
|
||||||
}
|
}
|
||||||
(root nodeUser nodePwd)
|
(root nodeUser nodePwd)
|
||||||
"cli" -> runZenithCLI dbName
|
"cli" -> simpleMain ui
|
||||||
_ -> printUsage
|
_ -> printUsage
|
||||||
else printUsage
|
else printUsage
|
||||||
|
|
||||||
|
|
|
@ -44,11 +44,6 @@ library:
|
||||||
- persistent-sqlite
|
- persistent-sqlite
|
||||||
- persistent-template
|
- persistent-template
|
||||||
- brick
|
- brick
|
||||||
- mtl
|
|
||||||
- microlens
|
|
||||||
- microlens-mtl
|
|
||||||
- microlens-th
|
|
||||||
- vty
|
|
||||||
- zcash-haskell
|
- zcash-haskell
|
||||||
|
|
||||||
executables:
|
executables:
|
||||||
|
|
|
@ -1,122 +1,13 @@
|
||||||
{-# LANGUAGE TemplateHaskell #-}
|
|
||||||
|
|
||||||
module Zenith.CLI where
|
module Zenith.CLI where
|
||||||
|
|
||||||
import Control.Monad (void)
|
import Brick (Widget, (<+>), joinBorders, simpleMain, str, withBorderStyle)
|
||||||
import Control.Monad.State (modify)
|
import Brick.Widgets.Border (borderWithLabel, vBorder)
|
||||||
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.Widgets.Border.Style (unicode)
|
import Brick.Widgets.Border.Style (unicode)
|
||||||
import qualified Brick.Widgets.Center as C
|
import Brick.Widgets.Center (center)
|
||||||
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
|
|
||||||
|
|
||||||
data Name
|
ui :: Widget ()
|
||||||
= WList
|
ui =
|
||||||
| 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 =
|
|
||||||
joinBorders $
|
joinBorders $
|
||||||
withBorderStyle unicode $
|
withBorderStyle unicode $
|
||||||
B.borderWithLabel (str $ "Zenith - " <> s ^. network) $
|
borderWithLabel (str "Zenith") $
|
||||||
(C.center (listBox "Addresses" (s ^. addresses)) <+>
|
(center (str "Addresses") <+> vBorder <+> center (str "Transactions"))
|
||||||
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"
|
|
||||||
|
|
|
@ -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
|
||||||
import Database.Persist.Sqlite
|
import Database.Persist.Sqlite
|
||||||
import Database.Persist.TH
|
import Database.Persist.TH
|
||||||
import ZcashHaskell.Types (Phrase, ZcashNet)
|
import ZcashHaskell.Types (Phrase)
|
||||||
|
|
||||||
derivePersistField "ZcashNet"
|
|
||||||
|
|
||||||
share
|
share
|
||||||
[mkPersist sqlSettings, mkMigrate "migrateAll"]
|
[mkPersist sqlSettings, mkMigrate "migrateAll"]
|
||||||
|
@ -34,6 +32,5 @@ share
|
||||||
tPrivateKey BS.ByteString
|
tPrivateKey BS.ByteString
|
||||||
birthdayHeight Int
|
birthdayHeight Int
|
||||||
name T.Text
|
name T.Text
|
||||||
network ZcashNet
|
|
||||||
deriving Show
|
deriving Show
|
||||||
|]
|
|]
|
||||||
|
|
|
@ -44,9 +44,9 @@ packages:
|
||||||
# extra-deps: []
|
# extra-deps: []
|
||||||
extra-deps:
|
extra-deps:
|
||||||
- git: https://git.vergara.tech/Vergara_Tech/zcash-haskell.git
|
- git: https://git.vergara.tech/Vergara_Tech/zcash-haskell.git
|
||||||
commit: c4f345b1deb876e19a51c5f7ae1b4402fae14126
|
commit: 6ea8698ccb5e44f9900ba0e61c6ffe6cba900139
|
||||||
- git: https://git.vergara.tech/Vergara_Tech/haskell-hexstring.git
|
- 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
|
- git: https://git.vergara.tech/Vergara_Tech/haskell-foreign-rust.git
|
||||||
commit: 787c2e813eb3a5d16c375d4b37dfefbd2adcdf05
|
commit: 787c2e813eb3a5d16c375d4b37dfefbd2adcdf05
|
||||||
- git: https://github.com/well-typed/borsh.git
|
- git: https://github.com/well-typed/borsh.git
|
||||||
|
|
|
@ -5,26 +5,26 @@
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
- completed:
|
- completed:
|
||||||
commit: c4f345b1deb876e19a51c5f7ae1b4402fae14126
|
commit: 6ea8698ccb5e44f9900ba0e61c6ffe6cba900139
|
||||||
git: https://git.vergara.tech/Vergara_Tech/zcash-haskell.git
|
git: https://git.vergara.tech/Vergara_Tech/zcash-haskell.git
|
||||||
name: zcash-haskell
|
name: zcash-haskell
|
||||||
pantry-tree:
|
pantry-tree:
|
||||||
sha256: 1bf709484bc488e51e18aa11001abdc06100ed7086b9bbd765d28c4a3d8e9113
|
sha256: 0506f9f095dbb134a4e7b3ba73a60a21c6298cbea01409871141b31cd0cf9c46
|
||||||
size: 1366
|
size: 1366
|
||||||
version: 0.4.1
|
version: 0.4.1
|
||||||
original:
|
original:
|
||||||
commit: c4f345b1deb876e19a51c5f7ae1b4402fae14126
|
commit: 6ea8698ccb5e44f9900ba0e61c6ffe6cba900139
|
||||||
git: https://git.vergara.tech/Vergara_Tech/zcash-haskell.git
|
git: https://git.vergara.tech/Vergara_Tech/zcash-haskell.git
|
||||||
- completed:
|
- completed:
|
||||||
commit: fd1ddce73c0ad18a2a4509a299c6e93f8c6c383d
|
commit: fe2df6f7d63272ac147911c1573550bed1d38a37
|
||||||
git: https://git.vergara.tech/Vergara_Tech/haskell-hexstring.git
|
git: https://git.vergara.tech/Vergara_Tech/haskell-hexstring.git
|
||||||
name: hexstring
|
name: hexstring
|
||||||
pantry-tree:
|
pantry-tree:
|
||||||
sha256: 05af6ec085b0c8ac00e0c3043652095a6a9c9d3bd2112ffdcb4c4e28206e0b1c
|
sha256: 71f12a60e85f7e1897b07bb2d4c77794faee50df250d68b0c47b3d343dd4625a
|
||||||
size: 741
|
size: 741
|
||||||
version: 0.12.0
|
version: 0.12.0
|
||||||
original:
|
original:
|
||||||
commit: fd1ddce73c0ad18a2a4509a299c6e93f8c6c383d
|
commit: fe2df6f7d63272ac147911c1573550bed1d38a37
|
||||||
git: https://git.vergara.tech/Vergara_Tech/haskell-hexstring.git
|
git: https://git.vergara.tech/Vergara_Tech/haskell-hexstring.git
|
||||||
- completed:
|
- completed:
|
||||||
commit: 787c2e813eb3a5d16c375d4b37dfefbd2adcdf05
|
commit: 787c2e813eb3a5d16c375d4b37dfefbd2adcdf05
|
||||||
|
|
|
@ -26,7 +26,6 @@ source-repository head
|
||||||
library
|
library
|
||||||
exposed-modules:
|
exposed-modules:
|
||||||
Zenith.CLI
|
Zenith.CLI
|
||||||
Zenith.Core
|
|
||||||
Zenith.DB
|
Zenith.DB
|
||||||
Zenith.Types
|
Zenith.Types
|
||||||
Zenith.Utils
|
Zenith.Utils
|
||||||
|
@ -45,10 +44,6 @@ library
|
||||||
, bytestring
|
, bytestring
|
||||||
, http-conduit
|
, http-conduit
|
||||||
, http-types
|
, http-types
|
||||||
, microlens
|
|
||||||
, microlens-mtl
|
|
||||||
, microlens-th
|
|
||||||
, mtl
|
|
||||||
, persistent
|
, persistent
|
||||||
, persistent-sqlite
|
, persistent-sqlite
|
||||||
, persistent-template
|
, persistent-template
|
||||||
|
@ -59,7 +54,6 @@ library
|
||||||
, scientific
|
, scientific
|
||||||
, text
|
, text
|
||||||
, vector
|
, vector
|
||||||
, vty
|
|
||||||
, zcash-haskell
|
, zcash-haskell
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
nodeUser = "user"
|
nodeUser = "user"
|
||||||
nodePwd = "superSecret"
|
nodePwd = "superSecret"
|
||||||
dbName = "zenith.db"
|
|
||||||
|
|
Loading…
Reference in a new issue