@@ -3,23 +3,17 @@ import { lit as html } from './helpers/lit.js'
3
3
import {
4
4
generateWalletData ,
5
5
deriveWalletData ,
6
- envoy ,
7
- sortContactsByAlias ,
8
6
getStoreData ,
9
7
formDataEntries ,
10
- getAddressIndexFromUsage ,
11
8
} from './helpers/utils.js'
12
9
13
10
import {
14
11
DUFFS ,
15
- OIDC_CLAIMS ,
16
- // USAGE,
17
12
} from './helpers/constants.js'
18
13
19
14
import {
20
15
findInStore ,
21
16
initDashSocket ,
22
- // batchAddressGenerate,
23
17
batchGenAccts ,
24
18
batchGenAcctAddrs ,
25
19
batchGenAcctsAddrs ,
@@ -35,13 +29,22 @@ import {
35
29
getUnusedChangeAddress ,
36
30
getAccountWallet ,
37
31
} from './helpers/wallet.js'
32
+
38
33
import {
39
34
localForageBaseCfg ,
40
35
importFromJson ,
41
36
exportWalletData ,
42
37
saveJsonToFile ,
43
38
} from './helpers/db.js'
44
39
40
+ import {
41
+ appState ,
42
+ appTools ,
43
+ appDialogs ,
44
+ userInfo ,
45
+ walletFunds ,
46
+ } from './state/index.js'
47
+
45
48
import setupNav from './components/nav.js'
46
49
import setupMainFooter from './components/main-footer.js'
47
50
import setupSendRequestBtns from './components/send-request-btns.js'
@@ -75,80 +78,6 @@ let accounts
75
78
let wallets
76
79
let wallet
77
80
78
- let appState = envoy (
79
- {
80
- phrase : null ,
81
- encryptionPassword : null ,
82
- selectedWallet : '' ,
83
- selectedAlias : '' ,
84
- aliasInfo : { } ,
85
- contacts : [ ] ,
86
- sentTransactions : { } ,
87
- account : { } ,
88
- } ,
89
- // async (state, oldState, prop) => {
90
- // if (prop === 'sentTransactions') {
91
- // console.log(prop, state[prop])
92
- // }
93
- // },
94
- )
95
- let appTools = envoy (
96
- {
97
- storedData : { } ,
98
- } ,
99
- )
100
- let userInfo = envoy (
101
- {
102
- ...OIDC_CLAIMS ,
103
- } ,
104
- async ( state , oldState , prop ) => {
105
- if ( state [ prop ] !== oldState [ prop ] ) {
106
- let decryptedAlias = await appTools . storedData . decryptItem (
107
- store . aliases ,
108
- appState . selectedAlias ,
109
- )
110
- appTools . storedData . encryptItem (
111
- store . aliases ,
112
- appState . selectedAlias ,
113
- {
114
- ...decryptedAlias ,
115
- updatedAt : ( new Date ( ) ) . toISOString ( ) ,
116
- info : {
117
- ...decryptedAlias . info ,
118
- [ prop ] : state [ prop ] ,
119
- } ,
120
- } ,
121
- false ,
122
- )
123
- }
124
- } ,
125
- )
126
-
127
- // rigs
128
- let appDialogs = envoy (
129
- {
130
- onboard : { } ,
131
- phraseBackup : { } ,
132
- phraseGenerate : { } ,
133
- phraseImport : { } ,
134
- walletEncrypt : { } ,
135
- walletDecrypt : { } ,
136
- addContact : { } ,
137
- editContact : { } ,
138
- editProfile : { } ,
139
- scanContact : { } ,
140
- sendOrReceive : { } ,
141
- sendConfirm : { } ,
142
- requestQr : { } ,
143
- } ,
144
- )
145
-
146
- let walletFunds = envoy (
147
- {
148
- balance : 0
149
- } ,
150
- )
151
-
152
81
// element
153
82
let bodyNav
154
83
let dashBalance
@@ -571,7 +500,7 @@ async function main() {
571
500
572
501
appDialogs . addContact = await addContactRig ( {
573
502
setupDialog, updateAllFunds,
574
- appDialogs, appState, appTools, store, walletFunds ,
503
+ appDialogs, appState, appTools, store,
575
504
mainApp, wallet, userInfo, contactsList,
576
505
} )
577
506
@@ -783,7 +712,7 @@ async function main() {
783
712
. then ( accts => {
784
713
console . log ( 'batchGenAcctsAddrs' , { accts } )
785
714
786
- updateAllFunds ( wallet , walletFunds )
715
+ updateAllFunds ( wallet )
787
716
. then ( funds => {
788
717
console . log ( 'updateAllFunds then funds' , funds )
789
718
} )
@@ -1016,7 +945,7 @@ async function main() {
1016
945
)
1017
946
1018
947
setTimeout ( ( ) =>
1019
- updateAllFunds ( wallet , walletFunds )
948
+ updateAllFunds ( wallet )
1020
949
. then ( funds => {
1021
950
console . log ( 'updateAllFunds then funds' , funds )
1022
951
} )
@@ -1141,7 +1070,7 @@ async function main() {
1141
1070
}
1142
1071
1143
1072
setTimeout ( ( ) =>
1144
- updateAllFunds ( wallet , walletFunds )
1073
+ updateAllFunds ( wallet )
1145
1074
. then ( funds => {
1146
1075
console . log ( 'updateAllFunds then funds' , funds )
1147
1076
} )
0 commit comments