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

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,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.46](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.45...@exodus/headless@2.0.0-alpha.46) (2023-06-18)
7
+
8
+ ### Features
9
+
10
+ - use(featureFlags, apyRates, fees, addressProvider) ([#1993](https://github.com/ExodusMovement/exodus-hydra/issues/1993)) ([5aba49b](https://github.com/ExodusMovement/exodus-hydra/commit/5aba49bbea24f229900966c0abde5eb8932ac861))
11
+
12
+ ## [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)
13
+
14
+ ### Features
15
+
16
+ - use(geolocation, marketHistory, topMovers, rates) ([#1992](https://github.com/ExodusMovement/exodus-hydra/issues/1992)) ([2e8d634](https://github.com/ExodusMovement/exodus-hydra/commit/2e8d63426421ffcbec84a9b6fbc83eb913b47eba))
17
+
6
18
  ## [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
19
 
8
20
  ### 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.46",
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": "9946e9d678eb80b4cb7de96fb76c804ae5e31fc9"
92
92
  }
package/src/api.js CHANGED
@@ -5,10 +5,9 @@ const createApi = ({ ioc, port }) => {
5
5
 
6
6
  const { assetsModule } = ioc.getByType('adapter')
7
7
 
8
- const { addressProvider, application, enabledAssets, remoteConfig, wallet } =
9
- ioc.getByType('module')
8
+ const { application, enabledAssets, remoteConfig, wallet } = ioc.getByType('module')
10
9
 
11
- const { feeMonitors, ratesMonitor, nftsMonitor } = ioc.getByType('monitor')
10
+ const { feeMonitors, nftsMonitor } = ioc.getByType('monitor')
12
11
 
13
12
  // TODO: decide where this belongs
14
13
  const { passphraseCache } = ioc.getAll()
@@ -53,14 +52,6 @@ const createApi = ({ ioc, port }) => {
53
52
  return asset.name
54
53
  },
55
54
  },
56
- rates: {
57
- refresh: () => ratesMonitor.update(),
58
- },
59
- addressProvider: {
60
- getAddress: addressProvider.getAddress.bind(addressProvider),
61
- getSupportedPurposes: addressProvider.getSupportedPurposes.bind(addressProvider),
62
- getReceiveAddress: addressProvider.getReceiveAddress.bind(addressProvider),
63
- },
64
55
  isMnemonicValid,
65
56
  subscribe: port.subscribe.bind(port),
66
57
  unsubscribe: port.unsubscribe.bind(port),
@@ -1,4 +1,3 @@
1
- import { apyRatesAtomDefinition } from '@exodus/apy-rates/atoms'
2
1
  import {
3
2
  createInMemoryAtom,
4
3
  createRemoteConfigAtomFactory,
@@ -10,10 +9,6 @@ import {
10
9
  enabledAndDisabledAssetsAtomDefinition,
11
10
  enabledAssetsAtomDefinition,
12
11
  } from '@exodus/enabled-assets/atoms'
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
12
 
18
13
  import baseAssetNamesToMonitorAtomDefinition from '../atoms/base-asset-names-to-monitor'
19
14
  import nonDustBalanceAssetNamesAtomDefinition from '../atoms/non-dust-balance-asset-names-atom'
@@ -49,32 +44,6 @@ const createAtomDependencies = () =>
49
44
  dependencies: ['config', 'remoteConfig'],
50
45
  },
51
46
  },
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
47
  {
79
48
  definition: {
80
49
  id: 'mockConfigAtom',
@@ -95,13 +64,8 @@ const createAtomDependencies = () =>
95
64
  ],
96
65
  },
97
66
  { definition: balancesAtomDefinition },
98
- { definition: ratesAtomDefinition },
99
- { definition: geolocationAtomDefinition },
100
- { definition: featureFlagsAtomDefinition },
101
67
  { definition: baseAssetNamesToMonitorAtomDefinition },
102
- { definition: topMoversAtomDefinition },
103
68
  { definition: restoreAtomDefinition },
104
- { definition: apyRatesAtomDefinition },
105
69
  ].map(withType('atom'))
106
70
 
107
71
  export default createAtomDependencies
@@ -4,11 +4,9 @@
4
4
  import assert from 'minimalistic-assert'
5
5
 
6
6
  import createAdapterDependencies from './adapters'
7
- import createAtomCollectionDependencies from './atom-collections'
8
7
  import createAtomDependencies from './atoms'
9
8
  import createConfigDependencies from './configs'
10
9
  import createModuleDependencies from './modules'
11
- import createMonitorDependencies from './monitors'
12
10
  import createPluginDependencies from './plugins'
13
11
  import { wrapConstant } from './utils'
14
12
 
@@ -35,12 +33,8 @@ const createDependencies = ({ adapters, config }) => {
35
33
 
36
34
  const modules = createModuleDependencies({ adapters, config })
37
35
 
38
- const monitors = createMonitorDependencies({ adapters, config })
39
-
40
36
  const atoms = createAtomDependencies({ adapters, config })
41
37
 
42
- const atomCollections = createAtomCollectionDependencies({ adapters, config })
43
-
44
38
  const adaptersTree = createAdapterDependencies({ adapters, config })
45
39
 
46
40
  const plugins = createPluginDependencies()
@@ -49,9 +43,7 @@ const createDependencies = ({ adapters, config }) => {
49
43
  .concat(adaptersTree)
50
44
  .concat(configs)
51
45
  .concat(modules)
52
- .concat(monitors)
53
46
  .concat(atoms)
54
- .concat(atomCollections)
55
47
  .concat(plugins)
56
48
  .concat(wrapConstant({ id: 'logger', type: 'module', value: logger }))
57
49
  }
@@ -1,9 +1,7 @@
1
- import createAddressProviderDependencies from '@exodus/address-provider'
2
1
  import availableAssetsModuleDefinition from '@exodus/available-assets/module'
3
2
  import balancesDefinition from '@exodus/balances/module'
4
3
  import enabledAssetsModuleDefinition from '@exodus/enabled-assets/module'
5
4
  import createExodusPricingClient from '@exodus/exodus-pricing-client'
6
- import featureFlagsDefinition from '@exodus/feature-flags/module'
7
5
  import createKeyIdentifierProvider from '@exodus/key-identifier-provider'
8
6
  import keychainDefinition from '@exodus/keychain/module'
9
7
  import walletDefinition from '@exodus/wallet/module'
@@ -50,11 +48,6 @@ const createModuleDependencies = ({ config }) =>
50
48
  },
51
49
  },
