@exodus/headless 2.0.0-alpha.29 → 2.0.0-alpha.30
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 +6 -0
- package/package.json +2 -2
- package/src/application.js +15 -1
- package/src/atoms/base-asset-names-to-monitor.js +26 -11
- package/src/atoms/restore.js +10 -0
- package/src/dependencies/atoms.js +2 -0
- package/src/index.js +2 -2
- package/src/plugins/index.js +2 -1
- package/src/plugins/restore.js +16 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
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.30](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.29...@exodus/headless@2.0.0-alpha.30) (2023-06-01)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- port base asset names to monitor atom changes to headless ([#1756](https://github.com/ExodusMovement/exodus-hydra/issues/1756)) ([edebc00](https://github.com/ExodusMovement/exodus-hydra/commit/edebc00f7264b7450cc18919b472c33b1f180797))
|
|
11
|
+
|
|
6
12
|
## [2.0.0-alpha.29](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.28...@exodus/headless@2.0.0-alpha.29) (2023-06-01)
|
|
7
13
|
|
|
8
14
|
### Features
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/headless",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.30",
|
|
4
4
|
"description": "The headless Exodus wallet SDK",
|
|
5
5
|
"author": "Exodus Movement Inc",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"nock": "^13.3.1",
|
|
84
84
|
"p-defer": "^4.0.0"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "d2f34916f4466f83b89a06d52d14a7baf3178a34"
|
|
87
87
|
}
|
package/src/application.js
CHANGED
|
@@ -76,7 +76,21 @@ class Application extends ExodusModule {
|
|
|
76
76
|
|
|
77
77
|
if (isImporting) await this.fire(Hook.Import)
|
|
78
78
|
|
|
79
|
-
await
|
|
79
|
+
const [hasPassphraseSet, isLocked, isBackedUp, isRestoring] = await Promise.all([
|
|
80
|
+
this.#wallet.hasPassphraseSet(),
|
|
81
|
+
this.#wallet.isLocked(),
|
|
82
|
+
this.#wallet.isBackedUp(),
|
|
83
|
+
this.isRestoring(),
|
|
84
|
+
])
|
|
85
|
+
|
|
86
|
+
await this.fire(Hook.Start, {
|
|
87
|
+
walletExists,
|
|
88
|
+
hasPassphraseSet,
|
|
89
|
+
isLocked,
|
|
90
|
+
isBackedUp,
|
|
91
|
+
isRestoring,
|
|
92
|
+
})
|
|
93
|
+
|
|
80
94
|
await this.#autoUnlock()
|
|
81
95
|
|
|
82
96
|
const locked = await this.#wallet.isLocked()
|
|
@@ -1,21 +1,36 @@
|
|
|
1
|
-
import { compute } from '@exodus/atoms'
|
|
1
|
+
import { combine, compute } from '@exodus/atoms'
|
|
2
2
|
import { uniq } from 'lodash'
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const getNetworks = (assetNames, assets) =>
|
|
5
|
+
uniq(
|
|
6
|
+
assetNames
|
|
7
|
+
.map((assetName) => assets[assetName]?.baseAsset.name)
|
|
8
|
+
.filter((assetName) => !!assetName && !assets[assetName].isCombined)
|
|
9
9
|
)
|
|
10
|
-
}
|
|
11
10
|
|
|
12
|
-
const createBaseAssetNamesToMonitorAtom = ({
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
const createBaseAssetNamesToMonitorAtom = ({
|
|
12
|
+
assetsModule,
|
|
13
|
+
enabledAssetsAtom,
|
|
14
|
+
restoreAtom,
|
|
15
|
+
availableAssetNamesAtom,
|
|
16
|
+
}) => {
|
|
17
|
+
const selector = ({ isRestore, enabledAssets, availableAssetNames }) => {
|
|
18
|
+
const assetNames = isRestore ? availableAssetNames : Object.keys(enabledAssets)
|
|
19
|
+
return getNetworks(assetNames, assetsModule.getAssets())
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return compute({
|
|
23
|
+
atom: combine({
|
|
24
|
+
isRestore: restoreAtom,
|
|
25
|
+
enabledAssets: enabledAssetsAtom,
|
|
26
|
+
availableAssetNames: availableAssetNamesAtom,
|
|
27
|
+
}),
|
|
28
|
+
selector,
|
|
29
|
+
})
|
|
15
30
|
}
|
|
16
31
|
|
|
17
32
|
export default {
|
|
18
33
|
id: 'baseAssetNamesToMonitorAtom',
|
|
19
34
|
factory: createBaseAssetNamesToMonitorAtom,
|
|
20
|
-
dependencies: ['assetsModule', 'enabledAssetsAtom'],
|
|
35
|
+
dependencies: ['assetsModule', 'availableAssetNamesAtom', 'enabledAssetsAtom', 'restoreAtom'],
|
|
21
36
|
}
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
} from '@exodus/wallet-accounts/atoms'
|
|
26
26
|
|
|
27
27
|
import baseAssetNamesToMonitorAtomDefinition from '../atoms/base-asset-names-to-monitor'
|
|
28
|
+
import restoreAtomDefinition from '../atoms/restore'
|
|
28
29
|
import { withType } from './utils'
|
|
29
30
|
|
|
30
31
|
const createAtomDependencies = () =>
|
|
@@ -161,6 +162,7 @@ const createAtomDependencies = () =>
|
|
|
161
162
|
{ definition: baseAssetNamesToMonitorAtomDefinition },
|
|
162
163
|
{ definition: topMoversAtomDefinition },
|
|
163
164
|
{ definition: cryptoNewsAtomDefinition },
|
|
165
|
+
{ definition: restoreAtomDefinition },
|
|
164
166
|
].map(withType('atom'))
|
|
165
167
|
|
|
166
168
|
export default createAtomDependencies
|
package/src/index.js
CHANGED
|
@@ -68,12 +68,12 @@ const createExodus = ({ adapters, config, port }) => {
|
|
|
68
68
|
// TODO: migrate to ratesAtom. Will be easier once it's on headless
|
|
69
69
|
ratesMonitor.on('rates', (payload) => port.emit('rates', payload))
|
|
70
70
|
|
|
71
|
-
application.hook('start', () => {
|
|
71
|
+
application.hook('start', (payload) => {
|
|
72
72
|
remoteConfig.load()
|
|
73
73
|
featureFlags.load()
|
|
74
74
|
geolocationMonitor.start()
|
|
75
75
|
|
|
76
|
-
port.emit('start')
|
|
76
|
+
port.emit('start', payload)
|
|
77
77
|
})
|
|
78
78
|
|
|
79
79
|
application.hook('unlock', async () => {
|
package/src/plugins/index.js
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const restorePlugin = ({ restoreAtom }) => {
|
|
2
|
+
return {
|
|
3
|
+
onStart: async ({ isRestoring }) => {
|
|
4
|
+
await restoreAtom.set(!!isRestoring)
|
|
5
|
+
},
|
|
6
|
+
onAssetsSynced: async () => {
|
|
7
|
+
await restoreAtom.set(false)
|
|
8
|
+
},
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
id: 'restorePlugin',
|
|
14
|
+
factory: restorePlugin,
|
|
15
|
+
dependencies: ['restoreAtom'],
|
|
16
|
+
}
|