@exodus/headless 2.0.0-alpha.44 → 2.0.0-alpha.45

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,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.45](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.44...@exodus/headless@2.0.0-alpha.45) (2023-06-18)
7
+
8
+ ### Features
9
+
10
+ - use(geolocation, marketHistory, topMovers, rates) ([#1992](https://github.com/ExodusMovement/exodus-hydra/issues/1992)) ([2e8d634](https://github.com/ExodusMovement/exodus-hydra/commit/2e8d63426421ffcbec84a9b6fbc83eb913b47eba))
11
+
6
12
  ## [2.0.0-alpha.44](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.43...@exodus/headless@2.0.0-alpha.44) (2023-06-18)
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.44",
3
+ "version": "2.0.0-alpha.45",
4
4
  "description": "The headless Exodus wallet SDK",
5
5
  "author": "Exodus Movement Inc",
6
6
  "main": "src/index.js",
@@ -88,5 +88,5 @@
88
88
  "nock": "^13.3.1",
89
89
  "p-defer": "^4.0.0"
90
90
  },
91
- "gitHead": "1116abf16d19461a0bd9154799613bd97d2a6cd9"
91
+ "gitHead": "af48f92eb9e4b7758b6f145181c4c45a24cf5b65"
92
92
  }
package/src/api.js CHANGED
@@ -8,7 +8,7 @@ const createApi = ({ ioc, port }) => {
8
8
  const { addressProvider, application, enabledAssets, remoteConfig, wallet } =
9
9
  ioc.getByType('module')
10
10
 
11
- const { feeMonitors, ratesMonitor, nftsMonitor } = ioc.getByType('monitor')
11
+ const { feeMonitors, nftsMonitor } = ioc.getByType('monitor')
12
12
 
13
13
  // TODO: decide where this belongs
14
14
  const { passphraseCache } = ioc.getAll()
@@ -53,9 +53,6 @@ const createApi = ({ ioc, port }) => {
53
53
  return asset.name
54
54
  },
55
55
  },
56
- rates: {
57
- refresh: () => ratesMonitor.update(),
58
- },
59
56
  addressProvider: {
60
57
  getAddress: addressProvider.getAddress.bind(addressProvider),
61
58
  getSupportedPurposes: addressProvider.getSupportedPurposes.bind(addressProvider),
@@ -11,9 +11,6 @@ import {
11
11
  enabledAssetsAtomDefinition,
12
12
  } from '@exodus/enabled-assets/atoms'
13
13
  import { featureFlagsAtomDefinition } from '@exodus/feature-flags/atoms'
14
- import { geolocationAtomDefinition } from '@exodus/geolocation/atoms'
15
- import { ratesAtomDefinition } from '@exodus/rates-monitor/atoms'
16
- import { topMoversAtomDefinition } from '@exodus/top-movers-monitor/atoms'
17
14
 
18
15
  import baseAssetNamesToMonitorAtomDefinition from '../atoms/base-asset-names-to-monitor'
19
16
  import nonDustBalanceAssetNamesAtomDefinition from '../atoms/non-dust-balance-asset-names-atom'
@@ -49,32 +46,6 @@ const createAtomDependencies = () =>
49
46
  dependencies: ['config', 'remoteConfig'],
50
47
  },
51
48
  },
52
- // TODO: move to @exodus/market-history
53
- {
54
- definition: {
55
- id: 'marketHistoryClearCacheAtom',
56
- factory: ({ config }) => createInMemoryAtom(config),
57
- dependencies: ['config'],
58
- },
59
- },
60
- // TODO: move to @exodus/market-history
61
- {
62
- definition: {
63
- id: 'remoteConfigClearMarketHistoryCacheAtom',
64
- factory: ({ config, remoteConfig }) =>
65
- createRemoteConfigAtomFactory({ remoteConfig })(config),
66
- dependencies: ['config', 'remoteConfig'],
67
- },
68
- },
69
- // TODO: move to @exodus/market-history
70
- {
71
- definition: {
72
- id: 'marketHistoryRefreshIntervalAtom',
73
- factory: ({ config, remoteConfig }) =>
74
- createRemoteConfigAtomFactory({ remoteConfig })(config),
75
- dependencies: ['config', 'remoteConfig'],
76
- },
77
- },
78
49
  {
79
50
  definition: {
80
51
  id: 'mockConfigAtom',
@@ -95,11 +66,8 @@ const createAtomDependencies = () =>
95
66
  ],
96
67
  },