52
50
  { definition: balancesDefinition, writesAtoms: ['balancesAtom'] },
53
- {
54
- definition: featureFlagsDefinition,
55
- writesAtoms: ['featureFlagAtoms'],
56
- },
57
- ...createAddressProviderDependencies(config.addressProvider),
58
51
  ].map(withType('module'))
59
52
 
60
53
  export default createModuleDependencies
package/src/index.js CHANGED
@@ -5,25 +5,39 @@ import attachAtoms from './atoms/attach'
5
5
  import { atomsToAttach } from './constants'
6
6
  import createIOC from './ioc'
7
7
  import abTesting from './modules/ab-testing'
8
+ import addressProvider from './modules/address-provider'
9
+ import apyRates from './modules/apy-rates'
8
10
  import blockchainMetadata from './modules/blockchain-metadata'
9
11
  import connectedOrigins from './modules/connected-origins'
10
12
  import cryptoNews from './modules/crypto-news'
13
+ import featureFlags from './modules/feature-flags'
14
+ import fees from './modules/fees'
15
+ import geolocation from './modules/geolocation'
11
16
  import kyc from './modules/kyc'
12
17
  import locale from './modules/locale'
18
+ import marketHistory from './modules/market-history'
13
19
  import nfts from './modules/nfts'
14
20
  import personalNotes from './modules/personal-notes'
21
+ import rates from './modules/rates'
15
22
  import referrals from './modules/referrals'
16
23
  import remoteConfig from './modules/remote-config'
24
+ import topMovers from './modules/top-movers'
17
25
  import walletAccounts from './modules/wallet-accounts'
18
26
  import attachPlugins from './plugins/attach'
19
27
 
