@exodus/headless 4.0.0 → 5.0.0-rc.0

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 CHANGED
@@ -3,6 +3,28 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [5.0.0-rc.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@4.0.1...@exodus/headless@5.0.0-rc.0) (2024-04-15)
7
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ - accept port via adapters (#6362)
11
+ - assets balance fields (#5933)
12
+
13
+ ### Features
14
+
15
+ - accept port via adapters ([#6362](https://github.com/ExodusMovement/exodus-hydra/issues/6362)) ([8c5619a](https://github.com/ExodusMovement/exodus-hydra/commit/8c5619a11a63a8eda5a193e1cd5242696a480cd2))
16
+ - assets balance fields ([#5933](https://github.com/ExodusMovement/exodus-hydra/issues/5933)) ([000eb65](https://github.com/ExodusMovement/exodus-hydra/commit/000eb653d9424b2a427f087009a2cc0dd5d0b3ea))
17
+ - pass through restartOptions in application.delete ([#6223](https://github.com/ExodusMovement/exodus-hydra/issues/6223)) ([db700d0](https://github.com/ExodusMovement/exodus-hydra/commit/db700d0f19c9437e2a4612df4f5b11eec2e20751))
18
+ - update default wallet account with mode and seed id ([#6091](https://github.com/ExodusMovement/exodus-hydra/issues/6091)) ([311061f](https://github.com/ExodusMovement/exodus-hydra/commit/311061fea6b6fb5bfea6bb8992ae01fa475f50d1))
19
+
20
+ ### Bug Fixes
21
+
22
+ - kyc test setup ([#6256](https://github.com/ExodusMovement/exodus-hydra/issues/6256)) ([694dd5c](https://github.com/ExodusMovement/exodus-hydra/commit/694dd5cc70f369b56b5b197b405dccfec18baa34))
23
+
24
+ ## [4.0.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@4.0.0...@exodus/headless@4.0.1) (2024-03-11)
25
+
26
+ **Note:** Version bump only for package @exodus/headless
27
+
6
28
  ## [4.0.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@3.2.0...@exodus/headless@4.0.0) (2024-03-08)
7
29
 
8
30
  ### ⚠ BREAKING CHANGES
package/README.md CHANGED
@@ -167,13 +167,13 @@ Unsafe (raw text) storage instance. Used internally by modules to persist data i
167
167
 
168
168
  In most cases you probably want to use encrypted storage instead (not yet migrated).
169
169
 
170
- Check [storage-spec](https://github.com/ExodusMovement/exodus-hydra/tree/master/modules/storage-spec) for more details about Storage API
170
+ Check [storage-spec](https://github.com/ExodusMovement/exodus-hydra/tree/master/adapters/storage-spec/spec.md) for more details about Storage API
171
171
 
172
172
  ### seedStorage
173
173
 
174
174
  Storage instance used unquely by wallet module to store seed and autogenerated passphrase (if present).
175
175
 
176
- Check [storage-spec](https://github.com/ExodusMovement/exodus-hydra/tree/master/modules/storage-spec) for more details about Storage API
176
+ Check [storage-spec](https://github.com/ExodusMovement/exodus-hydra/tree/master/adapters/storage-spec/spec.md) for more details about Storage API
177
177
 
178
178
  > **Note:** Because Browser Extension needs the passphrase to encrypt/decrypt seed, it get's passed as a 3rd parameter to get/set
179
179
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/headless",
3
- "version": "4.0.0",
3
+ "version": "5.0.0-rc.0",
4
4
  "description": "The platform-agnostic Exodus wallet SDK",
5
5
  "author": "Exodus Movement Inc.",
6
6
  "main": "src/index.js",
@@ -31,7 +31,7 @@
31
31
  "@exodus/assets-feature": "^4.0.1",
32
32
  "@exodus/atoms": "^7.0.0",
33
33
  "@exodus/available-assets": "^8.0.0",
34
- "@exodus/balances": "^12.4.0",
34
+ "@exodus/balances": "^13.0.0",
35
35
  "@exodus/basic-utils": "^2.0.0",
36
36
  "@exodus/blockchain-metadata": "^15.0.0",
37
37
  "@exodus/dependency-injection": "^2.1.2",
@@ -44,7 +44,6 @@
44
44
  "@exodus/fusion-atoms": "^1.1.2",
45
45
  "@exodus/geolocation": "^4.1.0",
46
46
  "@exodus/hd-key-slip-10": "^2.0.0",
47
- "@exodus/key-identifier-provider": "^1.4.0",
48
47
  "@exodus/key-ids": "^1.0.0",
49
48
  "@exodus/keychain": "^6.1.0",
50
49
  "@exodus/locale": "^2.0.2",
@@ -58,7 +57,8 @@
58
57
  "@exodus/sodium-crypto": "^3.2.0",
59
58
  "@exodus/startup-counter": "^1.0.0",
60
59
  "@exodus/tx-signer": "^2.0.1",
61
- "@exodus/wallet": "^13.0.0",
60
+ "@exodus/typeforce": "^1.18.1",
61
+ "@exodus/wallet": "^14.0.0",
62
62
  "@exodus/wallet-accounts": "^16.2.0",
63
63
  "bip39": "^2.6.0",
64
64
  "events": "^3.3.0",
@@ -76,24 +76,25 @@
76
76
  "@exodus/bip32": "^2.1.1",
77
77
  "@exodus/bitcoin-plugin": "^1.0.14",
78
78
  "@exodus/connected-origins": "^3.3.0",
79
- "@exodus/crypto-news-monitor": "^4.1.0",
79
+ "@exodus/crypto-news-monitor": "^5.0.0",
80
80
  "@exodus/currency": "^2.2.0",
81
81
  "@exodus/ethereum-lib": "^3.3.34",
82
82
  "@exodus/ethereum-meta": "^1.0.23",
83
83
  "@exodus/exodus-pricing-client": "^1.2.0",
84
+ "@exodus/fetch-factory": "^1.0.0",
84
85
  "@exodus/key-utils": "^3.0.0",
85
- "@exodus/kyc": "^4.4.0",
86
+ "@exodus/kyc": "^5.0.0",
86
87
  "@exodus/litecoin-meta": "^1.0.0",
87
88
  "@exodus/market-history": "^7.4.0",
88
89
  "@exodus/models": "^11.9.0",
89
- "@exodus/nfts": "^8.0.3",
90
+ "@exodus/nfts": "^9.1.1",
90
91
  "@exodus/personal-notes": "^3.6.0",
91
92
  "@exodus/referrals": "^8.2.0",
92
- "@exodus/solana-lib": "^1.3.11",
93
+ "@exodus/solana-lib": "^2.0.0",
93
94
  "@exodus/solana-meta": "^1.0.2",
94
95
  "@exodus/storage-encrypted": "^1.2.0",
95
96
  "@exodus/storage-memory": "^2.1.1",
96
- "@exodus/top-movers-monitor": "^4.0.0",
97
+ "@exodus/top-movers-monitor": "^4.1.0",
97
98
  "@exodus/ui-config": "^3.4.0",
98
99
  "@exodus/wild-emitter": "^1.0.0",
99
100
  "buffer-json": "^2.0.0",
@@ -104,5 +105,5 @@
104
105
  "msw": "^2.0.0",
105
106
  "p-defer": "^4.0.0"
106
107
  },
107
- "gitHead": "b23568229a3e40c4cb1bf3c0cc8ac203573df84a"
108
+ "gitHead": "cd2d72202cb71d7fff8e340ab54193543bfc53c4"
108
109
  }
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable unicorn/no-for-loop */
2
2
 
3
- import ExodusModule from '@exodus/module'
3
+ import ExodusModule from '@exodus/module' // eslint-disable-line import/no-deprecated
4
4
  import assert from 'minimalistic-assert'
5
5
 
6
6
  import { LifecycleHook as Hook } from '../constants'
@@ -31,13 +31,14 @@ const passphraseCachePlaceholder = {
31
31
 
32
32
  class Application extends ExodusModule {
33
33
  #hooks = {}
34
- #wallet = null
35
- #storage = null
36
- #lockedAtom = null
37
- #backedUpAtom = null
38
- #passphraseCache = null
39
- #applicationStarted = null
40
- #resolveStart = null
34
+ #wallet
35
+ #lockedAtom
36
+ #backedUpAtom
37
+ #passphraseCache
38
+ #applicationStarted
39
+ #resolveStart
40
+ #flagsStorage
41
+ #storage
41
42
 
42
43
  constructor({
43
44
  wallet,
@@ -53,14 +54,15 @@ class Application extends ExodusModule {
53
54
  this.#lockedAtom = lockedAtom
54
55
  this.#backedUpAtom = backedUpAtom
55
56
  this.#passphraseCache = passphraseCache
56
- this.#storage = unsafeStorage.namespace('flags')
57
+ this.#flagsStorage = unsafeStorage.namespace('flags')
58
+ this.#storage = unsafeStorage.namespace('application')
57
59
 
58
60
  this.#applicationStarted = new Promise((resolve) => (this.#resolveStart = resolve))
59
61
  this.setMaxListeners(Number.POSITIVE_INFINITY)
60
62
  }
61
63
 
62
64
  start = async () => {
63
- const [deleteFlag, importFlag] = await this.#storage.batchGet([DELETE_FLAG, IMPORT_FLAG])
65
+ const [deleteFlag, importFlag] = await this.#flagsStorage.batchGet([DELETE_FLAG, IMPORT_FLAG])
64
66
 
65
67
  const isDeleting = !!deleteFlag
66
68
  const isImporting = !!importFlag
@@ -68,7 +70,7 @@ class Application extends ExodusModule {
68
70
  if (isDeleting) await this.#wallet.clear()
69
71
 
70
72
  if (isDeleting || isImporting) {
71
- await this.#storage.batchDelete([DELETE_FLAG, IMPORT_FLAG])
73
+ await this.#flagsStorage.batchDelete([DELETE_FLAG, IMPORT_FLAG])
72
74
  await this.#passphraseCache.clear()
73
75
  }
74
76
 
@@ -78,7 +80,10 @@ class Application extends ExodusModule {
78
80
  await this.fire(Hook.Clear, null, { concurrent: true })
79
81
  }
80
82
 
81
- if (isImporting) await this.fire(Hook.Import)
83
+ if (isImporting) {
84
+ const params = await this.#storage.get('importParams')
85
+ await this.fire(Hook.Import, params)
86
+ }
82
87
 
83
88
  const [hasPassphraseSet, isLocked, isBackedUp, isRestoring] = await Promise.all([
84
89
  this.#wallet.hasPassphraseSet(),
@@ -170,7 +175,7 @@ class Application extends ExodusModule {
170
175
  this._logger.log('creating wallet')
171
176
 
172
177
  await this.#applicationStarted
173
- await this.#wallet.create(opts)
178
+ const seedId = await this.#wallet.create(opts)
174
179
 
175
180
  const isLocked = await this.#wallet.isLocked()
176
181
 
@@ -180,28 +185,31 @@ class Application extends ExodusModule {
180
185
  isLocked,
181
186
  isRestoring: false,
182
187
  walletExists: true,
188
+ seedId,
183
189
  })
184
190
  }
185
191
 
186
192
  import = async (opts) => {
187
193
  this._logger.log('importing wallet')
188
194
 
189
- await this.#storage.set(RESTORE_FLAG, true)
195
+ await this.#flagsStorage.set(RESTORE_FLAG, true)
190
196
 
191
197
  await this.#applicationStarted
192
198
 
193
199
  const walletExists = await this.#wallet.exists()
194
200
 
195
- const { forceRestart, forgotPassphrase, ...wallet } = opts
201
+ const { forceRestart, forgotPassphrase, compatibilityMode, ...wallet } = opts
196
202
 
197
- await this.#wallet.import(wallet)
203
+ const seedId = await this.#wallet.import(wallet)
204
+ const importParams = { seedId, compatibilityMode }
198
205
 
199
206
  if (forceRestart || walletExists) {
200
- await this.#storage.set(IMPORT_FLAG, true)
207
+ await this.#flagsStorage.set(IMPORT_FLAG, true)
201
208
 
209
+ await this.#storage.set('importParams', importParams)
202
210
  await this.fire(Hook.Restart, { reason: 'import' })
203
211
  } else {
204
- await this.fire(Hook.Import)
212
+ await this.fire(Hook.Import, importParams)
205
213
 
206
214
  this._logger.log('wallet imported')
207
215
  }
@@ -239,7 +247,7 @@ class Application extends ExodusModule {
239
247
 
240
248
  if (isRestoring) {
241
249
  await this.fire(Hook.Restore)
242
- await this.#storage.delete(RESTORE_FLAG)
250
+ await this.#flagsStorage.delete(RESTORE_FLAG)
243
251
  await this.fire(Hook.RestoreCompleted)
244
252
  }
245
253
 
@@ -249,7 +257,7 @@ class Application extends ExodusModule {
249
257
  }
250
258
 
251
259
  restore = async () => {
252
- await this.#storage.set(RESTORE_FLAG, true)
260
+ await this.#flagsStorage.set(RESTORE_FLAG, true)
253
261
  await this.#restoreIfNeeded()
254
262
  }
255
263
 
@@ -304,9 +312,9 @@ class Application extends ExodusModule {
304
312
  this._logger.log('passphrase changed')
305
313
  }
306
314
 
307
- delete = async ({ forgotPassphrase } = {}) => {
308
- await this.#storage.set(DELETE_FLAG, true)
309
- await this.fire(Hook.Restart, { reason: 'delete', forgotPassphrase })
315
+ delete = async ({ forgotPassphrase, restartOptions } = {}) => {
316
+ await this.#flagsStorage.set(DELETE_FLAG, true)
317
+ await this.fire(Hook.Restart, { ...restartOptions, reason: 'delete', forgotPassphrase })
310
318
  }
311
319
 
312
320
  stop = async () => {
@@ -322,7 +330,7 @@ class Application extends ExodusModule {
322
330
  }
323
331
 
324
332
  isRestoring = async () => {
325
- return this.#storage.get(RESTORE_FLAG)
333
+ return this.#flagsStorage.get(RESTORE_FLAG)
326
334
  }
327
335
 
328
336
  // TODO: stop emitting this on hooks?
@@ -1,18 +1,7 @@
1
- import createKeyIdentifierProvider from '@exodus/key-identifier-provider'
2
-
3
1
  import unlockEncryptedStorageDefinition from '../unlock-encrypted-storage'
4
2
  import { withType } from './utils'
5
3
 
6
- const createModuleDependencies = ({ config }) =>
7
- [
8
- {
9
- definition: {
10
- id: 'keyIdentifierProvider',
11
- factory: createKeyIdentifierProvider,
12
- dependencies: [],
13
- },
14
- },
15
- { definition: unlockEncryptedStorageDefinition },
16
- ].map(withType('module'))
4
+ const createModuleDependencies = () =>
5
+ [{ definition: unlockEncryptedStorageDefinition }].map(withType('module'))
17
6
 
18
7
  export default createModuleDependencies
package/src/index.js CHANGED
@@ -19,6 +19,7 @@ import remoteConfig from '@exodus/remote-config'
19
19
  import restoreProgressTracker from '@exodus/restore-progress-tracker'
20
20
  import startupCounter from '@exodus/startup-counter'
21
21
  import transactionSigner from '@exodus/tx-signer'
22
+ import typeforce from '@exodus/typeforce'
22
23
  import wallet from '@exodus/wallet'
23
24
  import walletAccounts from '@exodus/wallet-accounts'
24
25
 
@@ -28,7 +29,18 @@ import createDependencies from './dependencies'
28
29
  import attachMigrations from './migrations/attach'
29
30
  import attachPlugins from './plugins/attach'
30
31
 
31
- const createExodus = ({ adapters, config, port, debug = false }) => {
32
+ const createExodus = (opts) => {
33
+ typeforce(
34
+ {
35
+ adapters: 'Object',
36
+ config: 'Object',
37
+ debug: '?Boolean',
38
+ },
39
+ opts,
40
+ true
41
+ )
42
+
43
+ const { adapters, config, debug = false } = opts
32
44
  const ioc = createIOC({ adapters, config, debug })
33
45
 
34
46
  ioc.use(application())
@@ -56,7 +68,6 @@ const createExodus = ({ adapters, config, port, debug = false }) => {
56
68
  ioc.use(walletAccounts())
57
69
 
58
70
  ioc.registerMultiple(createDependencies({ adapters, config }))
59
- ioc.register({ definition: { id: 'port', type: 'port', factory: () => port } })
60
71
 
61
72
  const resolve = () => {
62
73
  ioc.resolve()
@@ -67,6 +78,7 @@ const createExodus = ({ adapters, config, port, debug = false }) => {
67
78
 
68
79
  const { migrations } = ioc.getAll()
69
80
 
81
+ const port = ioc.get('port')
70
82
  application.on('start', (payload) => port.emit('start', payload))
71
83
 
72
84
  application.hook('load', (args) => port.emit('pre-load', args))
@@ -1,10 +1,10 @@
1
1
  const setBuildMetadataProperties = async ({ analytics, getBuildMetadata }) => {
2
- analytics.requireDefaultProperties(['appId', 'osName'])
2
+ analytics.requireDefaultEventProperties(['appId', 'osName'])
3
3
 
4
4
  const { appId, osName, deviceModel, platformVersion, deviceManufacturer } =
5
5
  await getBuildMetadata()
6
6
 
7
- analytics.setDefaultProperties({
7
+ analytics.setDefaultEventProperties({
8
8
  appId,
9
9
  osName,
10
10
  deviceModel,
@@ -17,13 +17,13 @@ const setBuildMetadataProperties = async ({ analytics, getBuildMetadata }) => {
17
17
 
18
18
  const setSystemPreferencesProperties = async ({ analytics, systemPreferences }) => {
19
19
  if (!systemPreferences) return
20
- analytics.requireDefaultProperties(['locale'])
20
+ analytics.requireDefaultEventProperties(['locale'])
21
21
  const languages = await systemPreferences.getPreferredLanguages()
22
- analytics.setDefaultProperties({ locale: languages })
22
+ analytics.setDefaultEventProperties({ locale: languages })
23
23
  }
24
24
 
25
25
  const setEnvProperties = async ({ analytics, env }) => {
26
- analytics.setDefaultProperties({
26
+ analytics.setDefaultEventProperties({
27
27
  appPlatform: env.platform,
28
28
  appVersion: env.version,
29
29
  appBuild: env.build === 'development' ? 'dev' : 'prod',