@exodus/headless 2.0.0-alpha.87 → 2.0.0-alpha.9

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/README.md CHANGED
@@ -15,7 +15,6 @@ The headless Exodus wallet SDK
15
15
 
16
16
  ```js
17
17
  import createExodus from '@exodus/headless'
18
- import referrals from '@exodus/headless/src/modules/referrals'
19
18
  import Emitter from '@exodus/wild-emitter'
20
19
 
21
20
  // 1. Create port. Acts as an event bus between headless wallet and client
@@ -26,10 +25,10 @@ const adapters = {}
26
25
  const config = {}
27
26
 
28
27
  // 3. Create Exodus container
29
- const exodusContainer = createExodus({ port, adapters, config })
28
+ const container = createExodus({ port, adapters, config })
30
29
 
31
30
  // 4. Register external modules. Does not support overriding modules at the moment.
32
- exodusContainer.register({
31
+ container.register({
33
32
  definition: {
34
33
  id: 'remoteConfig',
35
34
  factory: createRemoteConfig,
@@ -37,22 +36,11 @@ exodusContainer.register({
37
36
  },
38
37
  })
39
38
 
40
- // see an example feature definition:
41
- // https://github.com/ExodusMovement/exodus-hydra/blob/2e8d63426421ffcbec84a9b6fbc83eb913b47eba/modules/headless/src/modules/geolocation/index.js
42
- exodusContainer.use(referrals())
43
- exodusContainer.use(myCustomFeature({ id: 'myCustomFeature', ... }))
44
-
45
39
  // 5. Resolve exodus instance
46
- const exodus = exodusContainer.resolve()
47
-
48
- // 6. Start exodus instance
49
- await exodus.wallet.start()
40
+ const exodus = container.resolve()
50
41
 
51
- // 7. Use it!
42
+ // 6. Use it!
52
43
  await exodus.wallet.create({ passphrase: 'my-super-secure-passphrase' })
53
-
54
- // 8. Use your custom feature API, if any
55
- exodus.myCustomFeature.doThatThingYouDo()
56
44
  ```
57
45
 
58
46
  ## Lifecycle
@@ -268,15 +256,6 @@ Currently not used.
268
256
  | disable | `async (assetNames: string[]) => void` | Disables assets. |
269
257
  | addAndEnableToken | `async (assetId: string, baseAssetName: string) => string` | Adds and enables a custom token. Returns the created `asset`'s `.name` |
270
258
 
271
- ## locale
272
-
273
- > Type: object
274
-
275
- | Method | Type | Description |
276
- | ----------- | ---------------------------------- | ------------------------- |
277
- | setCurrency | `async (currency: string) => void` | Changes current currency. |
278
- | setLanguage | `async (language: string) => void` | Changes current language. |
279
-
280
259
  ## subscribe
281
260
 
282
261
  > Type: function
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@exodus/headless",
3
- "version": "2.0.0-alpha.87",
4
- "description": "The platform-agnostic Exodus wallet SDK",
5
- "author": "Exodus Movement Inc.",
3
+ "version": "2.0.0-alpha.9",
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/sdks/headless",
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,79 +17,51 @@
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 --runInBand"
26
+ "test": "jest"
27
27
  },
28
28
  "dependencies": {
29
- "@exodus/address-provider": "^6.0.0",
30
- "@exodus/atoms": "^5.2.3",
31
- "@exodus/auto-enable-assets-plugin": "^4.0.1",
32
- "@exodus/available-assets": "^3.0.0",
33
- "@exodus/balances": "^7.0.0",
29
+ "@exodus/atoms": "^2.9.0",
30
+ "@exodus/available-assets": "^2.0.0",
34
31
  "@exodus/basic-utils": "^2.0.0",
35
- "@exodus/blockchain-metadata": "^9.0.0",
36
- "@exodus/config": "^7.0.0",
37
- "@exodus/dependency-injection": "^2.0.1",
38
- "@exodus/dependency-preprocessors": "^2.8.4",
39
- "@exodus/enabled-assets": "^7.0.0",
40
- "@exodus/exodus-pricing-client": "^1.2.0",
41
- "@exodus/feature-flags": "^3.0.0",
42
- "@exodus/fee-monitors": "^1.0.0",
32
+ "@exodus/blockchain-metadata": "^8.0.1",
33
+ "@exodus/config": "7.0.0",
34
+ "@exodus/dependency-injection": "^1.2.0",
35
+ "@exodus/dependency-preprocessors": "^2.0.2",
36
+ "@exodus/enabled-assets": "^5.0.4",
43
37
  "@exodus/fetch": "^1.2.1",
44
- "@exodus/fusion": "^6.0.0",
45
- "@exodus/geolocation": "^2.1.1",
46
38
  "@exodus/key-identifier-provider": "^1.1.3",
47
- "@exodus/keychain": "^4.1.0",
48
- "@exodus/locale": "^1.1.0",
39
+ "@exodus/keychain": "^4.0.0",
49
40
  "@exodus/module": "^1.0.0",
50
- "@exodus/rates-monitor": "^3.0.0",
51
- "@exodus/restore-progress-tracker": "^2.0.5",
52
- "@exodus/wallet": "^8.1.1",
53
- "@exodus/wallet-accounts": "^10.1.0",
54
- "@exodus/wallet-compatibility-modes": "^3.0.0",
55
- "bip39": "^2.6.0",
41
+ "@exodus/wallet": "^6.0.1",
42
+ "@exodus/wallet-accounts": "^8.0.1",
43
+ "@exodus/wallet-compatibility-modes": "^2.0.0",
44
+ "bip39": "2.6.0",
56
45
  "events": "^3.3.0",
57
- "lodash": "npm:@exodus/lodash@^4.17.21-exodus.2",
46
+ "lodash": "https://registry.yarnpkg.com/@exodus/lodash/-/lodash-4.17.21-exodus.2.tgz",
58
47
  "minimalistic-assert": "^1.0.1"
59
48
  },
