@@ -80,53 +80,76 @@ newWalletH walletMnemonicLink config = do
80
80
81
81
div_ [id_ " menmonic" , class_ " mb-3" ] " "
82
82
83
- postWalletForm config
83
+ postWalletMnemonicForm config
84
84
85
85
div_
86
86
[ id_ " new_wallet"
87
87
]
88
88
mempty
89
89
90
+ newWalletFromXPubH :: PostWalletConfig -> WHtml ()
91
+ newWalletFromXPubH config = do
92
+ useHtmxExtension " json-enc"
93
+
94
+ postWalletMnemonicForm config
95
+
96
+ div_
97
+ [ id_ " new_wallet"
98
+ ]
99
+ mempty
90
100
data PostWalletConfig = PostWalletConfig
91
101
{ passwordVisibility :: Maybe Visible
92
102
, walletDataLink :: Link
93
103
}
94
104
95
- postWalletForm :: PostWalletConfig -> WHtml ()
96
- postWalletForm PostWalletConfig {.. } = form_
97
- [ hxPost_ $ linkText walletDataLink
98
- , hxExt_ " json-enc"
99
- , hxTarget_ " #new_wallet"
100
- , autocomplete_ " off"
101
- ]
102
- $ do
103
- input_
105
+ formHeaderH :: PostWalletConfig -> WHtml () -> WHtml ()
106
+ formHeaderH PostWalletConfig {.. } =
107
+ form_
108
+ [ hxPost_ $ linkText walletDataLink
109
+ , hxExt_ " json-enc"
110
+ , hxTarget_ " #new_wallet"
111
+ , autocomplete_ " off"
112
+ ]
113
+
114
+ mnemonicSetupFieldsH :: PostWalletConfig -> WHtml ()
115
+ mnemonicSetupFieldsH PostWalletConfig {.. } = do
116
+ input_
117
+ [ class_ " form-control form-control-lg mb-3"
118
+ , visibility
119
+ , name_ " mnemonicSentence"
120
+ , placeholder_ " Mnemonic Sentence"
121
+ ]
122
+ onShelley
123
+ $ input_
104
124
[ class_ " form-control form-control-lg mb-3"
105
- , visibility
106
- , name_ " mnemonicSentence "
107
- , placeholder_ " Mnemonic Sentence "
125
+ , type_ " text "
126
+ , name_ " name "
127
+ , placeholder_ " Wallet Name "
108
128
]
109
- onShelley
110
- $ input_
111
- [ class_ " form-control form-control-lg mb-3"
112
- , type_ " text"
113
- , name_ " name"
114
- , placeholder_ " Wallet Name"
115
- ]
116
- onShelley
117
- $ input_
118
- [ class_ " form-control form-control-lg mb-3"
119
- , visibility
120
- , name_ " passphrase"
121
- , placeholder_ " Passphrase"
122
- ]
123
- button_
124
- [ class_ " btn btn-primary btn-block mb-3"
125
- , type_ " submit"
129
+ onShelley
130
+ $ input_
131
+ [ class_ " form-control form-control-lg mb-3"
132
+ , visibility
133
+ , name_ " passphrase"
134
+ , placeholder_ " Passphrase"
126
135
]
127
- " Restore wallet"
128
136
where
129
137
visibility = type_ $ case passwordVisibility of
130
138
Just Visible -> " text"
131
139
Just Hidden -> " password"
132
140
Nothing -> " password"
141
+
142
+ postWalletMnemonicForm :: PostWalletConfig -> WHtml ()
143
+ postWalletMnemonicForm cfg = formHeaderH cfg $ mnemonicSetupFieldsH cfg
144
+
145
+ xpubSetupFieldsH :: WHtml ()
146
+ xpubSetupFieldsH = do
147
+ input_
148
+ [ class_ " form-control form-control-lg mb-3"
149
+ , type_ " text"
150
+ , name_ " xpub"
151
+ , placeholder_ " Extended Public Key"
152
+ ]
153
+
154
+ postWalletXPubForm :: PostWalletConfig -> WHtml ()
155
+ postWalletXPubForm cfg = formHeaderH cfg xpubSetupFieldsH
0 commit comments