20
28
  const createExodus = ({ adapters, config, port }) => {
21
29
  const ioc = createIOC({ adapters, config })
22
- const { headless: headlessConfig } = config
30
+ const { headless: headlessConfig, topMoversMonitor } = config
23
31
 
24
32
  ioc.use(walletAccounts())
25
33
  ioc.use(blockchainMetadata())
26
34
  ioc.use(remoteConfig())
35
+ ioc.use(geolocation())
36
+ ioc.use(marketHistory())
37
+ ioc.use(fees())
38
+ ioc.use(rates())
39
+ ioc.use(apyRates())
40
+ ioc.use(featureFlags())
27
41
  ioc.use(locale())
28
42
  ioc.use(nfts())
29
43
  ioc.use(kyc())
@@ -32,6 +46,8 @@ const createExodus = ({ adapters, config, port }) => {
32
46
  ioc.use(abTesting())
33
47
  ioc.use(personalNotes())
34
48
  ioc.use(cryptoNews())
49
+ ioc.use(topMovers({ config: topMoversMonitor }))
50
+ ioc.use(addressProvider({ config: config.addressProvider }))
35
51
 
36
52
  ioc.register({ definition: { id: 'port', type: 'port', factory: () => port } })
37
53
 
@@ -40,54 +56,17 @@ const createExodus = ({ adapters, config, port }) => {
40
56
 
41
57
  const { assetsModule, storage } = ioc.getByType('adapter')
42
58
 
43
- const { application, enabledAssets, featureFlags, unlockEncryptedStorage } =
44
- ioc.getByType('module')
45
-
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')
56
-
57
- feeMonitors.on('fees-load', () => port.emit('fees-load', feeMonitors.getAllFeeData()))
58
- feeMonitors.on('fees-update', (payload) => port.emit('fees-update', payload))
59
-
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))
59
+ const { application, enabledAssets, unlockEncryptedStorage } = ioc.getByType('module')
68
60
 
69
61
  application.hook('start', (payload) => {
70
- featureFlags.load()
71
- geolocationMonitor.start()
72
-
73
62
  port.emit('start', payload)
74
63
  })
75
64
 
76
65
  application.hook('unlock', async () => {
77
66
  if (typeof storage.unlock === 'function') unlockEncryptedStorage(storage)
78
67
 
79
- marketHistory.start()
80
- ratesMonitor.start()
81
- feeMonitors.start()
82
- apyRatesMonitor.start()
83
-
84
68
  await assetsModule.load()
85
69
  await enabledAssets.load()
86
-
87
- featureFlagAtoms.topMovers?.get().then(({ isOn }) => {
88
- if (!isOn) return
89
- topMoversMonitor.start()
90
- })
91
70
  })
92
71
 
93
72
  application.on('unlock', () => {
@@ -99,7 +78,6 @@ const createExodus = ({ adapters, config, port }) => {
99
78
  //
100
79
  assetsModule.clear(),
101
80
  enabledAssets.clear(),
102
- featureFlags.clear(),
103
81
  ])
104
82
  })
105
83
 