60
49
  "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
50
  "@exodus/bitcoin-meta": "^1.0.0",
67
- "@exodus/connected-origins": "^2.0.0",
68
- "@exodus/crypto-news-monitor": "^3.0.0",
69
51
  "@exodus/currency": "^2.2.0",
70
52
  "@exodus/ethereum-lib": "^2.22.2",
71
53
  "@exodus/ethereum-meta": "^1.0.23",
72
- "@exodus/kyc": "^4.0.0",
73
- "@exodus/market-history": "^5.0.1",
74
54
  "@exodus/models": "^8.11.1",
75
- "@exodus/nfts": "^4.0.1",
76
- "@exodus/personal-notes": "^3.3.0",
77
- "@exodus/referrals": "^6.2.0",
78
55
  "@exodus/solana-lib": "^1.3.11",
79
56
  "@exodus/solana-meta": "^1.0.2",
80
57
  "@exodus/storage-encrypted": "^1.1.2",
81
- "@exodus/storage-memory": "^2.1.0",
82
- "@exodus/top-movers-monitor": "^3.0.0",
58
+ "@exodus/storage-memory": "^1.1.0",
83
59
  "@exodus/wild-emitter": "^1.0.0",
84
60
  "buffer-json": "^2.0.0",
85
- "deepmerge": "^4.2.2",
86
- "delay": "^5.0.0",
87
- "eslint": "^8.44.0",
88
- "eslint-plugin-simple-import-sort": "^7.0.0",
61
+ "eslint": "^8.33.0",
89
62
  "events": "^3.3.0",
90
63
  "jest": "^29.1.2",
91
- "nock": "^13.3.1",
92
64
  "p-defer": "^4.0.0"
93
65
  },
94
- "gitHead": "4aa7f1573f70592832912d16cbd2d818cc504b2b"
66
+ "gitHead": "5649cedee6c33891264a2df328efdd4a840ef8a2"
95
67
  }
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 apis = ioc.getByType('api')
5
- const { remoteConfig } = ioc.getByType('module')
6
- const { feeMonitors, nftsMonitor } = ioc.getByType('monitor')
4
+ const { passphraseCache } = ioc.getByType('adapter')
7
5
 
8
- // TODO: do this on 'unload'
9
- const stop = () => {
10
- remoteConfig.stop()
11
- feeMonitors.stop()
12
- nftsMonitor?.stop()
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
- ...Object.assign({}, ...Object.values(apis)),
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
 
@@ -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 = new Set(Object.values(Hook))
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(Hook.Clear)
72
+ await this.fire(HOOKS.clear)
60
73
  }
61
74
 
62
- if (isImporting) await this.fire(Hook.Import)
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(Hook.Load, {
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(Hook.Unload)
108
+ await this.fire(HOOKS.unload)
110
109
  }
111
110
 
112
111
  hook = (hookName, listener) => {
113
- assert(HOOKS.has(hookName), `no such hook: ${hookName}`)
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.has(hookName), `no such hook: ${hookName}`)
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
- try {
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
- const isLocked = await this.#wallet.isLocked()
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, forgotPassphrase, ...wallet } = opts
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
- await this.fire(Hook.Restart, { reason: 'import' })
159
+ this.emit('restart', { reason: 'import' })
174
160
  } else {
175
- await this.fire(Hook.Import)
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(Hook.Backup)
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(Hook.Lock)
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(Hook.Restore)
189
+ await this.fire(HOOKS.restore)
204
190
  await this.#storage.delete(RESTORE_FLAG)
205
191
  await this.setBackedUp()
206
- await this.fire(Hook.RestoreCompleted)
192
+ await this.fire(HOOKS['restore-completed'])
207
193
  }
