rvv041 - Address Book updated
- Functionality to copy receiver address to Clipboard added - Functionality to Send Zcash to selected AddresBook entry added
This commit is contained in:
parent
e946df43f8
commit
16b5acabf2
2 changed files with 55 additions and 32 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -2,4 +2,6 @@
|
||||||
*~
|
*~
|
||||||
dist-newstyle/
|
dist-newstyle/
|
||||||
zenith.db
|
zenith.db
|
||||||
zenith.log
|
zenith.log
|
||||||
|
zenith.db-shm
|
||||||
|
zenith.db-wal
|
||||||
|
|
|
@ -112,6 +112,7 @@ data Name
|
||||||
| AmtField
|
| AmtField
|
||||||
| MemoField
|
| MemoField
|
||||||
| ABViewport
|
| ABViewport
|
||||||
|
| ABList
|
||||||
deriving (Eq, Show, Ord)
|
deriving (Eq, Show, Ord)
|
||||||
|
|
||||||
data DialogInput = DialogInput
|
data DialogInput = DialogInput
|
||||||
|
@ -174,6 +175,7 @@ data State = State
|
||||||
, _eventDispatch :: !(BC.BChan Tick)
|
, _eventDispatch :: !(BC.BChan Tick)
|
||||||
, _timer :: !Int
|
, _timer :: !Int
|
||||||
, _txForm :: !(Form SendInput () Name)
|
, _txForm :: !(Form SendInput () Name)
|
||||||
|
, _abaddresses :: !(L.List Name (Entity AddressBook))
|
||||||
}
|
}
|
||||||
|
|
||||||
makeLenses ''State
|
makeLenses ''State
|
||||||
|
@ -347,17 +349,6 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
||||||
(hBox [capCommand "↲ " "Send", capCommand "<esc> " "Cancel"]))
|
(hBox [capCommand "↲ " "Send", capCommand "<esc> " "Cancel"]))
|
||||||
Blank -> emptyWidget
|
Blank -> emptyWidget
|
||||||
AdrBook ->
|
AdrBook ->
|
||||||
-- D.renderDialog
|
|
||||||
-- (D.dialog (Just (str "Select Wallet")) Nothing 50)
|
|
||||||
-- (selectListBox "Wallets" (st ^. wallets) listDrawWallet <=>
|
|
||||||
-- C.hCenter
|
|
||||||
-- (hBox
|
|
||||||
-- [ capCommand "↑↓ " "move"
|
|
||||||
-- , capCommand "↲ " "select"
|
|
||||||
-- , capCommand "N" "ew"
|
|
||||||
-- , capCommand "S" "how phrase"
|
|
||||||
-- , xCommand
|
|
||||||
-- ]))
|
|
||||||
D.renderDialog
|
D.renderDialog
|
||||||
(D.dialog (Just $ str " Address Book ") Nothing 60)
|
(D.dialog (Just $ str " Address Book ") Nothing 60)
|
||||||
(withAttr abDefAttr $
|
(withAttr abDefAttr $
|
||||||
|
@ -367,11 +358,11 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
||||||
hLimit 50 $
|
hLimit 50 $
|
||||||
vBox $ [vLimit 16 $
|
vBox $ [vLimit 16 $
|
||||||
hLimit 50 $
|
hLimit 50 $
|
||||||
vBox $ --[ L.renderList listDrawAB True (s^.abaddresses) ],
|
vBox $ [ L.renderList listDrawAB True (s ^. abaddresses) ],
|
||||||
[str "Addresses 1.................",
|
-- [str "Addresses 1.................",
|
||||||
str "Addresses 2.....",
|
-- str "Addresses 2.....",
|
||||||
str "Addresses 3",
|
-- str "Addresses 3",
|
||||||
str "Addresses 4"],
|
-- str "Addresses 4"],
|
||||||
padTop Max $
|
padTop Max $
|
||||||
vLimit 4 $
|
vLimit 4 $
|
||||||
hLimit 50 $
|
hLimit 50 $
|
||||||
|
@ -612,6 +603,14 @@ listDrawTx znet sel tx =
|
||||||
then withAttr customAttr (txt $ "> " <> s)
|
then withAttr customAttr (txt $ "> " <> s)
|
||||||
else txt $ " " <> s
|
else txt $ " " <> s
|
||||||
|
|
||||||
|
listDrawAB :: Bool -> Entity AddressBook -> Widget Name
|
||||||
|
listDrawAB sel ab =
|
||||||
|
let selStr s =
|
||||||
|
if sel
|
||||||
|
then withAttr abSelAttr (txt $ "" <> s <> ">")
|
||||||
|
else txt s
|
||||||
|
in selStr $ addressBookDescrip (entityVal ab)
|
||||||
|
|
||||||
customAttr :: A.AttrName
|
customAttr :: A.AttrName
|
||||||
customAttr = L.listSelectedAttr <> A.attrName "custom"
|
customAttr = L.listSelectedAttr <> A.attrName "custom"
|
||||||
|
|
||||||
|
@ -989,19 +988,35 @@ appEvent (BT.VtyEvent e) = do
|
||||||
case e of
|
case e of
|
||||||
V.EvKey (V.KChar 'x') [] ->
|
V.EvKey (V.KChar 'x') [] ->
|
||||||
BT.modify $ set dialogBox Blank
|
BT.modify $ set dialogBox Blank
|
||||||
V.EvKey V.KEnter [] -> do
|
V.EvKey (V.KChar 'c') [] -> do
|
||||||
ns <- liftIO $ refreshWallet s
|
-- Copy Address to Clipboard
|
||||||
BT.put ns
|
case L.listSelectedElement $ s ^. abaddresses of
|
||||||
BT.modify $ set dialogBox Blank
|
Just (_, a) -> do
|
||||||
V.EvKey (V.KChar 'n') [] -> do
|
liftIO $
|
||||||
BT.modify $
|
setClipboard $
|
||||||
set inputForm $
|
T.unpack $ addressBookAddress (entityVal a)
|
||||||
updateFormState (DialogInput "New Wallet") $
|
BT.modify $
|
||||||
s ^. inputForm
|
set msg $
|
||||||
BT.modify $ set dialogBox WName
|
"Address copied to Clipboard from >>\n" ++
|
||||||
V.EvKey (V.KChar 's') [] ->
|
T.unpack (addressBookDescrip (entityVal a)) ++ "->\n" ++
|
||||||
BT.modify $ set displayBox PhraseDisplay
|
T.unpack (addressBookAddress (entityVal a)) ++ "!"
|
||||||
ev -> BT.zoom wallets $ L.handleListEvent ev
|
BT.modify $ set displayBox MsgDisplay
|
||||||
|
_ -> do
|
||||||
|
BT.modify $ set msg $ "Error while copying the address!!"
|
||||||
|
BT.modify $ set displayBox MsgDisplay
|
||||||
|
-- Send Zcash transaction
|
||||||
|
V.EvKey (V.KChar 's') [] -> do
|
||||||
|
case L.listSelectedElement $ s ^. abaddresses of
|
||||||
|
Just (_, a) -> do
|
||||||
|
BT.modify $
|
||||||
|
set txForm $
|
||||||
|
mkSendForm (s ^. balance) (SendInput (addressBookAddress (entityVal a)) 0.0 "")
|
||||||
|
BT.modify $ set dialogBox SendTx
|
||||||
|
_ -> do
|
||||||
|
BT.modify $ set msg $ "No receiver address available!!"
|
||||||
|
BT.modify $ set displayBox MsgDisplay
|
||||||
|
-- Process any other event
|
||||||
|
ev -> BT.zoom abaddresses $ L.handleListEvent ev
|
||||||
Blank -> do
|
Blank -> do
|
||||||
case e of
|
case e of
|
||||||
V.EvKey (V.KChar '\t') [] -> focusRing %= F.focusNext
|
V.EvKey (V.KChar '\t') [] -> focusRing %= F.focusNext
|
||||||
|
@ -1033,6 +1048,8 @@ appEvent (BT.VtyEvent e) = do
|
||||||
BT.zoom addresses $ L.handleListEvent ev
|
BT.zoom addresses $ L.handleListEvent ev
|
||||||
Just TList ->
|
Just TList ->
|
||||||
BT.zoom transactions $ L.handleListEvent ev
|
BT.zoom transactions $ L.handleListEvent ev
|
||||||
|
Just ABList ->
|
||||||
|
BT.zoom transactions $ L.handleListEvent ev
|
||||||
_anyName -> return ()
|
_anyName -> return ()
|
||||||
where
|
where
|
||||||
printMsg :: String -> BT.EventM Name State ()
|
printMsg :: String -> BT.EventM Name State ()
|
||||||
|
@ -1058,7 +1075,7 @@ theMap =
|
||||||
, (barDoneAttr, V.white `on` V.blue)
|
, (barDoneAttr, V.white `on` V.blue)
|
||||||
, (barToDoAttr, V.white `on` V.black)
|
, (barToDoAttr, V.white `on` V.black)
|
||||||
, (abDefAttr, V.white `on` V.blue)
|
, (abDefAttr, V.white `on` V.blue)
|
||||||
, (abSelAttr, V.blue `on` V.white)
|
, (abSelAttr, V.black `on` V.white)
|
||||||
, (abMBarAttr, V.white `on` V.black)
|
, (abMBarAttr, V.white `on` V.black)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1105,6 +1122,9 @@ runZenithCLI config = do
|
||||||
if not (null walList)
|
if not (null walList)
|
||||||
then zcashWalletLastSync $ entityVal $ head walList
|
then zcashWalletLastSync $ entityVal $ head walList
|
||||||
else 0
|
else 0
|
||||||
|
|
||||||
|
abookList <- getAdrBook pool $ zgb_net chainInfo
|
||||||
|
|
||||||
bal <-
|
bal <-
|
||||||
if not (null accList)
|
if not (null accList)
|
||||||
then getBalance pool $ entityKey $ head accList
|
then getBalance pool $ entityKey $ head accList
|
||||||
|
@ -1133,7 +1153,7 @@ runZenithCLI config = do
|
||||||
else Blank)
|
else Blank)
|
||||||
True
|
True
|
||||||
(mkInputForm $ DialogInput "Main")
|
(mkInputForm $ DialogInput "Main")
|
||||||
(F.focusRing [AList, TList])
|
(F.focusRing [AList, TList,ABList])
|
||||||
(zgb_blocks chainInfo)
|
(zgb_blocks chainInfo)
|
||||||
dbFilePath
|
dbFilePath
|
||||||
host
|
host
|
||||||
|
@ -1145,6 +1165,7 @@ runZenithCLI config = do
|
||||||
eventChan
|
eventChan
|
||||||
0
|
0
|
||||||
(mkSendForm 0 $ SendInput "" 0.0 "")
|
(mkSendForm 0 $ SendInput "" 0.0 "")
|
||||||
|
(L.list ABList (Vec.fromList abookList) 1)
|
||||||
Left e -> do
|
Left e -> do
|
||||||
print $
|
print $
|
||||||
"No Zebra node available on port " <>
|
"No Zebra node available on port " <>
|
||||||
|
|
Loading…
Reference in a new issue