@exodus/headless 2.0.0-alpha.78 → 2.0.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -560
- package/README.md +4 -25
- package/package.json +21 -50
- package/src/api.js +66 -11
- package/src/application.js +39 -53
- package/src/dependencies/atoms.js +29 -2
- package/src/dependencies/index.js +2 -2
- package/src/dependencies/modules.js +31 -2
- package/src/dependencies/utils.js +4 -0
- package/src/index.js +57 -85
- package/src/ioc.js +6 -32
- package/src/plugins/attach.js +7 -24
- package/src/plugins/index.js +1 -3
- package/src/plugins/log-lifecycle.js +0 -1
- package/src/unlock-encrypted-storage.js +0 -2
- package/src/utils/blockchain-metadata.js +48 -0
- package/src/atoms/attach.js +0 -31
- package/src/atoms/base-asset-names-to-monitor.js +0 -38
- package/src/constants.js +0 -38
- package/src/features/available-assets/index.js +0 -15
- package/src/features/enabled-assets/api.js +0 -19
- package/src/features/enabled-assets/index.js +0 -26
- package/src/features/enabled-assets/plugin.js +0 -19
- package/src/features/fees/index.js +0 -16
- package/src/features/fees/plugin.js +0 -19
- package/src/features/locale/api.js +0 -14
- package/src/features/locale/index.js +0 -50
- package/src/features/locale/plugin.js +0 -15
- package/src/features/pricing/api.js +0 -15
- package/src/features/pricing/index.js +0 -35
- package/src/features/rates/api.js +0 -13
- package/src/features/rates/index.js +0 -22
- package/src/features/rates/plugin.js +0 -18
- package/src/features/remote-config/api.js +0 -14
- package/src/features/remote-config/index.js +0 -28
- package/src/features/remote-config/plugin.js +0 -21
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/headless",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
4
|
-
"description": "The
|
|
5
|
-
"author": "Exodus Movement Inc
|
|
3
|
+
"version": "2.0.0-alpha.8",
|
|
4
|
+
"description": "The headless Exodus wallet SDK",
|
|
5
|
+
"author": "Exodus Movement Inc",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+https://github.com/ExodusMovement/exodus-hydra.git"
|
|
10
10
|
},
|
|
11
|
-
"homepage": "https://github.com/ExodusMovement/exodus-hydra/tree/master/
|
|
11
|
+
"homepage": "https://github.com/ExodusMovement/exodus-hydra/tree/master/modules/headless",
|
|
12
12
|
"license": "UNLICENSED",
|
|
13
13
|
"bugs": {
|
|
14
14
|
"url": "https://github.com/ExodusMovement/exodus-hydra/issues?q=is%3Aissue+is%3Aopen+label%3Aheadless"
|
|
@@ -17,78 +17,49 @@
|
|
|
17
17
|
"src",
|
|
18
18
|
"README.md",
|
|
19
19
|
"CHANGELOG.md",
|
|
20
|
-
"!**/__tests__
|
|
20
|
+
"!**/__tests__",
|
|
21
21
|
"!**/*.test.js"
|
|
22
22
|
],
|
|
23
23
|
"scripts": {
|
|
24
24
|
"lint": "eslint . --ignore-path ../../.gitignore",
|
|
25
25
|
"lint:fix": "yarn lint --fix",
|
|
26
|
-
"test": "jest
|
|
26
|
+
"test": "jest"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@exodus/
|
|
30
|
-
"@exodus/atoms": "^5.2.2",
|
|
31
|
-
"@exodus/auto-enable-assets-plugin": "^4.0.1",
|
|
32
|
-
"@exodus/available-assets": "^2.0.2",
|
|
33
|
-
"@exodus/balances": "^7.0.0",
|
|
29
|
+
"@exodus/atoms": "^2.9.0",
|
|
34
30
|
"@exodus/basic-utils": "^2.0.0",
|
|
35
|
-
"@exodus/blockchain-metadata": "^
|
|
36
|
-
"@exodus/config": "
|
|
37
|
-
"@exodus/dependency-injection": "^2.0
|
|
38
|
-
"@exodus/dependency-preprocessors": "^2.
|
|
39
|
-
"@exodus/enabled-assets": "^
|
|
40
|
-
"@exodus/exodus-pricing-client": "^1.2.0",
|
|
41
|
-
"@exodus/feature-flags": "^3.0.0",
|
|
42
|
-
"@exodus/fee-monitors": "^1.0.0",
|
|
31
|
+
"@exodus/blockchain-metadata": "^8.0.1",
|
|
32
|
+
"@exodus/config": "7.0.0",
|
|
33
|
+
"@exodus/dependency-injection": "^1.2.0",
|
|
34
|
+
"@exodus/dependency-preprocessors": "^2.0.2",
|
|
35
|
+
"@exodus/enabled-assets": "^5.0.4",
|
|
43
36
|
"@exodus/fetch": "^1.2.1",
|
|
44
|
-
"@exodus/fusion": "^6.0.0",
|
|
45
|
-
"@exodus/geolocation": "^2.1.1",
|
|
46
37
|
"@exodus/key-identifier-provider": "^1.1.3",
|
|
47
|
-
"@exodus/keychain": "^4.
|
|
48
|
-
"@exodus/market-history": "^5.0.0",
|
|
38
|
+
"@exodus/keychain": "^4.0.0",
|
|
49
39
|
"@exodus/module": "^1.0.0",
|
|
50
|
-
"@exodus/
|
|
51
|
-
"@exodus/
|
|
52
|
-
"@exodus/wallet": "^
|
|
53
|
-
"
|
|
54
|
-
"@exodus/wallet-compatibility-modes": "^3.0.0",
|
|
55
|
-
"bip39": "^2.6.0",
|
|
40
|
+
"@exodus/wallet": "^6.0.1",
|
|
41
|
+
"@exodus/wallet-accounts": "^8.0.1",
|
|
42
|
+
"@exodus/wallet-compatibility-modes": "^2.0.0",
|
|
43
|
+
"bip39": "2.6.0",
|
|
56
44
|
"events": "^3.3.0",
|
|
57
|
-
"lodash": "
|
|
45
|
+
"lodash": "https://registry.yarnpkg.com/@exodus/lodash/-/lodash-4.17.21-exodus.2.tgz",
|
|
58
46
|
"minimalistic-assert": "^1.0.1"
|
|
59
47
|
},
|
|
60
48
|
"devDependencies": {
|
|
61
|
-
"@exodus/ab-testing": "^6.0.0",
|
|
62
|
-
"@exodus/algorand-lib": "^2.0.1",
|
|
63
|
-
"@exodus/algorand-meta": "^1.1.4",
|
|
64
|
-
"@exodus/apy-rates": "^3.0.0",
|
|
65
|
-
"@exodus/bitcoin-lib": "^2.2.1",
|
|
66
49
|
"@exodus/bitcoin-meta": "^1.0.0",
|
|
67
|
-
"@exodus/connected-origins": "^2.0.0",
|
|
68
|
-
"@exodus/crypto-news-monitor": "^3.0.0",
|
|
69
50
|
"@exodus/currency": "^2.2.0",
|
|
70
51
|
"@exodus/ethereum-lib": "^2.22.2",
|
|
71
52
|
"@exodus/ethereum-meta": "^1.0.23",
|
|
72
|
-
"@exodus/kyc": "^4.0.0",
|
|
73
53
|
"@exodus/models": "^8.11.1",
|
|
74
|
-
"@exodus/nfts": "^4.0.0",
|
|
75
|
-
"@exodus/personal-notes": "^3.3.0",
|
|
76
|
-
"@exodus/referrals": "^6.2.0",
|
|
77
54
|
"@exodus/solana-lib": "^1.3.11",
|
|
78
55
|
"@exodus/solana-meta": "^1.0.2",
|
|
79
56
|
"@exodus/storage-encrypted": "^1.1.2",
|
|
80
|
-
"@exodus/storage-memory": "^
|
|
81
|
-
"@exodus/top-movers-monitor": "^3.0.0",
|
|
57
|
+
"@exodus/storage-memory": "^1.1.0",
|
|
82
58
|
"@exodus/wild-emitter": "^1.0.0",
|
|
83
59
|
"buffer-json": "^2.0.0",
|
|
84
|
-
"
|
|
85
|
-
"delay": "^5.0.0",
|
|
86
|
-
"eslint": "^8.44.0",
|
|
87
|
-
"eslint-plugin-simple-import-sort": "^7.0.0",
|
|
88
|
-
"events": "^3.3.0",
|
|
60
|
+
"eslint": "^8.33.0",
|
|
89
61
|
"jest": "^29.1.2",
|
|
90
|
-
"nock": "^13.3.1",
|
|
91
62
|
"p-defer": "^4.0.0"
|
|
92
63
|
},
|
|
93
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "b6930ca25bb34b679efb0d2d76c9a8b21eeb8728"
|
|
94
65
|
}
|
package/src/api.js
CHANGED
|
@@ -1,23 +1,78 @@
|
|
|
1
1
|
import { validateMnemonic as isMnemonicValid } from 'bip39'
|
|
2
2
|
|
|
3
3
|
const createApi = ({ ioc, port }) => {
|
|
4
|
-
const
|
|
5
|
-
const { remoteConfig } = ioc.getByType('module')
|
|
6
|
-
const { feeMonitors, nftsMonitor } = ioc.getByType('monitor')
|
|
4
|
+
const { passphraseCache } = ioc.getByType('adapter')
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
const {
|
|
7
|
+
application,
|
|
8
|
+
assetsModule,
|
|
9
|
+
blockchainMetadata,
|
|
10
|
+
enabledAssets,
|
|
11
|
+
remoteConfig,
|
|
12
|
+
wallet,
|
|
13
|
+
walletAccounts,
|
|
14
|
+
} = ioc.getByType('module')
|
|
15
|
+
|
|
16
|
+
const { enabledWalletAccountsAtom } = ioc.getByType('atom')
|
|
14
17
|
|
|
15
18
|
return {
|
|
16
|
-
|
|
19
|
+
wallet: {
|
|
20
|
+
exists: () => wallet.exists(),
|
|
21
|
+
load: application.load,
|
|
22
|
+
unload: application.unload,
|
|
23
|
+
create: application.create,
|
|
24
|
+
lock: application.lock,
|
|
25
|
+
unlock: application.unlock,
|
|
26
|
+
import: application.import,
|
|
27
|
+
delete: application.delete,
|
|
28
|
+
getMnemonic: application.getMnemonic,
|
|
29
|
+
setBackedUp: application.setBackedUp,
|
|
30
|
+
changePassphrase: application.changePassphrase,
|
|
31
|
+
restoreFromCurrentPhrase: async ({ passphrase } = {}) => {
|
|
32
|
+
if (!passphrase) passphrase = await passphraseCache.get()
|
|
33
|
+
const mnemonic = await application.getMnemonic({ passphrase })
|
|
34
|
+
|
|
35
|
+
await application.import({ passphrase, mnemonic })
|
|
36
|
+
},
|
|
37
|
+
changeLockTimer: application.changeLockTimer,
|
|
38
|
+
isLocked: () => wallet.isLocked(),
|
|
39
|
+
},
|
|
40
|
+
walletAccounts: {
|
|
41
|
+
create: walletAccounts.create,
|
|
42
|
+
update: walletAccounts.update,
|
|
43
|
+
disable: walletAccounts.disable,
|
|
44
|
+
enable: walletAccounts.enable,
|
|
45
|
+
getEnabled: enabledWalletAccountsAtom.get,
|
|
46
|
+
},
|
|
47
|
+
blockchainMetadata: {
|
|
48
|
+
getTxLog: blockchainMetadata.getTxLog,
|
|
49
|
+
getLoadedTxLogs: blockchainMetadata.getLoadedTxLogs,
|
|
50
|
+
updateTxs: blockchainMetadata.updateTxs,
|
|
51
|
+
overwriteTxs: blockchainMetadata.overwriteTxs,
|
|
52
|
+
clearTxs: blockchainMetadata.clearTxs,
|
|
53
|
+
removeTxs: blockchainMetadata.removeTxs,
|
|
54
|
+
getAccountState: blockchainMetadata.getAccountState,
|
|
55
|
+
getLoadedAccountStates: blockchainMetadata.getLoadedAccountStates,
|
|
56
|
+
updateAccountState: blockchainMetadata.updateAccountState,
|
|
57
|
+
removeAccountState: blockchainMetadata.removeAccountState,
|
|
58
|
+
batch: blockchainMetadata.batch,
|
|
59
|
+
},
|
|
60
|
+
assets: {
|
|
61
|
+
enable: enabledAssets.enable,
|
|
62
|
+
disable: enabledAssets.disable,
|
|
63
|
+
addAndEnableToken: async (...args) => {
|
|
64
|
+
const asset = await assetsModule.addToken(...args)
|
|
65
|
+
await enabledAssets.enable([asset.name])
|
|
66
|
+
return asset.name
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
remoteConfig: {
|
|
70
|
+
get: remoteConfig.get,
|
|
71
|
+
getAll: remoteConfig.getAll,
|
|
72
|
+
},
|
|
17
73
|
isMnemonicValid,
|
|
18
74
|
subscribe: port.subscribe.bind(port),
|
|
19
75
|
unsubscribe: port.unsubscribe.bind(port),
|
|
20
|
-
stop,
|
|
21
76
|
}
|
|
22
77
|
}
|
|
23
78
|
|
package/src/application.js
CHANGED
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
import ExodusModule from '@exodus/module'
|
|
4
4
|
import assert from 'minimalistic-assert'
|
|
5
5
|
|
|
6
|
-
import { LifecycleHook as Hook } from './constants'
|
|
7
|
-
|
|
8
6
|
// Because we are forced to restart wallet after deleting/importing, we need to store certain flags to persist state between executions
|
|
9
7
|
|
|
10
8
|
// Triggers deletetion logic when wallet starts.
|
|
@@ -19,7 +17,22 @@ const IMPORT_FLAG = 'importFlag'
|
|
|
19
17
|
// Set as true on import method is called, and set to false after restore is completed
|
|
20
18
|
const RESTORE_FLAG = 'restoreFlag'
|
|
21
19
|
|
|
22
|
-
const HOOKS =
|
|
20
|
+
const HOOKS = Object.freeze({
|
|
21
|
+
lock: 'lock',
|
|
22
|
+
unlock: 'unlock',
|
|
23
|
+
clear: 'clear',
|
|
24
|
+
import: 'import',
|
|
25
|
+
migrate: 'migrate',
|
|
26
|
+
start: 'start',
|
|
27
|
+
load: 'load',
|
|
28
|
+
unload: 'unload',
|
|
29
|
+
create: 'create',
|
|
30
|
+
backup: 'backup',
|
|
31
|
+
restore: 'restore',
|
|
32
|
+
'restore-completed': 'restore-completed',
|
|
33
|
+
'assets-synced': 'assets-synced',
|
|
34
|
+
'change-passphrase': 'change-passphrase',
|
|
35
|
+
})
|
|
23
36
|
|
|
24
37
|
class Application extends ExodusModule {
|
|
25
38
|
#hooks = {}
|
|
@@ -56,26 +69,12 @@ class Application extends ExodusModule {
|
|
|
56
69
|
const walletExists = await this.#wallet.exists()
|
|
57
70
|
|
|
58
71
|
if (isImporting || !walletExists) {
|
|
59
|
-
await this.fire(
|
|
72
|
+
await this.fire(HOOKS.clear)
|
|
60
73
|
}
|
|
61
74
|
|
|
62
|
-
if (isImporting) await this.fire(
|
|
63
|
-
|
|
64
|
-
const [hasPassphraseSet, isLocked, isBackedUp, isRestoring] = await Promise.all([
|
|
65
|
-
this.#wallet.hasPassphraseSet(),
|
|
66
|
-
this.#wallet.isLocked(),
|
|
67
|
-
this.#wallet.isBackedUp(),
|
|
68
|
-
this.isRestoring(),
|
|
69
|
-
])
|
|
70
|
-
|
|
71
|
-
await this.fire(Hook.Start, {
|
|
72
|
-
walletExists,
|
|
73
|
-
hasPassphraseSet,
|
|
74
|
-
isLocked,
|
|
75
|
-
isBackedUp,
|
|
76
|
-
isRestoring,
|
|
77
|
-
})
|
|
75
|
+
if (isImporting) await this.fire(HOOKS.import)
|
|
78
76
|
|
|
77
|
+
await this.fire(HOOKS.start)
|
|
79
78
|
await this.#autoUnlock()
|
|
80
79
|
|
|
81
80
|
const locked = await this.#wallet.isLocked()
|
|
@@ -95,7 +94,7 @@ class Application extends ExodusModule {
|
|
|
95
94
|
this.isRestoring(),
|
|
96
95
|
])
|
|
97
96
|
|
|
98
|
-
await this.fire(
|
|
97
|
+
await this.fire(HOOKS.load, {
|
|
99
98
|
walletExists,
|
|
100
99
|
hasPassphraseSet,
|
|
101
100
|
isLocked,
|
|
@@ -106,11 +105,11 @@ class Application extends ExodusModule {
|
|
|
106
105
|
unload = async () => {
|
|
107
106
|
await this.#applicationStarted
|
|
108
107
|
await this.#passphraseCache.scheduleClear()
|
|
109
|
-
await this.fire(
|
|
108
|
+
await this.fire(HOOKS.unload)
|
|
110
109
|
}
|
|
111
110
|
|
|
112
111
|
hook = (hookName, listener) => {
|
|
113
|
-
assert(HOOKS
|
|
112
|
+
assert(HOOKS[hookName], `no such hook: ${hookName}`)
|
|
114
113
|
|
|
115
114
|
if (!this.#hooks[hookName]) {
|
|
116
115
|
this.#hooks[hookName] = []
|
|
@@ -120,18 +119,13 @@ class Application extends ExodusModule {
|
|
|
120
119
|
}
|
|
121
120
|
|
|
122
121
|
fire = async (hookName, params) => {
|
|
123
|
-
assert(HOOKS
|
|
122
|
+
assert(HOOKS[hookName], `no such hook: ${hookName}`)
|
|
124
123
|
this._logger.debug('firing hooks', hookName)
|
|
125
124
|
|
|
126
125
|
const hooks = this.#hooks[hookName] || []
|
|
127
126
|
|
|
128
127
|
for (let i = 0; i < hooks.length; i++) {
|
|
129
|
-
|
|
130
|
-
await hooks[i](params)
|
|
131
|
-
} catch (err) {
|
|
132
|
-
this._logger.error(`application lifecycle hook failed: ${hookName}`, hooks[i], params)
|
|
133
|
-
throw err
|
|
134
|
-
}
|
|
128
|
+
await hooks[i](params)
|
|
135
129
|
}
|
|
136
130
|
|
|
137
131
|
this.emit(hookName, params)
|
|
@@ -143,15 +137,7 @@ class Application extends ExodusModule {
|
|
|
143
137
|
await this.#applicationStarted
|
|
144
138
|
await this.#wallet.create(opts)
|
|
145
139
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
await this.fire(Hook.Create, {
|
|
149
|
-
hasPassphraseSet: !!opts?.passphrase,
|
|
150
|
-
isBackedUp: false,
|
|
151
|
-
isLocked,
|
|
152
|
-
isRestoring: false,
|
|
153
|
-
walletExists: true,
|
|
154
|
-
})
|
|
140
|
+
await this.fire(HOOKS.create, { hasPassphraseSet: !!opts?.passphrase })
|
|
155
141
|
}
|
|
156
142
|
|
|
157
143
|
import = async (opts) => {
|
|
@@ -163,16 +149,16 @@ class Application extends ExodusModule {
|
|
|
163
149
|
|
|
164
150
|
const walletExists = await this.#wallet.exists()
|
|
165
151
|
|
|
166
|
-
const { forceRestart,
|
|
152
|
+
const { forceRestart, ...wallet } = opts
|
|
167
153
|
|
|
168
154
|
await this.#wallet.import(wallet)
|
|
169
155
|
|
|
170
156
|
if (forceRestart || walletExists) {
|
|
171
157
|
await this.#storage.set(IMPORT_FLAG, true)
|
|
172
158
|
|
|
173
|
-
|
|
159
|
+
this.emit('restart', { reason: 'import' })
|
|
174
160
|
} else {
|
|
175
|
-
await this.fire(
|
|
161
|
+
await this.fire(HOOKS.import)
|
|
176
162
|
|
|
177
163
|
this._logger.log('wallet imported')
|
|
178
164
|
}
|
|
@@ -182,7 +168,7 @@ class Application extends ExodusModule {
|
|
|
182
168
|
|
|
183
169
|
setBackedUp = async () => {
|
|
184
170
|
await this.#wallet.setBackedUp()
|
|
185
|
-
await this.fire(
|
|
171
|
+
await this.fire(HOOKS.backup)
|
|
186
172
|
}
|
|
187
173
|
|
|
188
174
|
lock = async (opts) => {
|
|
@@ -191,7 +177,7 @@ class Application extends ExodusModule {
|
|
|
191
177
|
await this.#applicationStarted
|
|
192
178
|
await this.#wallet.lock(opts)
|
|
193
179
|
await this.#passphraseCache.clear()
|
|
194
|
-
await this.fire(
|
|
180
|
+
await this.fire(HOOKS.lock)
|
|
195
181
|
|
|
196
182
|
this._logger.log('locked')
|
|
197
183
|
}
|
|
@@ -200,13 +186,13 @@ class Application extends ExodusModule {
|
|
|
200
186
|
const isRestoring = await this.isRestoring()
|
|
201
187
|
|
|
202
188
|
if (isRestoring) {
|
|
203
|
-
await this.fire(
|
|
189
|
+
await this.fire(HOOKS.restore)
|
|
204
190
|
await this.#storage.delete(RESTORE_FLAG)
|
|
205
191
|
await this.setBackedUp()
|
|
206
|
-
await this.fire(
|
|
192
|
+
await this.fire(HOOKS['restore-completed'])
|
|
207
193
|
}
|
|
208
194
|
|
|
209
|
-
this.fire(
|
|
195
|
+
this.fire(HOOKS['assets-synced'])
|
|
210
196
|
}
|
|
211
197
|
|
|
212
198
|
#autoUnlock = async () => {
|
|
@@ -219,7 +205,7 @@ class Application extends ExodusModule {
|
|
|
219
205
|
this._logger.log('unlocking with cache')
|
|
220
206
|
|
|
221
207
|
await this.#wallet.unlock({ passphrase })
|
|
222
|
-
await this.fire(
|
|
208
|
+
await this.fire(HOOKS.unlock)
|
|
223
209
|
|
|
224
210
|
this.#restoreIfNeeded()
|
|
225
211
|
|
|
@@ -235,8 +221,8 @@ class Application extends ExodusModule {
|
|
|
235
221
|
await this.#applicationStarted
|
|
236
222
|
await this.#wallet.unlock({ passphrase })
|
|
237
223
|
|
|
238
|
-
await this.fire(
|
|
239
|
-
await this.fire(
|
|
224
|
+
await this.fire(HOOKS.migrate)
|
|
225
|
+
await this.fire(HOOKS.unlock)
|
|
240
226
|
|
|
241
227
|
this.#restoreIfNeeded()
|
|
242
228
|
|
|
@@ -251,14 +237,14 @@ class Application extends ExodusModule {
|
|
|
251
237
|
await this.#applicationStarted
|
|
252
238
|
await this.#wallet.changePassphrase({ currentPassphrase, newPassphrase })
|
|
253
239
|
await this.#passphraseCache.set(newPassphrase)
|
|
254
|
-
await this.fire(
|
|
240
|
+
await this.fire(HOOKS['change-passphrase'])
|
|
255
241
|
|
|
256
242
|
this._logger.log('passphrase changed')
|
|
257
243
|
}
|
|
258
244
|
|
|
259
|
-
delete = async (
|
|
245
|
+
delete = async () => {
|
|
260
246
|
await this.#storage.set(DELETE_FLAG, true)
|
|
261
|
-
|
|
247
|
+
this.emit('restart', { reason: 'delete' })
|
|
262
248
|
}
|
|
263
249
|
|
|
264
250
|
changeLockTimer = async ({ ttl }) => {
|
|
@@ -1,5 +1,32 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createInMemoryAtom } from '@exodus/atoms'
|
|
2
|
+
import {
|
|
3
|
+
walletAccountsAtomDefinition,
|
|
4
|
+
enabledWalletAccountsAtomDefinition,
|
|
5
|
+
} from '@exodus/wallet-accounts/atoms'
|
|
2
6
|
|
|
3
|
-
|
|
7
|
+
import {
|
|
8
|
+
enabledAndDisabledAssetsAtomDefinition,
|
|
9
|
+
enabledAssetsAtomDefinition,
|
|
10
|
+
} from '@exodus/enabled-assets/atoms'
|
|
11
|
+
|
|
12
|
+
import { withType } from './utils'
|
|
13
|
+
|
|
14
|
+
const createAtomDependencies = () =>
|
|
15
|
+
[
|
|
16
|
+
{
|
|
17
|
+
definition: {
|
|
18
|
+
id: 'lockedAtom',
|
|
19
|
+
factory: () => createInMemoryAtom({ defaultValue: true }),
|
|
20
|
+
dependencies: [],
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
definition: walletAccountsAtomDefinition,
|
|
25
|
+
storage: { namespace: 'walletAccounts' },
|
|
26
|
+
},
|
|
27
|
+
{ definition: enabledWalletAccountsAtomDefinition },
|
|
28
|
+
{ definition: enabledAndDisabledAssetsAtomDefinition },
|
|
29
|
+
{ definition: enabledAssetsAtomDefinition },
|
|
30
|
+
].map(withType('atom'))
|
|
4
31
|
|
|
5
32
|
export default createAtomDependencies
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
|
|
4
4
|
import assert from 'minimalistic-assert'
|
|
5
5
|
|
|
6
|
+
import createConfigDependencies from './configs'
|
|
6
7
|
import createAdapterDependencies from './adapters'
|
|
7
8
|
import createAtomDependencies from './atoms'
|
|
8
|
-
import createConfigDependencies from './configs'
|
|
9
9
|
import createModuleDependencies from './modules'
|
|
10
|
-
import createPluginDependencies from './plugins'
|
|
11
10
|
import { wrapConstant } from './utils'
|
|
11
|
+
import createPluginDependencies from './plugins'
|
|
12
12
|
|
|
13
13
|
const adapterKeys = [
|
|
14
14
|
// ...
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
import createRemoteConfig from '@exodus/config/remote'
|
|
2
|
+
import keychainDefinition from '@exodus/keychain/module'
|
|
3
|
+
import walletDefinition from '@exodus/wallet/module'
|
|
4
|
+
import walletAccountsDefinition from '@exodus/wallet-accounts/module'
|
|
5
|
+
import blockchainMetadataDefinition from '@exodus/blockchain-metadata/module'
|
|
6
|
+
import enabledAssetsModuleDefinition from '@exodus/enabled-assets/module'
|
|
1
7
|
import createKeyIdentifierProvider from '@exodus/key-identifier-provider'
|
|
2
8
|
import walletCompatibilityModesDefinition from '@exodus/wallet-compatibility-modes/module'
|
|
9
|
+
import EventEmitter from 'events/'
|
|
3
10
|
|
|
4
11
|
import createApplication from '../application'
|
|
5
|
-
import unlockEncryptedStorageDefinition from '../unlock-encrypted-storage'
|
|
6
12
|
import { withType } from './utils'
|
|
13
|
+
import unlockEncryptedStorageDefinition from '../unlock-encrypted-storage'
|
|
7
14
|
|
|
8
|
-
const createModuleDependencies = (
|
|
15
|
+
const createModuleDependencies = () =>
|
|
9
16
|
[
|
|
10
17
|
{
|
|
11
18
|
definition: {
|
|
@@ -21,10 +28,32 @@ const createModuleDependencies = ({ config }) =>
|
|
|
21
28
|
dependencies: [],
|
|
22
29
|
},
|
|
23
30
|
},
|
|
31
|
+
{
|
|
32
|
+
definition: keychainDefinition,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
definition: walletDefinition,
|
|
36
|
+
},
|
|
24
37
|
{
|
|
25
38
|
definition: walletCompatibilityModesDefinition,
|
|
26
39
|
},
|
|
27
40
|
{ definition: unlockEncryptedStorageDefinition },
|
|
41
|
+
{ definition: walletAccountsDefinition },
|
|
42
|
+
{
|
|
43
|
+
definition: blockchainMetadataDefinition,
|
|
44
|
+
storage: { namespace: ['blockchain', 'v1'] },
|
|
45
|
+
},
|
|
46
|
+
{ definition: enabledAssetsModuleDefinition },
|
|
47
|
+
{
|
|
48
|
+
definition: {
|
|
49
|
+
id: 'remoteConfig',
|
|
50
|
+
factory: (deps) => {
|
|
51
|
+
const eventEmitter = new EventEmitter().setMaxListeners(Number.POSITIVE_INFINITY)
|
|
52
|
+
return createRemoteConfig({ eventEmitter, ...deps })
|
|
53
|
+
},
|
|
54
|
+
dependencies: ['fetch', 'freeze', 'config', 'logger'],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
28
57
|
].map(withType('module'))
|
|
29
58
|
|
|
30
59
|
export default createModuleDependencies
|
|
@@ -2,6 +2,10 @@ export const wrapConstant = ({ id, type, value }) => ({
|
|
|
2
2
|
definition: { id, type, factory: () => value },
|
|
3
3
|
})
|
|
4
4
|
|
|
5
|
+
export const insertIf = (module, enabled) => {
|
|
6
|
+
return enabled ? [module] : []
|
|
7
|
+
}
|
|
8
|
+
|
|
5
9
|
export const withType =
|
|
6
10
|
(type) =>
|
|
7
11
|
({ definition, ...rest }) => ({
|