208
194
 
209
- this.fire(Hook.AssetsSynced)
195
+ this.fire(HOOKS['assets-synced'])
210
196
  }
211
197
 
212
198
  #autoUnlock = async () => {
@@ -219,9 +205,7 @@ class Application extends ExodusModule {
219
205
  this._logger.log('unlocking with cache')
220
206
 
221
207
  await this.#wallet.unlock({ passphrase })
222
-
223
- await this.fire(Hook.Migrate)
224
- await this.fire(Hook.Unlock)
208
+ await this.fire(HOOKS.unlock)
225
209
 
226
210
  this.#restoreIfNeeded()
227
211
 
@@ -237,8 +221,8 @@ class Application extends ExodusModule {
237
221
  await this.#applicationStarted
238
222
  await this.#wallet.unlock({ passphrase })
239
223
 
240
- await this.fire(Hook.Migrate)
241
- await this.fire(Hook.Unlock)
224
+ await this.fire(HOOKS.migrate)
225
+ await this.fire(HOOKS.unlock)
242
226
 
243
227
  this.#restoreIfNeeded()
244
228
 
@@ -253,14 +237,14 @@ class Application extends ExodusModule {
253
237
  await this.#applicationStarted
254
238
  await this.#wallet.changePassphrase({ currentPassphrase, newPassphrase })
255
239
  await this.#passphraseCache.set(newPassphrase)
256
- await this.fire(Hook.ChangePassphrase)
240
+ await this.fire(HOOKS['change-passphrase'])
257
241
 
258
242
  this._logger.log('passphrase changed')
259
243
  }
260
244
 
261
- delete = async ({ forgotPassphrase } = {}) => {
245
+ delete = async () => {
262
246
  await this.#storage.set(DELETE_FLAG, true)
263
- await this.fire(Hook.Restart, { reason: 'delete', forgotPassphrase })
247
+ this.emit('restart', { reason: 'delete' })
264
248
  }
265
249
 
266
250
  changeLockTimer = async ({ ttl }) => {
@@ -7,12 +7,23 @@ const emitAtomValue = async (opts) => {
7
7
  export const emitFromAtoms = ({ atoms, port }) =>
8
8
  Object.entries(atoms).forEach(async ([atomId, atom]) => emitAtomValue({ port, atomId, atom }))
9
9
 
10
- const attachAtom = ({ port, application, atom, atomId }) => {
10
+ const attachAtom = ({ port, application, logger, atom, atomId, lifecycleEvents }) => {
11
11
  let loaded = false
12
12
 
13
- application.on('load', async () => {
14
- loaded = true
15
- await emitAtomValue({ port, atomId, atom })
13
+ lifecycleEvents.forEach((event) =>
14
+ application.on(event, async () => {
15
+ loaded = true
16
+ await emitAtomValue({ port, atomId, atom })
17
+ })
18
+ )
19
+
20
+ application.on('clear', async () => {
21
+ try {
22
+ await atom?.set(undefined)
23
+ } catch (error) {
24
+ logger.debug('failed to clear atom', error)
25
+ // noop. atom might not support set
26
+ }
16
27
  })
17
28
 
18
29
  atom.observe((value) => {
@@ -20,9 +31,9 @@ const attachAtom = ({ port, application, atom, atomId }) => {
20
31
  })
21
32
  }
22
33
 
23
- const attachAtoms = ({ port, application, atoms }) => {
34
+ const attachAtoms = ({ port, application, logger, atoms, lifecycleEvents = ['start'] }) => {
24
35
  for (const [atomId, atom] of Object.entries(atoms)) {
25
- attachAtom({ port, application, atom, atomId })
36
+ attachAtom({ port, application, logger, atom, atomId, lifecycleEvents })
26
37
  }
27
38
  }
28
39
 
package/src/constants.js CHANGED
@@ -1,38 +1,4 @@
1
1
  export const atomsToAttach = [
2
- 'abTestingAtom',
3
- 'apyRatesAtom',
2
+ //
4
3
  'availableAssetNamesAtom',
5
- 'balancesAtom',
6
- 'connectedOriginsAtom',
7
- 'cryptoNewsAtom',
8
- 'currencyAtom',
9
- 'enabledWalletAccountsAtom',
10
- 'featureFlagsAtom',
11
- 'geolocationAtom',
12
- 'kycAtom',
13
- 'languageAtom',
14
- 'nftsConfigAtom',
15
- 'personalNotesAtom',
16
- 'referralsAtom',
17
- 'topMoversAtom',
18
- 'walletAccountsAtom',
19
- 'restoringAssetsAtom',
20
4
  ]
21
-
22
- export const LifecycleHook = Object.freeze({
23
- Lock: 'lock',
24
- Unlock: 'unlock',
25
- Clear: 'clear',
26
- Import: 'import',
27
- Migrate: 'migrate',
28
- Start: 'start',
29
- Restart: 'restart',
30
- Load: 'load',
31
- Unload: 'unload',
32
- Create: 'create',
33
- Backup: 'backup',
34
- Restore: 'restore',
35
- RestoreCompleted: 'restore-completed',
36
- AssetsSynced: 'assets-synced',
37
- ChangePassphrase: 'change-passphrase',
38
- })
@@ -1,5 +1,35 @@
1
- import baseAssetNamesToMonitorAtomDefinition from '../atoms/base-asset-names-to-monitor'
1
+ import { createInMemoryAtom } from '@exodus/atoms'
2
+ import {
3
+ walletAccountsAtomDefinition,
4
+ enabledWalletAccountsAtomDefinition,
5
+ } from '@exodus/wallet-accounts/atoms'
2
6
 
3
- const createAtomDependencies = () => [{ definition: baseAssetNamesToMonitorAtomDefinition }]
7
+ import {
8
+ enabledAndDisabledAssetsAtomDefinition,
9
+ enabledAssetsAtomDefinition,
10
+ } from '@exodus/enabled-assets/atoms'
11
+
12
+ import { availableAssetNamesAtomDefinition } from '@exodus/available-assets/atoms'
13
+
14
+ import { withType } from './utils'
15
+
16
+ const createAtomDependencies = () =>
17
+ [
18
+ {
19
+ definition: {
20
+ id: 'lockedAtom',
21
+ factory: () => createInMemoryAtom({ defaultValue: true }),
22
+ dependencies: [],
23
+ },
24
+ },
25
+ {
26
+ definition: walletAccountsAtomDefinition,
27
+ storage: { namespace: 'walletAccounts' },
28
+ },
29
+ { definition: enabledWalletAccountsAtomDefinition },
30
+ { definition: enabledAndDisabledAssetsAtomDefinition },
31
+ { definition: enabledAssetsAtomDefinition },
32
+ { definition: availableAssetNamesAtomDefinition },
33
+ ].map(withType('atom'))
4
34
 
5
35
  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,19 @@
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'
7
+ import availableAssetsModuleDefinition from '@exodus/available-assets/module'
1
8
  import createKeyIdentifierProvider from '@exodus/key-identifier-provider'
2
9
  import walletCompatibilityModesDefinition from '@exodus/wallet-compatibility-modes/module'
10
+ import EventEmitter from 'events/'
3
11
 
4
12
  import createApplication from '../application'
5
- import unlockEncryptedStorageDefinition from '../unlock-encrypted-storage'
6
13
  import { withType } from './utils'
14
+ import unlockEncryptedStorageDefinition from '../unlock-encrypted-storage'
7
15
 
8
- const createModuleDependencies = ({ config }) =>
16
+ const createModuleDependencies = () =>
9
17
  [
10
18
  {
11
19
  definition: {
@@ -21,10 +29,33 @@ const createModuleDependencies = ({ config }) =>
21
29
  dependencies: [],
22
30
  },
23
31
  },
32
+ {
33
+ definition: keychainDefinition,
34
+ },
35
+ {
36
+ definition: walletDefinition,
37
+ },
24
38
  {
25
39
  definition: walletCompatibilityModesDefinition,
26
40
  },
27
41
  { definition: unlockEncryptedStorageDefinition },
42
+ { definition: walletAccountsDefinition },
43
+ {
44
+ definition: blockchainMetadataDefinition,
45
+ storage: { namespace: ['blockchain', 'v1'] },
46
+ },
47
+ { definition: enabledAssetsModuleDefinition },
48
+ {
49
+ definition: {
50
+ id: 'remoteConfig',
51
+ factory: (deps) => {
52
+ const eventEmitter = new EventEmitter().setMaxListeners(Number.POSITIVE_INFINITY)
53
+ return createRemoteConfig({ eventEmitter, ...deps })
54
+ },
55
+ dependencies: ['fetch', 'freeze', 'config', 'logger'],
56
+ },
57
+ },
58
+ { definition: availableAssetsModuleDefinition },
28
59
  ].map(withType('module'))
29
60
 
30
61
  export default createModuleDependencies