@@ -33,25 +33,20 @@ use node_comm::node_traits::NodeInterface;
33
33
use serialization:: { hex:: HexEncode , hex_encoded:: HexEncoded } ;
34
34
use utils:: qrcode:: { QrCode , QrCodeError } ;
35
35
use wallet:: version:: get_version;
36
- use wallet_controller:: types:: { GenericTokenTransfer , WalletTypeArgs } ;
36
+ use wallet_controller:: types:: GenericTokenTransfer ;
37
37
use wallet_rpc_client:: wallet_rpc_traits:: { PartialOrSignedTx , WalletInterface } ;
38
- use wallet_rpc_lib:: {
39
- cmdline:: CliHardwareWalletType ,
40
- types:: {
41
- Balances , ComposedTransaction , ControllerConfig , MnemonicInfo , NewTransaction , NftMetadata ,
42
- RpcInspectTransaction , RpcSignatureStats , RpcSignatureStatus , RpcStandaloneAddressDetails ,
43
- RpcValidatedSignatures , TokenMetadata ,
44
- } ,
38
+ use wallet_rpc_lib:: types:: {
39
+ Balances , ComposedTransaction , ControllerConfig , HardwareWalletType , MnemonicInfo ,
40
+ NewTransaction , NftMetadata , RpcInspectTransaction , RpcSignatureStats , RpcSignatureStatus ,
41
+ RpcStandaloneAddressDetails , RpcValidatedSignatures , TokenMetadata ,
45
42
} ;
46
43
47
- use wallet_types:: {
48
- partially_signed_transaction:: PartiallySignedTransaction , seed_phrase:: StoreSeedPhrase ,
49
- } ;
44
+ use wallet_types:: partially_signed_transaction:: PartiallySignedTransaction ;
50
45
51
46
use crate :: {
52
47
errors:: WalletCliCommandError , helper_types:: parse_generic_token_transfer,
53
48
CreateWalletDeviceSelectMenu , ManageableWalletCommand , OpenWalletDeviceSelectMenu ,
54
- WalletManagementCommand ,
49
+ OpenWalletSubCommand , WalletManagementCommand ,
55
50
} ;
56
51
57
52
use self :: local_state:: WalletWithState ;
@@ -150,36 +145,17 @@ where
150
145
WalletCliCommandError < N > : From < E > ,
151
146
{
152
147
match command {
153
- WalletManagementCommand :: CreateWallet {
154
- wallet_path,
155
- mnemonic,
156
- whether_to_store_seed_phrase,
157
- passphrase,
158
- hardware_wallet,
159
- trezor_device_id,
160
- } => {
161
- let store_seed_phrase =
162
- whether_to_store_seed_phrase. map_or ( StoreSeedPhrase :: DoNotStore , Into :: into) ;
163
- let wallet_args = hardware_wallet. map_or (
164
- WalletTypeArgs :: Software {
165
- mnemonic,
166
- passphrase,
167
- store_seed_phrase,
168
- } ,
169
- |h| h. into_wallet_args ( trezor_device_id) ,
170
- ) ;
148
+ WalletManagementCommand :: CreateWallet { wallet } => {
149
+ let ( wallet_path, wallet_args) = wallet. into_path_and_wallet_args ( ) ;
150
+
171
151
let response =
172
152
self . wallet ( ) . await ?. create_wallet ( wallet_path. clone ( ) , wallet_args) . await ?;
173
153
174
154
if let Some ( devices) = response. multiple_devices_available {
175
155
match devices {
176
156
wallet_rpc_lib:: types:: MultipleDevicesAvailable :: Trezor { devices } => {
177
- let choices = CreateWalletDeviceSelectMenu :: new (
178
- devices,
179
- wallet_path,
180
- CliHardwareWalletType :: Trezor ,
181
- false ,
182
- ) ;
157
+ let choices =
158
+ CreateWalletDeviceSelectMenu :: new ( devices, wallet_path, false ) ;
183
159
return Ok ( ConsoleCommand :: ChoiceMenu ( Box :: new ( choices) ) ) ;
184
160
}
185
161
}
@@ -208,38 +184,17 @@ where
208
184
} )
209
185
}
210
186
211
- WalletManagementCommand :: RecoverWallet {
212
- wallet_path,
213
- mnemonic,
214
- whether_to_store_seed_phrase,
215
- passphrase,
216
- hardware_wallet,
217
- trezor_device_id,
218
- } => {
219
- let hardware_wallet = hardware_wallet. map ( Into :: into) ;
187
+ WalletManagementCommand :: RecoverWallet { wallet } => {
188
+ let ( wallet_path, wallet_args) = wallet. into_path_and_wallet_args ( ) ;
220
189
221
- let response = self
222
- . wallet ( )
223
- . await ?
224
- . recover_wallet (
225
- wallet_path. clone ( ) ,
226
- whether_to_store_seed_phrase. is_some_and ( |x| x. to_bool ( ) ) ,
227
- mnemonic,
228
- passphrase,
229
- hardware_wallet,
230
- trezor_device_id,
231
- )
232
- . await ?;
190
+ let response =
191
+ self . wallet ( ) . await ?. recover_wallet ( wallet_path. clone ( ) , wallet_args) . await ?;
233
192
234
193
if let Some ( devices) = response. multiple_devices_available {
235
194
match devices {
236
195
wallet_rpc_lib:: types:: MultipleDevicesAvailable :: Trezor { devices } => {
237
- let choices = CreateWalletDeviceSelectMenu :: new (
238
- devices,
239
- wallet_path,
240
- CliHardwareWalletType :: Trezor ,
241
- true ,
242
- ) ;
196
+ let choices =
197
+ CreateWalletDeviceSelectMenu :: new ( devices, wallet_path, true ) ;
243
198
return Ok ( ConsoleCommand :: ChoiceMenu ( Box :: new ( choices) ) ) ;
244
199
}
245
200
}
@@ -255,14 +210,31 @@ where
255
210
} )
256
211
}
257
212
258
- WalletManagementCommand :: OpenWallet {
259
- wallet_path,
260
- encryption_password,
261
- force_change_wallet_type,
262
- hardware_wallet,
263
- trezor_device_id,
264
- } => {
265
- let hardware_wallet = hardware_wallet. map ( Into :: into) ;
213
+ WalletManagementCommand :: OpenWallet { wallet } => {
214
+ let ( wallet_path, encryption_password, force_change_wallet_type, hardware_wallet) =
215
+ match wallet {
216
+ OpenWalletSubCommand :: Software {
217
+ wallet_path,
218
+ encryption_password,
219
+ force_change_wallet_type,
220
+ } => (
221
+ wallet_path,
222
+ encryption_password,
223
+ force_change_wallet_type,
224
+ None ,
225
+ ) ,
226
+ OpenWalletSubCommand :: Trezor {
227
+ wallet_path,
228
+ encryption_password,
229
+ device_id,
230
+ } => (
231
+ wallet_path,
232
+ encryption_password,
233
+ false ,
234
+ Some ( HardwareWalletType :: Trezor { device_id } ) ,
235
+ ) ,
236
+ } ;
237
+
266
238
let response = self
267
239
. wallet ( )
268
240
. await ?
@@ -271,7 +243,6 @@ where
271
243
encryption_password. clone ( ) ,
272
244
Some ( force_change_wallet_type) ,
273
245
hardware_wallet,
274
- trezor_device_id,
275
246
)
276
247
. await ?;
277
248
@@ -288,8 +259,6 @@ where
288
259
devices,
289
260
wallet_path,
290
261
encryption_password,
291
- force_change_wallet_type,
292
- CliHardwareWalletType :: Trezor ,
293
262
) ;
294
263
return Ok ( ConsoleCommand :: ChoiceMenu ( Box :: new ( choices) ) ) ;
295
264
}
0 commit comments