97
68
  { definition: balancesAtomDefinition },
98
- { definition: ratesAtomDefinition },
99
- { definition: geolocationAtomDefinition },
100
69
  { definition: featureFlagsAtomDefinition },
101
70
  { definition: baseAssetNamesToMonitorAtomDefinition },
102
- { definition: topMoversAtomDefinition },
103
71
  { definition: restoreAtomDefinition },
104
72
  { definition: apyRatesAtomDefinition },
105
73
  ].map(withType('atom'))
@@ -1,52 +1,11 @@
1
1
  import apyRatesMonitorDefinition from '@exodus/apy-rates/monitor'
2
2
  import feeMonitorsDefinition from '@exodus/fee-monitors/monitor'
3
- import geolocationMonitorDefinition from '@exodus/geolocation/monitor'
4
- import marketHistoryMonitorDefinition from '@exodus/market-history/module'
5
- import ratesMonitorDefinition from '@exodus/rates-monitor/module'
6
- import localTopMoversMonitorDefinition from '@exodus/top-movers-monitor/monitor/local'
7
- import remoteTopMoversMonitorDefinition from '@exodus/top-movers-monitor/monitor/remote'
8
3
 
9
4
  import { withType } from './utils'
10
5
 
11
6
  const createMonitorDependencies = ({ config }) =>