@@ -0,0 +1,14 @@
1
+ const createAddressProviderApi = ({ addressProvider }) => ({
2
+ addressProvider: {
3
+ getAddress: addressProvider.getAddress.bind(addressProvider),
4
+ getSupportedPurposes: addressProvider.getSupportedPurposes.bind(addressProvider),
5
+ getReceiveAddress: addressProvider.getReceiveAddress.bind(addressProvider),
6
+ },
7
+ })
8
+
9
+ export default {
10
+ id: 'addressProviderApi',
11
+ type: 'api',
12
+ factory: createAddressProviderApi,
13
+ dependencies: ['addressProvider'],
14
+ }
@@ -0,0 +1,15 @@
1
+ import createAddressProviderDependencies from '@exodus/address-provider'
2
+
3
+ import { withType } from '../../dependencies/utils'
4
+ import addressProviderApi from './api'
5
+
6
+ const addressProvider = ({ config }) => {
7
+ const dependencies = createAddressProviderDependencies(config).map(withType('module'))
8
+
9
+ return {
10
+ id: 'addressProvider',
11
+ definitions: [...dependencies, { definition: addressProviderApi }],
12
+ }
13
+ }
14
+
15
+ export default addressProvider
@@ -0,0 +1,20 @@
1
+ import { apyRatesAtomDefinition } from '@exodus/apy-rates/atoms'
2
+ import apyRatesMonitorDefinition from '@exodus/apy-rates/monitor'
3
+
4
+ import apyRatesPlugin from './plugin'
5
+
6
+ const apyRates = () => {
7
+ return {
8
+ id: 'apyRates',
9
+ definitions: [
10
+ {
11
+ definition: apyRatesMonitorDefinition,
12
+ writesAtoms: ['apyRatesAtom'],
13
+ },
14
+ { definition: apyRatesAtomDefinition },
15
+ { definition: apyRatesPlugin },
16
+ ],
17
+ }
18
+ }
19
+
20
+ export default apyRates
@@ -0,0 +1,14 @@
1
+ const createApyRatesLifecyclePlugin = ({ apyRatesMonitor }) => {
2
+ const onUnlock = () => {
3
+ apyRatesMonitor.start()
4
+ }
5
+
6
+ return { onUnlock }
7
+ }
8
+
9
+ export default {
10
+ id: 'apyRatesLifecyclePlugin',
11
+ type: 'plugin',
12
+ factory: createApyRatesLifecyclePlugin,
13
+ dependencies: ['apyRatesMonitor'],
14
+ }
@@ -0,0 +1,35 @@
1
+ import {
2
+ featureFlagAtomsDefinition,
3
+ featureFlagsAtomDefinition,
4
+ remoteConfigFeatureFlagAtomsDefinition,
5
+ } from '@exodus/feature-flags/atoms'
6
+ import featureFlagsDefinition from '@exodus/feature-flags/module'
7
+
8
+ import featureFlagsPlugin from './plugin'
9
+
10
+ const featureFlags = () => {
11
+ return {
12
+ id: 'featureFlags',
13
+ definitions: [
14
+ {
15
+ definition: featureFlagsDefinition,
16
+ writesAtoms: ['featureFlagAtoms'],
17
+ },
18
+ {
19
+ definition: featureFlagAtomsDefinition,
20
+ storage: { namespace: 'featureFlags' },
21
+ aliases: [
22
+ {
23
+ implementationId: 'unsafeStorage',
24
+ interfaceId: 'storage',
25
+ },
26
+ ],
27
+ },
28
+ { definition: featureFlagsAtomDefinition },
29
+ { definition: remoteConfigFeatureFlagAtomsDefinition },
30
+ { definition: featureFlagsPlugin },
31
+ ],
32
+ }
33
+ }
34
+
35
+ export default featureFlags
@@ -0,0 +1,18 @@
1
+ const createFeatureFlagsLifecyclePlugin = ({ featureFlags }) => {
2
+ const onStart = () => {
3
+ featureFlags.load()
4
+ }
5
+
6
+ const onClear = async () => {
7
+ await featureFlags.clear()
8
+ }
9
+
10
+ return { onStart, onClear }
11
+ }
12
+
13
+ export default {
14
+ id: 'featureFlagsLifecyclePlugin',
15
+ type: 'plugin',
16
+ factory: createFeatureFlagsLifecyclePlugin,
17
+ dependencies: ['featureFlags'],
18
+ }
@@ -0,0 +1,16 @@
1
+ import feeMonitorsDefinition from '@exodus/fee-monitors/monitor'
2
+
3
+ import feesPlugin from './plugin'
4
+
5
+ const fees = () => {
6
+ return {
7
+ id: 'fees',
8
+ definitions: [
9
+ // ...
10
+ { definition: feeMonitorsDefinition },
11
+ { definition: feesPlugin },
12
+ ],
13
+ }
14
+ }
15
+
16
+ export default fees
@@ -0,0 +1,17 @@
1
+ const createFeesLifecyclePlugin = ({ feeMonitors, port }) => {
2
+ feeMonitors.on('fees-load', () => port.emit('fees-load', feeMonitors.getAllFeeData()))
3
+ feeMonitors.on('fees-update', (payload) => port.emit('fees-update', payload))
4
+
5
+ const onUnlock = () => {
6
+ feeMonitors.start()
7
+ }
8
+
9
+ return { onUnlock }
10
+ }
11
+
12
+ export default {
13
+ id: 'feesLifecyclePlugin',
14
+ type: 'plugin',
15
+ factory: createFeesLifecyclePlugin,
16
+ dependencies: ['feeMonitors', 'port'],
17
+ }
@@ -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
+ }
@@ -1,25 +0,0 @@
1
- import {
2
- featureFlagAtomsDefinition,
3
- remoteConfigFeatureFlagAtomsDefinition,
4
- } from '@exodus/feature-flags/atoms'
5
-
6
- import { withType } from './utils'
7
-
8
- const createAtomCollectionDependencies = () =>
9
- [
10
- {
11
- definition: remoteConfigFeatureFlagAtomsDefinition,
12
- },
13
- {
14
- definition: featureFlagAtomsDefinition,
15
- storage: { namespace: 'featureFlags' },
16
- aliases: [
17
- {
18
- implementationId: 'unsafeStorage',
19
- interfaceId: 'storage',
20
- },
21
- ],
22
- },
23
- ].map(withType('atom-collection'))
24
-
25
- export default createAtomCollectionDependencies
@@ -1,56 +0,0 @@
1
- import apyRatesMonitorDefinition from '@exodus/apy-rates/monitor'
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
-
9
- import { withType } from './utils'
10
-
11
- const createMonitorDependencies = ({ config }) =>
12
- [
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
- { 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
- {
51
- definition: apyRatesMonitorDefinition,
52
- writesAtoms: ['apyRatesAtom'],
53
- },
54
- ].map(withType('monitor'))
55
-
56
- export default createMonitorDependencies