1
1
{-# LANGUAGE RankNTypes #-}
2
+
2
3
module Cardano.Wallet.UI.Deposit.Html.Pages.Wallet
3
4
where
4
5
@@ -11,6 +12,9 @@ import Cardano.Address.Derivation
11
12
import Cardano.Wallet.Deposit.IO
12
13
( WalletPublicIdentity (.. )
13
14
)
15
+ import Cardano.Wallet.Deposit.REST
16
+ ( ErrDatabase
17
+ )
14
18
import Cardano.Wallet.UI.Common.API
15
19
( Visible (.. )
16
20
)
@@ -33,6 +37,9 @@ import Codec.Binary.Encoding
33
37
( AbstractEncoding (.. )
34
38
, encode
35
39
)
40
+ import Control.Exception
41
+ ( SomeException
42
+ )
36
43
import Data.ByteString
37
44
( ByteString
38
45
)
@@ -46,20 +53,33 @@ import Lucid
46
53
( HtmlT
47
54
)
48
55
56
+ import qualified Data.ByteString.Lazy.Char8 as BL
49
57
import qualified Data.Text.Encoding as T
50
58
51
- data WalletPresent = WalletPresent WalletPublicIdentity | WalletAbsent
59
+ data WalletPresent
60
+ = WalletPresent WalletPublicIdentity
61
+ | WalletAbsent
62
+ | WalletFailedToInitialize ErrDatabase
63
+ | WalletVanished SomeException
64
+ | WalletInitializing
52
65
53
- walletH :: WalletPresent -> WHtml ()
54
- walletH walletPresent = do
66
+ walletH :: ( BL. ByteString -> WHtml () ) -> WalletPresent -> WHtml ()
67
+ walletH alert walletPresent = do
55
68
-- sseH sseLink walletLink "wallet" ["wallet"]
56
69
case walletPresent of
57
70
WalletPresent wallet -> walletElementH wallet
58
71
WalletAbsent ->
59
- newWalletH walletMnemonicLink $ PostWalletConfig
60
- { walletDataLink = walletLink
61
- , passwordVisibility = Just Hidden
62
- }
72
+ newWalletH walletMnemonicLink
73
+ $ PostWalletConfig
74
+ { walletDataLink = walletLink
75
+ , passwordVisibility = Just Hidden
76
+ }
77
+ WalletFailedToInitialize err ->
78
+ alert
79
+ $ " Failed to initialize wallet"
80
+ <> BL. pack (show err)
81
+ WalletVanished e -> alert $ " Wallet vanished " <> BL. pack (show e)
82
+ WalletInitializing -> alert " Wallet is initializing"
63
83
64
84
base16 :: ByteString -> Text
65
85
base16 = T. decodeUtf8 . encode EBase16
0 commit comments