Compare commits

..

No commits in common. "1931098ee9327da8b960ca372ee22f09d3d0b319" and "73ad2f0eb3985c3e6a9056842c7c847e7456e866" have entirely different histories.

2 changed files with 15 additions and 64 deletions

View file

@ -50,13 +50,7 @@ import Zenith.Core
import Zenith.DB
import Zenith.GUI.Theme
import Zenith.Scanner (processTx, updateConfs)
import Zenith.Types
( ZcashNetDB
)
import Zenith.Types
hiding
( ZcashAddress(..)
)
import Zenith.Types hiding (ZcashAddress(..))
import Zenith.Utils
( displayAmount
, isRecipientValid
@ -67,8 +61,6 @@ import Zenith.Utils
, validateAddressBool
, isValidString
, padWithZero
, getZenithPath
, isEmpty
)
data AppEvent
@ -123,9 +115,6 @@ data AppEvent
| CloseMsgAB
| CheckValidAddress !T.Text
| CheckValidDescrip !T.Text
| SaveNewABEntry
| ShowMessage !T.Text
deriving (Eq, Show)
data AppModel = AppModel
@ -818,7 +807,7 @@ buildUI wenv model = widgetTree
(hstack
[
label
(T.pack $
(T.pack $
padWithZero 3 $
show (fromSqlKey (entityKey ab))) `styleBasic` [textFont "Bold"]
, spacer
@ -858,11 +847,9 @@ buildUI wenv model = widgetTree
]
]
, spacer
, hstack
[ button "Save" SaveNewABEntry `nodeEnabled`
, hstack [
button "Save" NotImplemented `nodeEnabled`
((model ^. abAddressValid) && (model ^. abDescripValid))
, spacer
, button "Cancel" CloseNewAdrBook `nodeEnabled` True
]
]
msgAdrBookOverlay=
@ -1188,22 +1175,14 @@ handleEvent wenv node model evt =
(i < (fromIntegral (model ^. balance) / 100000000.0))
]
ShowTxId tx -> [Model $ model & showId ?~ tx & modalMsg .~ Nothing]
-- |
-- | Address Book Events
-- |
CheckValidAddress a -> [Model $ model & abAddressValid .~ isRecipientValid a]
CheckValidDescrip a -> [Model $ model & abDescripValid .~ isValidString a]
ShowAdrBook -> [Model $ model & showAdrBook .~ True & menuPopup .~ False]
CloseAdrBook -> [Model $ model & showAdrBook .~ False]
NewAdrBkEntry -> [Model $ model & newAdrBkEntry .~ True & menuPopup .~ False]
CloseNewAdrBook -> do
[Model $ model & newAdrBkEntry .~ False]
SaveNewABEntry ->
[ Task $ saveAddrBook (model ^. configuration) (ZcashNetDB (model ^. network)) (model ^. abdescrip) (model ^. abaddress)
]
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)
@ -1291,36 +1270,6 @@ handleEvent wenv node model evt =
Just _ -> do
wL <- getWallets pool (model ^. network)
return $ LoadWallets wL
-- |
-- | Address Book -> save new entry into database
-- |
saveAddrBook :: Config -> ZcashNetDB -> T.Text -> T.Text -> IO AppEvent
saveAddrBook config n d a = do
let dbPath = c_dbPath config
pool <- runNoLoggingT $ initPool dbPath
res <-
liftIO $
saveAdrsInAdrBook pool $
AddressBook
n
d
a
case res of
Nothing -> return $ ShowMessage "Error saving the AddressBook entry..."
Just _ -> loadABList config (model ^. network)
-- |
-- |
-- |
loadABList :: Config -> ZcashNet -> IO AppEvent
loadABList config n = do
let dbPath = c_dbPath config
pool <- runNoLoggingT $ initPool dbPath
abList <- getAdrBook pool n
if isEmpty abList
then return $ ShowMessage "Error loading the AddressBook list..."
else do
model & abaddressList ?~ abList
return $ ShowMessage "AddressBook loaded successfully!!!"
scanZebra :: T.Text -> T.Text -> Int -> (AppEvent -> IO ()) -> IO ()
scanZebra dbPath zHost zPort sendMsg = do
@ -1487,7 +1436,9 @@ runZenithGUI config = do
Nothing
True
bal
(if unconfBal == 0 then Nothing else Just unconfBal)
(if unconfBal == 0
then Nothing
else Just unconfBal)
Orchard
qr
False
@ -1498,7 +1449,9 @@ runZenithGUI config = do
Nothing
""
""
(SaveAddress (if not (null accList) then Just (head accList) else Nothing ) )
(SaveAddress (if not (null accList)
then Just (head accList)
else Nothing ) )
False
False
Nothing
@ -1512,7 +1465,7 @@ runZenithGUI config = do
False
False
Nothing
hD
""
False
False
""
@ -1521,6 +1474,7 @@ runZenithGUI config = do
False
abList
Nothing
-- hD
startApp model handleEvent buildUI (params hD)
Left e -> do
initDb dbFilePath
@ -1566,7 +1520,7 @@ runZenithGUI config = do
False
False
Nothing
hD
""
False
False
""
@ -1575,6 +1529,7 @@ runZenithGUI config = do
False
[]
Nothing
-- hD
startApp model handleEvent buildUI (params hD)
where
params hd =

View file

@ -157,8 +157,4 @@ padWithZero :: Int -> String -> String
padWithZero n s
| (length s) >= n = s
| otherwise = padWithZero n ("0" ++ s)
isEmpty :: [a] -> Bool
isEmpty [] = True
isEmpty _ = False