12
7
  [
13
- {
14
- definition: geolocationMonitorDefinition,
15
- writesAtoms: ['geolocationAtom'],
16
- },
17
- {
18
- definition: marketHistoryMonitorDefinition,
19
- storage: { namespace: 'marketHistory' },
20
- aliases: [
21
- {
22
- implementationId: 'unsafeStorage',
23
- interfaceId: 'storage',
24
- },
25
- {
26
- implementationId: 'marketHistoryClearCacheAtom',
27
- interfaceId: 'clearCacheAtom',
28
- },
29
- {
30
- implementationId: 'remoteConfigClearMarketHistoryCacheAtom',
31
- interfaceId: 'remoteConfigClearCacheAtom',
32
- },
33
- {
34
- implementationId: 'marketHistoryRefreshIntervalAtom',
35
- interfaceId: 'remoteConfigRefreshIntervalAtom',
36
- },
37
- ],
38
- },
39
8
  { definition: feeMonitorsDefinition },
40
- {
41
- definition: ratesMonitorDefinition,
42
- writesAtoms: ['ratesAtom'],
43
- },
44
- {
45
- definition: config.topMoversMonitor.computeLocally
46
- ? localTopMoversMonitorDefinition
47
- : remoteTopMoversMonitorDefinition,
48
- writesAtoms: ['topMoversAtom'],
49
- },
50
9
  {
51
10
  definition: apyRatesMonitorDefinition,
52
11
  writesAtoms: ['apyRatesAtom'],
package/src/index.js CHANGED
@@ -8,22 +8,29 @@ import abTesting from './modules/ab-testing'
8
8
  import blockchainMetadata from './modules/blockchain-metadata'
9
9
  import connectedOrigins from './modules/connected-origins'
10
10
  import cryptoNews from './modules/crypto-news'
11
+ import geolocation from './modules/geolocation'
11
12
  import kyc from './modules/kyc'
12
13
  import locale from './modules/locale'
14
+ import marketHistory from './modules/market-history'
13
15
  import nfts from './modules/nfts'
14
16
  import personalNotes from './modules/personal-notes'
17
+ import rates from './modules/rates'
15
18
  import referrals from './modules/referrals'
16
19
  import remoteConfig from './modules/remote-config'
20
+ import topMovers from './modules/top-movers'
17
21
  import walletAccounts from './modules/wallet-accounts'
18
22
  import attachPlugins from './plugins/attach'
19
23
 
20
24
  const createExodus = ({ adapters, config, port }) => {
21
25
  const ioc = createIOC({ adapters, config })
22
- const { headless: headlessConfig } = config
26
+ const { headless: headlessConfig, topMoversMonitor } = config
23
27
 
24
28
  ioc.use(walletAccounts())
25
29
  ioc.use(blockchainMetadata())
26
30
  ioc.use(remoteConfig())
31
+ ioc.use(geolocation())
32
+ ioc.use(marketHistory())
33
+ ioc.use(rates())
27
34
  ioc.use(locale())
28
35
  ioc.use(nfts())
29
36
  ioc.use(kyc())
@@ -32,6 +39,7 @@ const createExodus = ({ adapters, config, port }) => {
32
39
  ioc.use(abTesting())
33
40
  ioc.use(personalNotes())
34
41
  ioc.use(cryptoNews())
42
+ ioc.use(topMovers({ config: topMoversMonitor }))
35
43
 
36
44
  ioc.register({ definition: { id: 'port', type: 'port', factory: () => port } })
37
45
 
@@ -43,32 +51,13 @@ const createExodus = ({ adapters, config, port }) => {
43
51
  const { application, enabledAssets, featureFlags, unlockEncryptedStorage } =
44
52
  ioc.getByType('module')
45
53
 
46
- const {
47
- apyRatesMonitor,
48
- feeMonitors,
49
- geolocationMonitor,
50
- marketHistory,
51
- ratesMonitor,
52
- topMoversMonitor,
53
- } = ioc.getByType('monitor')
54
-
55
- const { featureFlagAtoms } = ioc.getByType('atom-collection')
54
+ const { apyRatesMonitor, feeMonitors } = ioc.getByType('monitor')
56
55
 
57
56
  feeMonitors.on('fees-load', () => port.emit('fees-load', feeMonitors.getAllFeeData()))
58
57
  feeMonitors.on('fees-update', (payload) => port.emit('fees-update', payload))
59
58
 
60
- // TODO: migrate to marketHistoryAtom. Will be easier once it's on headless
61
- marketHistory.on('market-history', (payload) => port.emit('market-history', payload))
62
- marketHistory.on('market-history-new-assets', (payload) =>
63
- port.emit('market-history-new-assets', payload)
64
- )
65
-
66
- // TODO: migrate to ratesAtom. Will be easier once it's on headless
67
- ratesMonitor.on('rates', (payload) => port.emit('rates', payload))
68
-
69
59
  application.hook('start', (payload) => {
70
60
  featureFlags.load()
71
- geolocationMonitor.start()
72
61
 
73
62
  port.emit('start', payload)
74
63
  })
@@ -76,18 +65,11 @@ const createExodus = ({ adapters, config, port }) => {
76
65
  application.hook('unlock', async () => {
77
66
  if (typeof storage.unlock === 'function') unlockEncryptedStorage(storage)
78
67
 
79
- marketHistory.start()
80
- ratesMonitor.start()
81
68
  feeMonitors.start()
82
69
  apyRatesMonitor.start()
83
70
 
84
71
  await assetsModule.load()
85
72
  await enabledAssets.load()
86
-
87
- featureFlagAtoms.topMovers?.get().then(({ isOn }) => {
88
- if (!isOn) return
89
- topMoversMonitor.start()
90
- })
91
73
  })
92
74
 
93
75
  application.on('unlock', () => {
@@ -0,0 +1,20 @@
1
+ import { geolocationAtomDefinition } from '@exodus/geolocation/atoms'
2
+ import geolocationMonitorDefinition from '@exodus/geolocation/monitor'
3
+
4
+ import geolocationPluginDefinition from './plugin'
5
+
6
+ const geolocation = () => {
7
+ return {
8
+ id: 'geolocation',
9
+ definitions: [
10
+ { definition: geolocationAtomDefinition },
11
+ {
12
+ definition: geolocationMonitorDefinition,
13
+ writesAtoms: ['geolocationAtom'],
14
+ },
15
+ { definition: geolocationPluginDefinition },
16
+ ],
17
+ }
18
+ }
19
+
20
+ export default geolocation
@@ -0,0 +1,14 @@
1
+ const createGeolocationLifecyclePlugin = ({ geolocationMonitor }) => {
2
+ const onStart = async () => {
3
+ geolocationMonitor.start()
4
+ }
5
+
6
+ return { onStart }
7
+ }
8
+
9
+ export default {
10
+ id: 'geolocationLifecyclePlugin',
11
+ type: 'plugin',
12
+ factory: createGeolocationLifecyclePlugin,
13
+ dependencies: ['geolocationMonitor'],
14
+ }
@@ -0,0 +1,66 @@
1
+ import { createInMemoryAtom, createRemoteConfigAtomFactory } from '@exodus/atoms'
2
+ import marketHistoryMonitorDefinition from '@exodus/market-history/module'
3
+
4
+ import marketHistoryPluginDefinition from './plugin'
5
+
6
+ const marketHistory = () => {
7
+ return {
8
+ id: 'marketHistory',
9
+ definitions: [
10
+ {
11
+ definition: { type: 'monitor', ...marketHistoryMonitorDefinition },
12
+ storage: { namespace: 'marketHistory' },
13
+ aliases: [
14
+ {
15
+ implementationId: 'unsafeStorage',
16
+ interfaceId: 'storage',
17
+ },
18
+ {
19
+ implementationId: 'marketHistoryClearCacheAtom',
20
+ interfaceId: 'clearCacheAtom',
21
+ },
22
+ {
23
+ implementationId: 'remoteConfigClearMarketHistoryCacheAtom',
24
+ interfaceId: 'remoteConfigClearCacheAtom',
25
+ },
26
+ {
27
+ implementationId: 'marketHistoryRefreshIntervalAtom',
28
+ interfaceId: 'remoteConfigRefreshIntervalAtom',
29
+ },
30
+ ],
31
+ },
32
+ // TODO: move to @exodus/market-history
33
+ {
34
+ definition: {
35
+ id: 'marketHistoryClearCacheAtom',
36
+ type: 'atom',
37
+ factory: ({ config }) => createInMemoryAtom(config),
38
+ dependencies: ['config'],
39
+ },
40
+ },
41
+ // TODO: move to @exodus/market-history
42
+ {
43
+ definition: {
44
+ id: 'remoteConfigClearMarketHistoryCacheAtom',
45
+ type: 'atom',
46
+ factory: ({ config, remoteConfig }) =>
47
+ createRemoteConfigAtomFactory({ remoteConfig })(config),
48
+ dependencies: ['config', 'remoteConfig'],
49
+ },
50
+ },
51
+ // TODO: move to @exodus/market-history
52
+ {
53
+ definition: {
54
+ id: 'marketHistoryRefreshIntervalAtom',
55
+ type: 'atom',
56
+ factory: ({ config, remoteConfig }) =>
57
+ createRemoteConfigAtomFactory({ remoteConfig })(config),
58
+ dependencies: ['config', 'remoteConfig'],
59
+ },
60
+ },
61
+ { definition: marketHistoryPluginDefinition },
62
+ ],
63
+ }
64
+ }
65
+
66
+ export default marketHistory
@@ -0,0 +1,21 @@
1
+ const createMarketHistoryLifecyclePlugin = ({ marketHistory, port }) => {
2
+ // TODO: migrate to marketHistoryAtom. Will be easier once it's on headless
3
+ marketHistory.on('market-history', (payload) => port.emit('market-history', payload))
4
+
5
+ marketHistory.on('market-history-new-assets', (payload) =>
6
+ port.emit('market-history-new-assets', payload)
7
+ )
8
+
9
+ const onUnlock = () => {
10
+ marketHistory.start()
11
+ }
12
+
13
+ return { onUnlock }
14
+ }
15
+
16
+ export default {
17
+ id: 'marketHistoryLifecyclePlugin',
18
+ type: 'plugin',
19
+ factory: createMarketHistoryLifecyclePlugin,
20
+ dependencies: ['marketHistory', 'port'],
21
+ }
@@ -0,0 +1,12 @@
1
+ const ratesApi = ({ ratesMonitor }) => ({
2
+ rates: {
3
+ refresh: () => ratesMonitor.update(),
4
+ },
5
+ })
6
+
7
+ export default {
8
+ id: 'ratesApi',
9
+ type: 'api',
10
+ factory: ratesApi,
11
+ dependencies: ['ratesMonitor'],
12
+ }
@@ -0,0 +1,22 @@
1
+ import { ratesAtomDefinition } from '@exodus/rates-monitor/atoms'
2
+ import ratesMonitorDefinition from '@exodus/rates-monitor/module'
3
+
4
+ import ratesApi from './api'
5
+ import ratesPlugin from './plugin'
6
+
7
+ const rates = () => {
8
+ return {
9
+ id: 'rates',
10
+ definitions: [
11
+ { definition: { type: 'atom', ...ratesAtomDefinition } },
12
+ {
13
+ definition: { type: 'monitor', ...ratesMonitorDefinition },
14
+ writesAtoms: ['ratesAtom'],
15
+ },
16
+ { definition: ratesPlugin },
17
+ { definition: ratesApi },
18
+ ],
19
+ }
20
+ }
21
+
22
+ export default rates
@@ -0,0 +1,17 @@
1
+ const createRatesLifecyclePlugin = ({ ratesMonitor, port }) => {
2
+ // TODO: migrate to ratesAtom. Will be easier once it's on headless
3
+ ratesMonitor.on('rates', (payload) => port.emit('rates', payload))
4
+
5
+ const onUnlock = () => {
6
+ ratesMonitor.start()
7
+ }
8
+
9
+ return { onUnlock }
10
+ }
11
+
12
+ export default {
13
+ id: 'ratesLifecyclePlugin',
14
+ type: 'plugin',
15
+ factory: createRatesLifecyclePlugin,
16
+ dependencies: ['ratesMonitor', 'port'],
17
+ }
@@ -0,0 +1,23 @@
1
+ import { topMoversAtomDefinition } from '@exodus/top-movers-monitor/atoms'
2
+ import localTopMoversMonitorDefinition from '@exodus/top-movers-monitor/monitor/local'
3
+ import remoteTopMoversMonitorDefinition from '@exodus/top-movers-monitor/monitor/remote'
4
+
5
+ import topMoversPlugin from './plugin'
6
+
7
+ const topMovers = ({ config }) => {
8
+ return {
9
+ id: 'topMovers',
10
+ definitions: [
11
+ { definition: topMoversAtomDefinition },
12
+ {
13
+ definition: config.computeLocally
14
+ ? localTopMoversMonitorDefinition
15
+ : remoteTopMoversMonitorDefinition,
16
+ writesAtoms: ['topMoversAtom'],
17
+ },
18
+ { definition: topMoversPlugin },
19
+ ],
20
+ }
21
+ }
22
+
23
+ export default topMovers
@@ -0,0 +1,17 @@
1
+ const createTopMoversLifecyclePlugin = ({ topMoversMonitor, featureFlagAtoms }) => {
2
+ const onUnlock = () => {
3
+ featureFlagAtoms.topMovers?.get().then(({ isOn }) => {
4
+ if (!isOn) return
5
+ topMoversMonitor.start()
6
+ })
7
+ }
8
+
9
+ return { onUnlock }
10
+ }
11
+
12
+ export default {
13
+ id: 'topMoversLifecyclePlugin',
14
+ type: 'plugin',
15
+ factory: createTopMoversLifecyclePlugin,
16
+ dependencies: ['topMoversMonitor', 'featureFlagAtoms'],
17
+ }