@exodus/headless 2.0.0-alpha.49 → 2.0.0-alpha.50
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 +12 -0
- package/package.json +7 -7
- package/src/api.js +1 -14
- package/src/dependencies/atoms.js +1 -21
- package/src/dependencies/modules.js +0 -10
- package/src/index.js +6 -7
- package/src/modules/enabled-assets/api.js +18 -0
- package/src/modules/enabled-assets/index.js +26 -0
- package/src/modules/enabled-assets/plugin.js +18 -0
- package/src/modules/feature-flags/api.js +14 -0
- package/src/modules/feature-flags/index.js +4 -2
- package/src/modules/pricing/api.js +14 -0
- package/src/modules/pricing/index.js +35 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
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.50](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.49...@exodus/headless@2.0.0-alpha.50) (2023-06-21)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **headless:** export features api ([#2051](https://github.com/ExodusMovement/exodus-hydra/issues/2051)) ([71bfc37](https://github.com/ExodusMovement/exodus-hydra/commit/71bfc37d70484d90c99170ab9da406c8be02389b))
|
|
11
|
+
- **headless:** use(enabledAssets) ([#2047](https://github.com/ExodusMovement/exodus-hydra/issues/2047)) ([c2c7572](https://github.com/ExodusMovement/exodus-hydra/commit/c2c7572d290e908b2c84a5558e59f02f4182e3ae))
|
|
12
|
+
- **headless:** use(pricing) ([#2050](https://github.com/ExodusMovement/exodus-hydra/issues/2050)) ([1db7c9d](https://github.com/ExodusMovement/exodus-hydra/commit/1db7c9df72300f49a09e848c69747202f03c39ae))
|
|
13
|
+
|
|
14
|
+
### Performance Improvements
|
|
15
|
+
|
|
16
|
+
- prevent writing same value to atoms ([#2078](https://github.com/ExodusMovement/exodus-hydra/issues/2078)) ([bd901b4](https://github.com/ExodusMovement/exodus-hydra/commit/bd901b40a10c8983f2fe6fbb10c9dc8a81ccbd60))
|
|
17
|
+
|
|
6
18
|
## [2.0.0-alpha.49](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.48...@exodus/headless@2.0.0-alpha.49) (2023-06-21)
|
|
7
19
|
|
|
8
20
|
### ⚠ BREAKING CHANGES
|
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.50",
|
|
4
4
|
"description": "The headless Exodus wallet SDK",
|
|
5
5
|
"author": "Exodus Movement Inc",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -26,23 +26,23 @@
|
|
|
26
26
|
"test": "jest --runInBand"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@exodus/ab-testing": "^5.1.
|
|
29
|
+
"@exodus/ab-testing": "^5.1.2",
|
|
30
30
|
"@exodus/address-provider": "^4.1.1",
|
|
31
31
|
"@exodus/apy-rates": "^2.1.1",
|
|
32
|
-
"@exodus/atoms": "^5.
|
|
32
|
+
"@exodus/atoms": "^5.1.0",
|
|
33
33
|
"@exodus/auto-enable-assets-plugin": "^4.0.1",
|
|
34
34
|
"@exodus/available-assets": "^2.0.2",
|
|
35
35
|
"@exodus/balances": "^6.0.1",
|
|
36
36
|
"@exodus/basic-utils": "^2.0.0",
|
|
37
37
|
"@exodus/blockchain-metadata": "^8.0.1",
|
|
38
38
|
"@exodus/config": "^7.0.0",
|
|
39
|
-
"@exodus/connected-origins": "^1.1.
|
|
39
|
+
"@exodus/connected-origins": "^1.1.3",
|
|
40
40
|
"@exodus/crypto-news-monitor": "^2.0.0",
|
|
41
41
|
"@exodus/dependency-injection": "^2.0.0",
|
|
42
42
|
"@exodus/dependency-preprocessors": "^2.8.1",
|
|
43
43
|
"@exodus/enabled-assets": "^6.0.2",
|
|
44
44
|
"@exodus/exodus-pricing-client": "^1.2.0",
|
|
45
|
-
"@exodus/feature-flags": "^2.1.
|
|
45
|
+
"@exodus/feature-flags": "^2.1.2",
|
|
46
46
|
"@exodus/fee-monitors": "^1.0.0",
|
|
47
47
|
"@exodus/fetch": "^1.2.1",
|
|
48
48
|
"@exodus/fusion": "^6.0.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@exodus/kyc": "^3.5.1",
|
|
53
53
|
"@exodus/market-history": "^3.1.2",
|
|
54
54
|
"@exodus/module": "^1.0.0",
|
|
55
|
-
"@exodus/nfts": "^2.1.
|
|
55
|
+
"@exodus/nfts": "^2.1.1",
|
|
56
56
|
"@exodus/personal-notes": "^3.2.1",
|
|
57
57
|
"@exodus/rates-monitor": "^2.0.1",
|
|
58
58
|
"@exodus/referrals": "^6.0.1",
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"nock": "^13.3.1",
|
|
90
90
|
"p-defer": "^4.0.0"
|
|
91
91
|
},
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "99176e5d6e7a9e0d01ee9dd28d4c1aa364cfc1b4"
|
|
93
93
|
}
|
package/src/api.js
CHANGED
|
@@ -2,11 +2,7 @@ import { validateMnemonic as isMnemonicValid } from 'bip39'
|
|
|
2
2
|
|
|
3
3
|
const createApi = ({ ioc, port }) => {
|
|
4
4
|
const apis = ioc.getByType('api')
|
|
5
|
-
|
|
6
|
-
const { assetsModule } = ioc.getByType('adapter')
|
|
7
|
-
|
|
8
|
-
const { enabledAssets, remoteConfig } = ioc.getByType('module')
|
|
9
|
-
|
|
5
|
+
const { remoteConfig } = ioc.getByType('module')
|
|
10
6
|
const { feeMonitors, nftsMonitor } = ioc.getByType('monitor')
|
|
11
7
|
|
|
12
8
|
// TODO: do this on 'unload'
|
|
@@ -18,15 +14,6 @@ const createApi = ({ ioc, port }) => {
|
|
|
18
14
|
|
|
19
15
|
return {
|
|
20
16
|
...Object.assign({}, ...Object.values(apis)),
|
|
21
|
-
assets: {
|
|
22
|
-
enable: enabledAssets.enable,
|
|
23
|
-
disable: enabledAssets.disable,
|
|
24
|
-
addAndEnableToken: async (...args) => {
|
|
25
|
-
const asset = await assetsModule.addToken(...args)
|
|
26
|
-
await enabledAssets.enable([asset.name])
|
|
27
|
-
return asset.name
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
17
|
isMnemonicValid,
|
|
31
18
|
subscribe: port.subscribe.bind(port),
|
|
32
19
|
unsubscribe: port.unsubscribe.bind(port),
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createStorageAtomFactory } from '@exodus/atoms'
|
|
2
2
|
import { availableAssetNamesAtomDefinition } from '@exodus/available-assets/atoms'
|
|
3
3
|
import { balancesAtomDefinition } from '@exodus/balances/atoms'
|
|
4
|
-
import {
|
|
5
|
-
enabledAndDisabledAssetsAtomDefinition,
|
|
6
|
-
enabledAssetsAtomDefinition,
|
|
7
|
-
} from '@exodus/enabled-assets/atoms'
|
|
8
4
|
|
|
9
5
|
import baseAssetNamesToMonitorAtomDefinition from '../atoms/base-asset-names-to-monitor'
|
|
10
6
|
import nonDustBalanceAssetNamesAtomDefinition from '../atoms/non-dust-balance-asset-names-atom'
|
|
@@ -12,26 +8,10 @@ import { withType } from './utils'
|
|
|
12
8
|
|
|
13
9
|
const createAtomDependencies = () =>
|
|
14
10
|
[
|
|
15
|
-
{
|
|
16
|
-
definition: enabledAndDisabledAssetsAtomDefinition,
|
|
17
|
-
storage: { namespace: 'enabledAssets' },
|
|
18
|
-
},
|
|
19
|
-
{ definition: enabledAssetsAtomDefinition },
|
|
20
11
|
{ definition: availableAssetNamesAtomDefinition },
|
|
21
12
|
{
|
|
22
13
|
definition: nonDustBalanceAssetNamesAtomDefinition,
|
|
23
14
|
},
|
|
24
|
-
{
|
|
25
|
-
definition: {
|
|
26
|
-
id: 'pricingServerUrlAtom',
|
|
27
|
-
factory: ({ config, remoteConfig }) =>
|
|
28
|
-
createRemoteConfigAtomFactory({ remoteConfig })({
|
|
29
|
-
path: config.pricingServerPath,
|
|
30
|
-
defaultValue: config.defaultPricingServerUrl,
|
|
31
|
-
}),
|
|
32
|
-
dependencies: ['config', 'remoteConfig'],
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
15
|
{
|
|
36
16
|
definition: {
|
|
37
17
|
id: 'mockConfigAtom',
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import availableAssetsModuleDefinition from '@exodus/available-assets/module'
|
|
2
2
|
import balancesDefinition from '@exodus/balances/module'
|
|
3
|
-
import enabledAssetsModuleDefinition from '@exodus/enabled-assets/module'
|
|
4
|
-
import createExodusPricingClient from '@exodus/exodus-pricing-client'
|
|
5
3
|
import createKeyIdentifierProvider from '@exodus/key-identifier-provider'
|
|
6
4
|
import keychainDefinition from '@exodus/keychain/module'
|
|
7
5
|
import walletCompatibilityModesDefinition from '@exodus/wallet-compatibility-modes/module'
|
|
@@ -33,15 +31,7 @@ const createModuleDependencies = ({ config }) =>
|
|
|
33
31
|
definition: walletCompatibilityModesDefinition,
|
|
34
32
|
},
|
|
35
33
|
{ definition: unlockEncryptedStorageDefinition },
|
|
36
|
-
{ definition: enabledAssetsModuleDefinition, writesAtoms: ['enabledAndDisabledAssetsAtom'] },
|
|
37
34
|
{ definition: availableAssetsModuleDefinition, writesAtoms: ['availableAssetNamesAtom'] },
|
|
38
|
-
{
|
|
39
|
-
definition: {
|
|
40
|
-
id: 'pricingClient',
|
|
41
|
-
factory: createExodusPricingClient,
|
|
42
|
-
dependencies: ['fetch', 'pricingServerUrlAtom'],
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
35
|
{ definition: balancesDefinition, writesAtoms: ['balancesAtom'] },
|
|
46
36
|
].map(withType('module'))
|
|
47
37
|
|
package/src/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import apyRates from './modules/apy-rates'
|
|
|
10
10
|
import blockchainMetadata from './modules/blockchain-metadata'
|
|
11
11
|
import connectedOrigins from './modules/connected-origins'
|
|
12
12
|
import cryptoNews from './modules/crypto-news'
|
|
13
|
+
import enabledAssets from './modules/enabled-assets'
|
|
13
14
|
import featureFlags from './modules/feature-flags'
|
|
14
15
|
import fees from './modules/fees'
|
|
15
16
|
import geolocation from './modules/geolocation'
|
|
@@ -18,6 +19,7 @@ import locale from './modules/locale'
|
|
|
18
19
|
import marketHistory from './modules/market-history'
|
|
19
20
|
import nfts from './modules/nfts'
|
|
20
21
|
import personalNotes from './modules/personal-notes'
|
|
22
|
+
import pricing from './modules/pricing'
|
|
21
23
|
import rates from './modules/rates'
|
|
22
24
|
import referrals from './modules/referrals'
|
|
23
25
|
import remoteConfig from './modules/remote-config'
|
|
@@ -33,9 +35,11 @@ const createExodus = ({ adapters, config, port }) => {
|
|
|
33
35
|
ioc.use(wallet())
|
|
34
36
|
ioc.use(walletAccounts())
|
|
35
37
|
ioc.use(blockchainMetadata())
|
|
38
|
+
ioc.use(enabledAssets())
|
|
36
39
|
ioc.use(remoteConfig())
|
|
37
40
|
ioc.use(geolocation())
|
|
38
41
|
ioc.use(marketHistory())
|
|
42
|
+
ioc.use(pricing())
|
|
39
43
|
ioc.use(fees())
|
|
40
44
|
ioc.use(rates())
|
|
41
45
|
ioc.use(apyRates())
|
|
@@ -58,7 +62,7 @@ const createExodus = ({ adapters, config, port }) => {
|
|
|
58
62
|
|
|
59
63
|
const { assetsModule, storage } = ioc.getByType('adapter')
|
|
60
64
|
|
|
61
|
-
const { application,
|
|
65
|
+
const { application, unlockEncryptedStorage } = ioc.getByType('module')
|
|
62
66
|
|
|
63
67
|
application.hook('start', (payload) => {
|
|
64
68
|
port.emit('start', payload)
|
|
@@ -68,7 +72,6 @@ const createExodus = ({ adapters, config, port }) => {
|
|
|
68
72
|
if (typeof storage.unlock === 'function') unlockEncryptedStorage(storage)
|
|
69
73
|
|
|
70
74
|
await assetsModule.load()
|
|
71
|
-
await enabledAssets.load()
|
|
72
75
|
})
|
|
73
76
|
|
|
74
77
|
application.on('unlock', () => {
|
|
@@ -76,11 +79,7 @@ const createExodus = ({ adapters, config, port }) => {
|
|
|
76
79
|
})
|
|
77
80
|
|
|
78
81
|
application.hook('clear', async () => {
|
|
79
|
-
await
|
|
80
|
-
//
|
|
81
|
-
assetsModule.clear(),
|
|
82
|
-
enabledAssets.clear(),
|
|
83
|
-
])
|
|
82
|
+
await assetsModule.clear()
|
|
84
83
|
})
|
|
85
84
|
|
|
86
85
|
application.on('clear', () => {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const enabledAssetsApi = ({ enabledAssets, assetsModule }) => ({
|
|
2
|
+
assets: {
|
|
3
|
+
enable: enabledAssets.enable,
|
|
4
|
+
disable: enabledAssets.disable,
|
|
5
|
+
addAndEnableToken: async (...args) => {
|
|
6
|
+
const asset = await assetsModule.addToken(...args)
|
|
7
|
+
await enabledAssets.enable([asset.name])
|
|
8
|
+
return asset.name
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
id: 'enabledAssetsApi',
|
|
15
|
+
type: 'api',
|
|
16
|
+
factory: enabledAssetsApi,
|
|
17
|
+
dependencies: ['enabledAssets', 'assetsModule'],
|
|
18
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
enabledAndDisabledAssetsAtomDefinition,
|
|
3
|
+
enabledAssetsAtomDefinition,
|
|
4
|
+
} from '@exodus/enabled-assets/atoms'
|
|
5
|
+
import enabledAssetsModuleDefinition from '@exodus/enabled-assets/module'
|
|
6
|
+
|
|
7
|
+
import enabledAssetsApiDefinition from './api'
|
|
8
|
+
import enabledAssetsPluginDefinition from './plugin'
|
|
9
|
+
|
|
10
|
+
const enabledAssets = () => {
|
|
11
|
+
return {
|
|
12
|
+
id: 'enabledAssets',
|
|
13
|
+
definitions: [
|
|
14
|
+
{ definition: enabledAssetsModuleDefinition, writesAtoms: ['enabledAndDisabledAssetsAtom'] },
|
|
15
|
+
{
|
|
16
|
+
definition: enabledAndDisabledAssetsAtomDefinition,
|
|
17
|
+
storage: { namespace: 'enabledAssets' },
|
|
18
|
+
},
|
|
19
|
+
{ definition: enabledAssetsAtomDefinition },
|
|
20
|
+
{ definition: enabledAssetsPluginDefinition },
|
|
21
|
+
{ definition: enabledAssetsApiDefinition },
|
|
22
|
+
],
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default enabledAssets
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const createEnabledAssetsLifecyclePlugin = ({ enabledAssets }) => {
|
|
2
|
+
const onUnlock = async () => {
|
|
3
|
+
await enabledAssets.load()
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
const onClear = async () => {
|
|
7
|
+
await enabledAssets.clear()
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return { onUnlock, onClear }
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
id: 'enabledAssetsLifecyclePlugin',
|
|
15
|
+
type: 'plugin',
|
|
16
|
+
factory: createEnabledAssetsLifecyclePlugin,
|
|
17
|
+
dependencies: ['enabledAssets'],
|
|
18
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const featureFlagsApi = ({ featureFlagAtoms }) => ({
|
|
2
|
+
features: {
|
|
3
|
+
set: (feature, value) => featureFlagAtoms[feature]?.set({ isOn: value }),
|
|
4
|
+
enable: (feature) => featureFlagAtoms[feature]?.set({ isOn: true }),
|
|
5
|
+
disable: (feature) => featureFlagAtoms[feature]?.set({ isOn: false }),
|
|
6
|
+
},
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
id: 'featureFlagsApi',
|
|
11
|
+
type: 'api',
|
|
12
|
+
factory: featureFlagsApi,
|
|
13
|
+
dependencies: ['featureFlagAtoms'],
|
|
14
|
+
}
|
|
@@ -5,7 +5,8 @@ import {
|
|
|
5
5
|
} from '@exodus/feature-flags/atoms'
|
|
6
6
|
import featureFlagsDefinition from '@exodus/feature-flags/module'
|
|
7
7
|
|
|
8
|
-
import
|
|
8
|
+
import featureFlagsApiDefinition from './api'
|
|
9
|
+
import featureFlagsPluginDefinition from './plugin'
|
|
9
10
|
|
|
10
11
|
const featureFlags = () => {
|
|
11
12
|
return {
|
|
@@ -27,7 +28,8 @@ const featureFlags = () => {
|
|
|
27
28
|
},
|
|
28
29
|
{ definition: featureFlagsAtomDefinition },
|
|
29
30
|
{ definition: remoteConfigFeatureFlagAtomsDefinition },
|
|
30
|
-
{ definition:
|
|
31
|
+
{ definition: featureFlagsPluginDefinition },
|
|
32
|
+
{ definition: featureFlagsApiDefinition },
|
|
31
33
|
],
|
|
32
34
|
}
|
|
33
35
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const pricingApi = ({ pricingClient }) => ({
|
|
2
|
+
pricing: {
|
|
3
|
+
currentPrice: pricingClient.currentPrice,
|
|
4
|
+
historicalPrice: pricingClient.historicalPrice,
|
|
5
|
+
ticker: pricingClient.ticker,
|
|
6
|
+
},
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
id: 'pricingApi',
|
|
11
|
+
type: 'api',
|
|
12
|
+
factory: pricingApi,
|
|
13
|
+
dependencies: ['pricingClient'],
|
|
14
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createRemoteConfigAtomFactory } from '@exodus/atoms'
|
|
2
|
+
import createExodusPricingClient from '@exodus/exodus-pricing-client'
|
|
3
|
+
|
|
4
|
+
import pricingApi from './api'
|
|
5
|
+
|
|
6
|
+
const pricing = () => {
|
|
7
|
+
return {
|
|
8
|
+
id: 'pricing',
|
|
9
|
+
definitions: [
|
|
10
|
+
{
|
|
11
|
+
definition: {
|
|
12
|
+
id: 'pricingClient',
|
|
13
|
+
type: 'module',
|
|
14
|
+
factory: createExodusPricingClient,
|
|
15
|
+
dependencies: ['fetch', 'pricingServerUrlAtom'],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
definition: {
|
|
20
|
+
id: 'pricingServerUrlAtom',
|
|
21
|
+
type: 'atom',
|
|
22
|
+
factory: ({ config, remoteConfig }) =>
|
|
23
|
+
createRemoteConfigAtomFactory({ remoteConfig })({
|
|
24
|
+
path: config.pricingServerPath,
|
|
25
|
+
defaultValue: config.defaultPricingServerUrl,
|
|
26
|
+
}),
|
|
27
|
+
dependencies: ['config', 'remoteConfig'],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{ definition: pricingApi },
|
|
31
|
+
],
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default pricing
|