Docker image #89
1 changed files with 31 additions and 2 deletions
|
@ -62,7 +62,7 @@ import Control.Monad (forever, void)
|
||||||
import Control.Monad.IO.Class (liftIO)
|
import Control.Monad.IO.Class (liftIO)
|
||||||
import Control.Monad.Logger (LoggingT, runFileLoggingT, runNoLoggingT)
|
import Control.Monad.Logger (LoggingT, runFileLoggingT, runNoLoggingT)
|
||||||
import Data.Aeson
|
import Data.Aeson
|
||||||
import Data.HexString (toText)
|
import Data.HexString (HexString(..), toText)
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import qualified Data.Text.Encoding as E
|
import qualified Data.Text.Encoding as E
|
||||||
|
@ -139,6 +139,7 @@ data DisplayType
|
||||||
| MsgDisplay
|
| MsgDisplay
|
||||||
| PhraseDisplay
|
| PhraseDisplay
|
||||||
| TxDisplay
|
| TxDisplay
|
||||||
|
| TxIdDisplay
|
||||||
| SyncDisplay
|
| SyncDisplay
|
||||||
| SendDisplay
|
| SendDisplay
|
||||||
| BlankDisplay
|
| BlankDisplay
|
||||||
|
@ -146,6 +147,7 @@ data DisplayType
|
||||||
data Tick
|
data Tick
|
||||||
= TickVal !Float
|
= TickVal !Float
|
||||||
| TickMsg !String
|
| TickMsg !String
|
||||||
|
| TickTx !HexString
|
||||||
|
|
||||||
data State = State
|
data State = State
|
||||||
{ _network :: !ZcashNet
|
{ _network :: !ZcashNet
|
||||||
|
@ -170,6 +172,7 @@ data State = State
|
||||||
, _eventDispatch :: !(BC.BChan Tick)
|
, _eventDispatch :: !(BC.BChan Tick)
|
||||||
, _timer :: !Int
|
, _timer :: !Int
|
||||||
, _txForm :: !(Form SendInput () Name)
|
, _txForm :: !(Form SendInput () Name)
|
||||||
|
, _sentTx :: !(Maybe HexString)
|
||||||
}
|
}
|
||||||
|
|
||||||
makeLenses ''State
|
makeLenses ''State
|
||||||
|
@ -413,6 +416,16 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s]
|
||||||
D.renderDialog
|
D.renderDialog
|
||||||
(D.dialog (Just $ txt "Message") Nothing 50)
|
(D.dialog (Just $ txt "Message") Nothing 50)
|
||||||
(padAll 1 $ strWrap $ st ^. msg)
|
(padAll 1 $ strWrap $ st ^. msg)
|
||||||
|
TxIdDisplay ->
|
||||||
|
withBorderStyle unicodeBold $
|
||||||
|
D.renderDialog
|
||||||
|
(D.dialog (Just $ txt "Success") Nothing 50)
|
||||||
|
(padAll 1 $
|
||||||
|
(txt "Tx ID: " <+>
|
||||||
|
txtWrapWith
|
||||||
|
(WrapSettings False True NoFill FillAfterFirst)
|
||||||
|
(maybe "None" toText (st ^. sentTx))) <=>
|
||||||
|
C.hCenter (hBox [capCommand "C" "opy", xCommand]))
|
||||||
TxDisplay ->
|
TxDisplay ->
|
||||||
case L.listSelectedElement $ st ^. transactions of
|
case L.listSelectedElement $ st ^. transactions of
|
||||||
Nothing -> emptyWidget
|
Nothing -> emptyWidget
|
||||||
|
@ -645,16 +658,21 @@ appEvent (BT.AppEvent t) = do
|
||||||
MsgDisplay -> return ()
|
MsgDisplay -> return ()
|
||||||
PhraseDisplay -> return ()
|
PhraseDisplay -> return ()
|
||||||
TxDisplay -> return ()
|
TxDisplay -> return ()
|
||||||
|
TxIdDisplay -> return ()
|
||||||
SyncDisplay -> return ()
|
SyncDisplay -> return ()
|
||||||
SendDisplay -> do
|
SendDisplay -> do
|
||||||
BT.modify $ set msg m
|
BT.modify $ set msg m
|
||||||
BlankDisplay -> return ()
|
BlankDisplay -> return ()
|
||||||
|
TickTx txid -> do
|
||||||
|
BT.modify $ set sentTx (Just txid)
|
||||||
|
BT.modify $ set displayBox TxIdDisplay
|
||||||
TickVal v -> do
|
TickVal v -> do
|
||||||
case s ^. displayBox of
|
case s ^. displayBox of
|
||||||
AddrDisplay -> return ()
|
AddrDisplay -> return ()
|
||||||
MsgDisplay -> return ()
|
MsgDisplay -> return ()
|
||||||
PhraseDisplay -> return ()
|
PhraseDisplay -> return ()
|
||||||
TxDisplay -> return ()
|
TxDisplay -> return ()
|
||||||
|
TxIdDisplay -> return ()
|
||||||
SendDisplay -> return ()
|
SendDisplay -> return ()
|
||||||
SyncDisplay -> do
|
SyncDisplay -> do
|
||||||
if s ^. barValue == 1.0
|
if s ^. barValue == 1.0
|
||||||
|
@ -775,6 +793,16 @@ appEvent (BT.VtyEvent e) = do
|
||||||
MsgDisplay -> BT.modify $ set displayBox BlankDisplay
|
MsgDisplay -> BT.modify $ set displayBox BlankDisplay
|
||||||
PhraseDisplay -> BT.modify $ set displayBox BlankDisplay
|
PhraseDisplay -> BT.modify $ set displayBox BlankDisplay
|
||||||
TxDisplay -> BT.modify $ set displayBox BlankDisplay
|
TxDisplay -> BT.modify $ set displayBox BlankDisplay
|
||||||
|
TxIdDisplay -> do
|
||||||
|
case e of
|
||||||
|
V.EvKey (V.KChar 'x') [] ->
|
||||||
|
BT.modify $ set displayBox BlankDisplay
|
||||||
|
V.EvKey (V.KChar 'c') [] -> do
|
||||||
|
liftIO $
|
||||||
|
setClipboard $
|
||||||
|
T.unpack $ maybe "None" toText (s ^. sentTx)
|
||||||
|
BT.modify $ set msg "Copied transaction ID!"
|
||||||
|
_ev -> return ()
|
||||||
SendDisplay -> BT.modify $ set displayBox BlankDisplay
|
SendDisplay -> BT.modify $ set displayBox BlankDisplay
|
||||||
SyncDisplay -> BT.modify $ set displayBox BlankDisplay
|
SyncDisplay -> BT.modify $ set displayBox BlankDisplay
|
||||||
BlankDisplay -> do
|
BlankDisplay -> do
|
||||||
|
@ -1063,6 +1091,7 @@ runZenithCLI config = do
|
||||||
eventChan
|
eventChan
|
||||||
0
|
0
|
||||||
(mkSendForm 0 $ SendInput "" 0.0 "")
|
(mkSendForm 0 $ SendInput "" 0.0 "")
|
||||||
|
Nothing
|
||||||
Left e -> do
|
Left e -> do
|
||||||
print $
|
print $
|
||||||
"No Zebra node available on port " <>
|
"No Zebra node available on port " <>
|
||||||
|
@ -1272,7 +1301,7 @@ sendTransaction pool chan zHost zPort znet accId bl amt ua memo = do
|
||||||
[Data.Aeson.String $ toText rawTx]
|
[Data.Aeson.String $ toText rawTx]
|
||||||
case resp of
|
case resp of
|
||||||
Left e1 -> BC.writeBChan chan $ TickMsg $ "Zebra error: " ++ show e1
|
Left e1 -> BC.writeBChan chan $ TickMsg $ "Zebra error: " ++ show e1
|
||||||
Right txId -> BC.writeBChan chan $ TickMsg $ "Tx ID: " ++ txId
|
Right txId -> BC.writeBChan chan $ TickTx txId
|
||||||
where
|
where
|
||||||
parseAddress :: T.Text -> IO UnifiedAddress
|
parseAddress :: T.Text -> IO UnifiedAddress
|
||||||
parseAddress a =
|
parseAddress a =
|
||||||
|
|
Loading…
Reference in a new issue