@exodus/headless 2.0.0-alpha.53 → 2.0.0-alpha.55

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,22 @@
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
+ ## [2.0.0-alpha.55](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.54...@exodus/headless@2.0.0-alpha.55) (2023-06-28)
7
+
8
+ ### Bug Fixes
9
+
10
+ - make restart a lifecycle hook ([#2136](https://github.com/ExodusMovement/exodus-hydra/issues/2136)) ([dbb4269](https://github.com/ExodusMovement/exodus-hydra/commit/dbb42697fc09fb4a18a1918fa83c379171e2e7e3))
11
+
12
+ ## [2.0.0-alpha.54](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.53...@exodus/headless@2.0.0-alpha.54) (2023-06-23)
13
+
14
+ ### ⚠ BREAKING CHANGES
15
+
16
+ - make personal-notes opt-in (#2102)
17
+
18
+ ### Features
19
+
20
+ - make personal-notes opt-in ([#2102](https://github.com/ExodusMovement/exodus-hydra/issues/2102)) ([324b64e](https://github.com/ExodusMovement/exodus-hydra/commit/324b64e616025ac7bd095028599736c0bfa97f74))
21
+
6
22
  ## [2.0.0-alpha.53](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.52...@exodus/headless@2.0.0-alpha.53) (2023-06-23)
7
23
 
8
24
  **Note:** Version bump only for package @exodus/headless
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/headless",
3
- "version": "2.0.0-alpha.53",
3
+ "version": "2.0.0-alpha.55",
4
4
  "description": "The headless Exodus wallet SDK",
5
5
  "author": "Exodus Movement Inc",
6
6
  "main": "src/index.js",
@@ -17,7 +17,7 @@
17
17
  "src",
18
18
  "README.md",
19
19
  "CHANGELOG.md",
20
- "!**/__tests__",
20
+ "!**/__tests__/**",
21
21
  "!**/*.test.js"
22
22
  ],
23
23
  "scripts": {
@@ -53,7 +53,6 @@
53
53
  "@exodus/market-history": "^3.1.2",
54
54
  "@exodus/module": "^1.0.0",
55
55
  "@exodus/nfts": "^2.1.1",
56
- "@exodus/personal-notes": "^3.2.1",
57
56
  "@exodus/rates-monitor": "^2.0.1",
58
57
  "@exodus/top-movers-monitor": "^2.0.1",
59
58
  "@exodus/wallet": "^6.0.1",
@@ -73,6 +72,7 @@
73
72
  "@exodus/ethereum-lib": "^2.22.2",
74
73
  "@exodus/ethereum-meta": "^1.0.23",
75
74
  "@exodus/models": "^8.11.1",
75
+ "@exodus/personal-notes": "^3.3.0",
76
76
  "@exodus/referrals": "^6.0.2",
77
77
  "@exodus/solana-lib": "^1.3.11",
78
78
  "@exodus/solana-meta": "^1.0.2",
@@ -89,5 +89,5 @@
89
89
  "nock": "^13.3.1",
90
90
  "p-defer": "^4.0.0"
91
91
  },
92
- "gitHead": "5a250a30db9b904f02ca8a4d248fec08cfd57abc"
92
+ "gitHead": "74bde9d9f5bd441f35b7fe4d5b5098ed294dab44"
93
93
  }
@@ -165,7 +165,7 @@ class Application extends ExodusModule {
165
165
  if (forceRestart || walletExists) {
166
166
  await this.#storage.set(IMPORT_FLAG, true)
167
167
 
168
- this.emit('restart', { reason: 'import' })
168
+ await this.fire(Hook.Restart, { reason: 'import' })
169
169
  } else {
170
170
  await this.fire(Hook.Import)
171
171
 
@@ -253,7 +253,7 @@ class Application extends ExodusModule {
253
253
 
254
254
  delete = async () => {
255
255
  await this.#storage.set(DELETE_FLAG, true)
256
- this.emit('restart', { reason: 'delete' })
256
+ await this.fire(Hook.Restart, { reason: 'delete' })
257
257
  }
258
258
 
259
259
  changeLockTimer = async ({ ttl }) => {
package/src/constants.js CHANGED
@@ -25,6 +25,7 @@ export const LifecycleHook = Object.freeze({
25
25
  Import: 'import',
26
26
  Migrate: 'migrate',
27
27
  Start: 'start',
28
+ Restart: 'restart',
28
29
  Load: 'load',
29
30
  Unload: 'unload',
30
31
  Create: 'create',
package/src/index.js CHANGED
@@ -20,7 +20,6 @@ import kyc from './modules/kyc'
20
20
  import locale from './modules/locale'
21
21
  import marketHistory from './modules/market-history'
22
22
  import nfts from './modules/nfts'
23
- import personalNotes from './modules/personal-notes'
24
23
  import pricing from './modules/pricing'
25
24
  import rates from './modules/rates'
26
25
  import remoteConfig from './modules/remote-config'
@@ -52,7 +51,6 @@ const createExodus = ({ adapters, config, port }) => {
52
51
  ioc.use(kyc())
53
52
  ioc.use(connectedOrigins())
54
53
  ioc.use(abTesting())
55
- ioc.use(personalNotes())
56
54
  ioc.use(cryptoNews())
57
55
  ioc.use(topMovers({ config: topMoversMonitor }))
58
56
  ioc.use(addressProvider({ config: config.addressProvider }))
@@ -64,33 +62,51 @@ const createExodus = ({ adapters, config, port }) => {
64
62
 
65
63
  const { assetsModule, storage } = ioc.getByType('adapter')
66
64
 
67
- const { application, unlockEncryptedStorage } = ioc.getByType('module')
65
+ const { application, wallet, unlockEncryptedStorage } = ioc.getByType('module')
68
66
 
69
- application.hook('start', (payload) => {
70
- port.emit('start', payload)
67
+ application.hook('start', (payload) => port.emit('start', payload))
68
+
69
+ application.on('load', (args) => port.emit('load', args))
70
+
71
+ application.on('create', async ({ hasPassphraseSet }) => {
72
+ const isLocked = await wallet.isLocked()
73
+
74
+ port.emit('create', {
75
+ walletExists: true,
76
+ hasPassphraseSet,
77
+ isLocked,
78
+ isBackedUp: false,
79
+ isRestoring: false,
80
+ })
71
81
  })
72
82
 
83
+ application.on('unlock', () => port.emit('unlock'))
84
+
85
+ application.on('lock', () => port.emit('lock'))
86
+
87
+ application.on('backup', () => port.emit('backup'))
88
+
89
+ application.on('restore', () => port.emit('restore'))
90
+
91
+ application.on('restore-completed', () => port.emit('restore-completed'))
92
+
93
+ application.on('change-passphrase', () => port.emit('passphrase-changed'))
94
+
95
+ application.on('import', () => port.emit('import', { walletExists: true }))
96
+
73
97
  application.hook('unlock', async () => {
74
98
  if (typeof storage.unlock === 'function') unlockEncryptedStorage(storage)
75
99
 
76
100
  await assetsModule.load()
77
101
  })
78
102
 
79
- application.on('unlock', () => {
80
- port.emit('unlock')
81
- })
82
-
83
103
  application.hook('clear', async () => {
84
104
  await assetsModule.clear()
85
105
  })
86
106
 
87
- application.on('clear', () => {
88
- port.emit('clear')
89
- })
107
+ application.on('clear', () => port.emit('clear'))
90
108
 
91
- application.on('restart', (payload) => {
92
- port.emit('restart', payload)
93
- })
109
+ application.on('restart', (payload) => port.emit('restart', payload))
94
110
 
95
111
  attachAtoms({
96
112
  port,
@@ -9,6 +9,7 @@ const logLifecycle = {
9
9
  onImport: () => logger.debug('onImport'),
10
10
  onMigrate: () => logger.debug('onMigrate'),
11
11
  onStart: () => logger.debug('onStart'),
12
+ onRestart: () => logger.debug('onRestart'),
12
13
  onLoad: () => logger.debug('onLoad'),
13
14
  onUnload: () => logger.debug('onUnload'),
14
15
  onCreate: () => logger.debug('onCreate'),
@@ -1,12 +0,0 @@
1
- const createPersonalNotesApi = ({ personalNotes }) => ({
2
- personalNotes: {
3
- upsert: personalNotes.upsert,
4
- },
5
- })
6
-
7
- export default {
8
- id: 'createPersonalNotesApi',
9
- type: 'api',
10
- factory: createPersonalNotesApi,
11
- dependencies: ['personalNotes'],
12
- }
@@ -1,31 +0,0 @@
1
- import { personalNotesAtomDefinition } from '@exodus/personal-notes/atoms'
2
- import personalNotesDefinition from '@exodus/personal-notes/module'
3
-
4
- import personalNotesApiDefinition from './api'
5
- import personalNotesPluginDefinition from './plugin'
6
-
7
- // TODO: Add type to module definitions
8
- const personalNotes = () => {
9
- return {
10
- id: 'personalNotes',
11
- definitions: [
12
- {
13
- definition: { type: 'atom', ...personalNotesAtomDefinition },
14
- aliases: [
15
- {
16
- implementationId: 'personalNotesStorage',
17
- interfaceId: 'storage',
18
- },
19
- ],
20
- },
21
- {
22
- definition: { type: 'module', ...personalNotesDefinition },
23
- writesAtoms: ['personalNotesAtom'],
24
- },
25
- { definition: personalNotesPluginDefinition },
26
- { definition: personalNotesApiDefinition },
27
- ],
28
- }
29
- }
30
-
31
- export default personalNotes
@@ -1,15 +0,0 @@
1
- const personalNotesLifecyclePlugin = ({ personalNotes }) => {
2
- // TEMP: dont wait to clear as encrypted storage is not yet unlocked
3
- const onClear = () => {
4
- personalNotes.clear()
5
- }
6
-
7
- return { onClear }
8
- }
9
-
10
- export default {
11
- id: 'personalNotesLifecyclePlugin',
12
- type: 'plugin',
13
- factory: personalNotesLifecyclePlugin,
14
- dependencies: ['personalNotes'],
15
- }