Add base addressbook to GUI #102
1 changed files with 29 additions and 2 deletions
|
@ -50,7 +50,13 @@ import Zenith.Core
|
|||
import Zenith.DB
|
||||
import Zenith.GUI.Theme
|
||||
import Zenith.Scanner (processTx, updateConfs)
|
||||
import Zenith.Types hiding (ZcashAddress(..))
|
||||
import Zenith.Types
|
||||
( ZcashNetDB
|
||||
)
|
||||
import Zenith.Types
|
||||
hiding
|
||||
( ZcashAddress(..)
|
||||
)
|
||||
import Zenith.Utils
|
||||
( displayAmount
|
||||
, isRecipientValid
|
||||
|
@ -61,6 +67,7 @@ import Zenith.Utils
|
|||
, validateAddressBool
|
||||
, isValidString
|
||||
, padWithZero
|
||||
, getZenithPath
|
||||
)
|
||||
|
||||
data AppEvent
|
||||
|
@ -115,6 +122,7 @@ data AppEvent
|
|||
| CloseMsgAB
|
||||
| CheckValidAddress !T.Text
|
||||
| CheckValidDescrip !T.Text
|
||||
| ShowMessage !T.Text
|
||||
deriving (Eq, Show)
|
||||
|
||||
data AppModel = AppModel
|
||||
|
@ -848,7 +856,10 @@ buildUI wenv model = widgetTree
|
|||
]
|
||||
, spacer
|
||||
, hstack [
|
||||
button "Save" NotImplemented `nodeEnabled`
|
||||
button "Save" (saveAddrBook
|
||||
(ZcashNetDB (model ^. network))
|
||||
(model ^. abdescrip)
|
||||
(model ^. abaddress)) `nodeEnabled`
|
||||
((model ^. abAddressValid) && (model ^. abDescripValid))
|
||||
]
|
||||
]
|
||||
|
@ -934,6 +945,21 @@ generateQRCodes config = do
|
|||
Orchard -> Just $ (T.append "zcash:" . getUA . walletAddressUAddress) w
|
||||
Sprout -> Nothing
|
||||
|
||||
saveAddrBook :: ZcashNetDB -> T.Text -> T.Text -> AppEvent
|
||||
saveAddrBook n d a = do
|
||||
dPath <- liftIO $ getZenithPath
|
||||
pool <- runNoLoggingT $ initPool $ (T.pack dPath)
|
||||
res <-
|
||||
liftIO $
|
||||
saveAdrsInAdrBook pool $
|
||||
AddressBook
|
||||
n
|
||||
d
|
||||
a
|
||||
case res of
|
||||
Nothing -> return $ ShowMessage "Error while saving address book entry"
|
||||
Just _ -> return $ ShowMessage "New address book entry saved successfully!!"
|
||||
|
||||
handleEvent ::
|
||||
WidgetEnv AppModel AppEvent
|
||||
-> WidgetNode AppModel AppEvent
|
||||
|
@ -1183,6 +1209,7 @@ handleEvent wenv node model evt =
|
|||
CloseNewAdrBook -> [Model $ model & newAdrBkEntry .~ False]
|
||||
NotImplemented -> [Model $ model & msgAB ?~ "Function not implemented..." & menuPopup .~ False]
|
||||
CloseMsgAB -> [Model $ model & msgAB .~ Nothing & inError .~ False]
|
||||
ShowMessage a -> [Model $ model & msgAB ?~ a & menuPopup .~ False]
|
||||
where
|
||||
currentWallet =
|
||||
if null (model ^. wallets)
|
||||
|
|
Loading…
Reference in a new issue