1
1
import { api } from '@core/api'
2
2
import { generateRandomId } from '@core/utils'
3
3
import { get } from 'svelte/store'
4
- import { IWallet } from '../interfaces'
4
+ import { IProfile , IWallet } from '../interfaces'
5
5
import { activeProfile as activeProfileStore } from '../stores'
6
6
import { getSecretManagerFromProfileType , getStorageDirectoryOfProfile } from '../utils'
7
- import { WalletOptions } from '@iota/sdk'
7
+ import { Wallet , WalletOptions } from '@iota/sdk'
8
8
import { selectedWalletId } from '../../wallet'
9
9
10
+ export function getWalletOptions ( profile : IProfile , storagePath :string ) : WalletOptions {
11
+ const walletOptions : WalletOptions = {
12
+ clientOptions : profile . clientOptions ,
13
+ storagePath,
14
+ secretManager : getSecretManagerFromProfileType ( profile . type , storagePath ) ,
15
+ bipPath : {
16
+ coinType : profile . network . coinType ,
17
+ account : 0 ,
18
+ addressIndex : 0
19
+ } ,
20
+ }
21
+
22
+ console . log ( "aaa" , walletOptions )
23
+
24
+ return walletOptions
25
+ }
26
+
10
27
// TODO(2.0): Fix and finish this method
11
28
/* - __storage__/
12
29
- profile_id_1
@@ -17,18 +34,8 @@ import { selectedWalletId } from '../../wallet'
17
34
export async function createWallet ( activeProfile = get ( activeProfileStore ) ) : Promise < IWallet > {
18
35
const id = activeProfile . id ;
19
36
const storagePath = await getStorageDirectoryOfProfile ( id )
20
- // const snapshotPath = ''
21
37
22
- const walletOptions : WalletOptions = {
23
- clientOptions : activeProfile . clientOptions ,
24
- secretManager : getSecretManagerFromProfileType ( activeProfile . type , storagePath ) ,
25
- bipPath : {
26
- coinType : activeProfile . network . coinType ,
27
- account : 0 ,
28
- addressIndex : 0
29
- } ,
30
- coinType : activeProfile . network . coinType
31
- }
38
+ const walletOptions = getWalletOptions ( activeProfile , storagePath ) ;
32
39
console . log ( "walletOptions" , walletOptions ) ;
33
40
34
41
const wallet = await api . createWallet ( id , {
0 commit comments