RPC Server #103
1 changed files with 39 additions and 15 deletions
|
@ -164,7 +164,6 @@ makeLenses ''AdrBookEntry
|
|||
data ShDshEntry = ShDshEntry
|
||||
{ _totalTransparent :: !Float
|
||||
, _totalShielded :: !Float
|
||||
, _shieldOp :: !ShieldDeshieldOp
|
||||
, _shAmt :: !Float
|
||||
} deriving (Show)
|
||||
|
||||
|
@ -182,7 +181,8 @@ data DialogType
|
|||
| AdrBookForm
|
||||
| AdrBookUpdForm
|
||||
| AdrBookDelForm
|
||||
| ShieldDeshieldForm
|
||||
| DeshieldForm
|
||||
| ShieldForm
|
||||
|
||||
data DisplayType
|
||||
= AddrDisplay
|
||||
|
@ -231,7 +231,8 @@ data State = State
|
|||
, _abCurAdrs :: !T.Text -- used for address book CRUD operations
|
||||
, _sentTx :: !(Maybe HexString)
|
||||
, _unconfBalance :: !Integer
|
||||
, _shdshForm :: !(Form ShDshEntry () Name)
|
||||
, _deshieldForm :: !(Form ShDshEntry () Name)
|
||||
, _shieldForm :: !(Form ShDshEntry () Name)
|
||||
}
|
||||
|
||||
makeLenses ''State
|
||||
|
@ -290,7 +291,8 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
|||
,C.hCenter
|
||||
(hBox
|
||||
[ capCommand2 "Address " "B" "ook"
|
||||
, capCommand2 "Shield/" "D" "eshield"
|
||||
, capCommand2 "s" "H" "ield"
|
||||
, capCommand "D" "e-shield"
|
||||
, capCommand "Q" "uit"
|
||||
, capCommand "?" " Help"
|
||||
, str $ show (st ^. timer)
|
||||
|
@ -420,10 +422,16 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
|||
(renderForm (st ^. txForm) <=>
|
||||
C.hCenter
|
||||
(hBox [capCommand "↲ " "Send", capCommand "<esc> " "Cancel"]))
|
||||
ShieldDeshieldForm ->
|
||||
DeshieldForm ->
|
||||
D.renderDialog
|
||||
(D.dialog (Just (str " Shield / De-Shield ")) Nothing 50)
|
||||
(renderForm (st ^. shdshForm) <=>
|
||||
(D.dialog (Just (str " De-Shield Zec ")) Nothing 50)
|
||||
(renderForm (st ^. deshieldForm) <=>
|
||||
C.hCenter
|
||||
(hBox [capCommand "P" "roceed", capCommand "<esc> " "Cancel"]))
|
||||
ShieldForm ->
|
||||
D.renderDialog
|
||||
(D.dialog (Just (str " Shield Zec ")) Nothing 50)
|
||||
(renderForm (st ^. shieldForm) <=>
|
||||
C.hCenter
|
||||
(hBox [capCommand "P" "roceed", capCommand "<esc> " "Cancel"]))
|
||||
Blank -> emptyWidget
|
||||
|
@ -669,8 +677,8 @@ mkSendForm bal =
|
|||
label s w =
|
||||
padBottom (Pad 1) $ vLimit 1 (hLimit 15 $ str s <+> fill ' ') <+> w
|
||||
|
||||
mkshieldDeshieldForm :: Integer -> ShDshEntry -> Form ShDshEntry e Name
|
||||
mkshieldDeshieldForm bal =
|
||||
mkDeshieldForm :: Integer -> ShDshEntry -> Form ShDshEntry e Name
|
||||
mkDeshieldForm bal =
|
||||
newForm
|
||||
[ label "Total Transp. : " @@=
|
||||
editShowableFieldWithValidate totalTransparent TotalTranspField (isAmountValid bal)
|
||||
|
@ -685,6 +693,18 @@ mkshieldDeshieldForm bal =
|
|||
label s w =
|
||||
padBottom (Pad 1) $ vLimit 1 (hLimit 15 $ str s <+> fill ' ') <+> w
|
||||
|
||||
mkShieldForm :: Integer -> ShDshEntry -> Form ShDshEntry e Name
|
||||
mkShieldForm bal =
|
||||
newForm
|
||||
[ label "Amount to Shield: " @@=
|
||||
editShowableFieldWithValidate shAmt AmtField (isAmountValid bal)
|
||||
]
|
||||
where
|
||||
isAmountValid :: Integer -> Float -> Bool
|
||||
isAmountValid b i = (fromIntegral b / 100000000.0) >= i
|
||||
label s w =
|
||||
padBottom (Pad 1) $ vLimit 1 (hLimit 15 $ str s <+> fill ' ') <+> w
|
||||
|
||||
mkNewABForm :: AdrBookEntry -> Form AdrBookEntry e Name
|
||||
mkNewABForm =
|
||||
newForm
|
||||
|
@ -933,7 +953,8 @@ appEvent (BT.AppEvent t) = do
|
|||
AdrBookForm -> return ()
|
||||
AdrBookUpdForm -> return ()
|
||||
AdrBookDelForm -> return ()
|
||||
ShieldDeshieldForm -> return ()
|
||||
DeshieldForm -> return ()
|
||||
ShieldForm -> return ()
|
||||
Blank -> do
|
||||
if s ^. timer == 90
|
||||
then do
|
||||
|
@ -1182,14 +1203,14 @@ appEvent (BT.VtyEvent e) = do
|
|||
setFieldValid
|
||||
(isRecipientValidGUI (fs ^. policyField) (fs ^. sendTo))
|
||||
RecField
|
||||
ShieldDeshieldForm -> do
|
||||
DeshieldForm -> do
|
||||
case e of
|
||||
V.EvKey V.KEsc [] -> BT.modify $ set dialogBox Blank
|
||||
ev ->
|
||||
BT.zoom shdshForm $ do
|
||||
BT.zoom deshieldForm $ do
|
||||
handleFormEvent (BT.VtyEvent ev)
|
||||
-- fs <- BT.gets formState
|
||||
-- ev -> BT.zoom shdshForm $ L.handleListEvent ev
|
||||
-- ev -> BT.zoom deshieldForm $ L.handleListEvent ev
|
||||
AdrBook -> do
|
||||
case e of
|
||||
V.EvKey (V.KChar 'x') [] ->
|
||||
|
@ -1400,7 +1421,9 @@ appEvent (BT.VtyEvent e) = do
|
|||
V.EvKey (V.KChar 'b') [] ->
|
||||
BT.modify $ set dialogBox AdrBook
|
||||
V.EvKey (V.KChar 'd') [] ->
|
||||
BT.modify $ set dialogBox ShieldDeshieldForm
|
||||
BT.modify $ set dialogBox DeshieldForm
|
||||
V.EvKey (V.KChar 'h') [] ->
|
||||
BT.modify $ set dialogBox ShieldForm
|
||||
ev ->
|
||||
case r of
|
||||
Just AList ->
|
||||
|
@ -1539,7 +1562,8 @@ runZenithTUI config = do
|
|||
""
|
||||
Nothing
|
||||
uBal
|
||||
(mkshieldDeshieldForm 0 (ShDshEntry 0 0 Shield 0.0 ))
|
||||
(mkDeshieldForm 0 (ShDshEntry 0 0 0.0 ))
|
||||
(mkShieldForm 0 (ShDshEntry 0 0 0.0 ))
|
||||
Left _e -> do
|
||||
print $
|
||||
"No Zebra node available on port " <>
|
||||
|
|
Loading…
Reference in a new issue