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

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,19 @@
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.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
+
8
+ ### Features
9
+
10
+ - use(personalNotes, blockchainMetadata, remoteConfig, cryptoNews) ([#1991](https://github.com/ExodusMovement/exodus-hydra/issues/1991)) ([ccaaa4a](https://github.com/ExodusMovement/exodus-hydra/commit/ccaaa4ac44f8bed9de99418c394c40478eaeae69))
11
+ - validate type field on ioc.use() ([#1974](https://github.com/ExodusMovement/exodus-hydra/issues/1974)) ([b234c82](https://github.com/ExodusMovement/exodus-hydra/commit/b234c82a6f0550d34273590250b307a965b11295))
12
+
13
+ ## [2.0.0-alpha.43](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.42...@exodus/headless@2.0.0-alpha.43) (2023-06-16)
14
+
15
+ ### Features
16
+
17
+ - **headless:** integrate ab-testing module ([#1972](https://github.com/ExodusMovement/exodus-hydra/issues/1972)) ([6c063b4](https://github.com/ExodusMovement/exodus-hydra/commit/6c063b4d4f04d08c36f843577822e7d53f002d4f))
18
+
6
19
  ## [2.0.0-alpha.42](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.41...@exodus/headless@2.0.0-alpha.42) (2023-06-15)
7
20
 
8
21
  ### Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/headless",
3
- "version": "2.0.0-alpha.42",
3
+ "version": "2.0.0-alpha.44",
4
4
  "description": "The headless Exodus wallet SDK",
5
5
  "author": "Exodus Movement Inc",
6
6
  "main": "src/index.js",
@@ -26,6 +26,7 @@
26
26
  "test": "jest --runInBand"
27
27
  },
28
28
  "dependencies": {
29
+ "@exodus/ab-testing": "^5.1.0",
29
30
  "@exodus/address-provider": "^4.0.0",
30
31
  "@exodus/apy-rates": "^2.1.0",
31
32
  "@exodus/atoms": "^4.0.1",
@@ -87,5 +88,5 @@
87
88
  "nock": "^13.3.1",
88
89
  "p-defer": "^4.0.0"
89
90
  },
90
- "gitHead": "bd71b5cf5b53868f90e6741bff3425022df792e9"
91
+ "gitHead": "1116abf16d19461a0bd9154799613bd97d2a6cd9"
91
92
  }
package/src/api.js CHANGED
@@ -5,15 +5,8 @@ const createApi = ({ ioc, port }) => {
5
5
 
6
6
  const { assetsModule } = ioc.getByType('adapter')
7
7
 
8
- const {
9
- addressProvider,
10
- application,
11
- blockchainMetadata,
12
- enabledAssets,
13
- personalNotes,
14
- remoteConfig,
15
- wallet,
16
- } = ioc.getByType('module')
8
+ const { addressProvider, application, enabledAssets, remoteConfig, wallet } =
9
+ ioc.getByType('module')
17
10
 
18
11
  const { feeMonitors, ratesMonitor, nftsMonitor } = ioc.getByType('monitor')
19
12
 
@@ -51,19 +44,6 @@ const createApi = ({ ioc, port }) => {
51
44
  changeLockTimer: application.changeLockTimer,
52
45
  isLocked: () => wallet.isLocked(),
53
46
  },
54
- blockchainMetadata: {
55
- getTxLog: blockchainMetadata.getTxLog,
56
- getLoadedTxLogs: blockchainMetadata.getLoadedTxLogs,
57
- updateTxs: blockchainMetadata.updateTxs,
58
- overwriteTxs: blockchainMetadata.overwriteTxs,
59
- clearTxs: blockchainMetadata.clearTxs,
60
- removeTxs: blockchainMetadata.removeTxs,
61
- getAccountState: blockchainMetadata.getAccountState,
62
- getLoadedAccountStates: blockchainMetadata.getLoadedAccountStates,
63
- updateAccountState: blockchainMetadata.updateAccountState,
64
- removeAccountState: blockchainMetadata.removeAccountState,
65
- batch: blockchainMetadata.batch,
66
- },
67
47
  assets: {
68
48
  enable: enabledAssets.enable,
69
49
  disable: enabledAssets.disable,
@@ -73,10 +53,6 @@ const createApi = ({ ioc, port }) => {
73
53
  return asset.name
74
54
  },
75
55
  },
76
- remoteConfig: {
77
- get: remoteConfig.get,
78
- getAll: remoteConfig.getAll,
79
- },
80
56
  rates: {
81
57
  refresh: () => ratesMonitor.update(),
82
58
  },
@@ -85,9 +61,6 @@ const createApi = ({ ioc, port }) => {
85
61
  getSupportedPurposes: addressProvider.getSupportedPurposes.bind(addressProvider),
86
62
  getReceiveAddress: addressProvider.getReceiveAddress.bind(addressProvider),
87
63
  },
88
- personalNotes: {
89
- upsert: personalNotes.upsert,
90
- },
91
64
  isMnemonicValid,
92
65
  subscribe: port.subscribe.bind(port),
93
66
  unsubscribe: port.unsubscribe.bind(port),
package/src/constants.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export const atomsToAttach = [
2
+ 'abTestingAtom',
2
3
  'apyRatesAtom',
3
4
  'availableAssetNamesAtom',
4
5
  'balancesAtom',
@@ -6,14 +6,12 @@ import {
6
6
  } from '@exodus/atoms'
7
7
  import { availableAssetNamesAtomDefinition } from '@exodus/available-assets/atoms'
8
8
  import { balancesAtomDefinition } from '@exodus/balances/atoms'
9
- import { cryptoNewsAtomDefinition } from '@exodus/crypto-news-monitor/atoms'
10
9
  import {
11
10
  enabledAndDisabledAssetsAtomDefinition,
12
11
  enabledAssetsAtomDefinition,
13
12
  } from '@exodus/enabled-assets/atoms'
14
13
  import { featureFlagsAtomDefinition } from '@exodus/feature-flags/atoms'
15
14
  import { geolocationAtomDefinition } from '@exodus/geolocation/atoms'
16
- import { personalNotesAtomDefinition } from '@exodus/personal-notes/atoms'
17
15
  import { ratesAtomDefinition } from '@exodus/rates-monitor/atoms'
18
16
  import { topMoversAtomDefinition } from '@exodus/top-movers-monitor/atoms'
19
17
 
@@ -100,18 +98,8 @@ const createAtomDependencies = () =>
100
98
  { definition: ratesAtomDefinition },
101
99
  { definition: geolocationAtomDefinition },
102
100
  { definition: featureFlagsAtomDefinition },
103
- {
104
- definition: personalNotesAtomDefinition,
105
- aliases: [
106
- {
107
- implementationId: 'personalNotesStorage',
108
- interfaceId: 'storage',
109
- },
110
- ],
111
- },
112
101
  { definition: baseAssetNamesToMonitorAtomDefinition },
113
102
  { definition: topMoversAtomDefinition },
114
- { definition: cryptoNewsAtomDefinition },
115
103
  { definition: restoreAtomDefinition },
116
104
  { definition: apyRatesAtomDefinition },
117
105
  ].map(withType('atom'))
@@ -1,17 +1,13 @@
1
1
  import createAddressProviderDependencies from '@exodus/address-provider'
2
2
  import availableAssetsModuleDefinition from '@exodus/available-assets/module'
3
3
  import balancesDefinition from '@exodus/balances/module'
4
- import blockchainMetadataDefinition from '@exodus/blockchain-metadata/module'
5
- import createRemoteConfig from '@exodus/config/remote'
6
4
  import enabledAssetsModuleDefinition from '@exodus/enabled-assets/module'
7
5
  import createExodusPricingClient from '@exodus/exodus-pricing-client'
8
6
  import featureFlagsDefinition from '@exodus/feature-flags/module'
9
7
  import createKeyIdentifierProvider from '@exodus/key-identifier-provider'
10
8
  import keychainDefinition from '@exodus/keychain/module'
11
- import personalNotesDefinition from '@exodus/personal-notes/module'
12
9
  import walletDefinition from '@exodus/wallet/module'
13
10
  import walletCompatibilityModesDefinition from '@exodus/wallet-compatibility-modes/module'
14
- import EventEmitter from 'events/'
15
11
 
16
12
  import createApplication from '../application'
17
13
  import unlockEncryptedStorageDefinition from '../unlock-encrypted-storage'
@@ -44,21 +40,7 @@ const createModuleDependencies = ({ config }) =>
44
40
  definition: walletCompatibilityModesDefinition,
45
41
  },
46
42
  { definition: unlockEncryptedStorageDefinition },
47
- {
48
- definition: blockchainMetadataDefinition,
49
- storage: { namespace: ['blockchain', 'v1'] },
50
- },
51
43
  { definition: enabledAssetsModuleDefinition, writesAtoms: ['enabledAndDisabledAssetsAtom'] },
52
- {
53
- definition: {
54
- id: 'remoteConfig',
55
- factory: (deps) => {
56
- const eventEmitter = new EventEmitter().setMaxListeners(Number.POSITIVE_INFINITY)
57
- return createRemoteConfig({ eventEmitter, ...deps })
58
- },
59
- dependencies: ['fetch', 'freeze', 'config', 'logger'],
60
- },
61
- },
62
44
  { definition: availableAssetsModuleDefinition, writesAtoms: ['availableAssetNamesAtom'] },
63
45
  {
64
46
  definition: {
@@ -73,9 +55,6 @@ const createModuleDependencies = ({ config }) =>
73
55
  writesAtoms: ['featureFlagAtoms'],
74
56
  },
75
57
  ...createAddressProviderDependencies(config.addressProvider),
76
- {
77
- definition: personalNotesDefinition,
78
- },
79
58
  ].map(withType('module'))
80
59
 
81
60
  export default createModuleDependencies
@@ -1,5 +1,4 @@
1
1
  import apyRatesMonitorDefinition from '@exodus/apy-rates/monitor'
2
- import cryptoNewsMonitorDefinition from '@exodus/crypto-news-monitor/monitor'
3
2
  import feeMonitorsDefinition from '@exodus/fee-monitors/monitor'
4
3
  import geolocationMonitorDefinition from '@exodus/geolocation/monitor'
5
4
  import marketHistoryMonitorDefinition from '@exodus/market-history/module'
@@ -48,10 +47,6 @@ const createMonitorDependencies = ({ config }) =>
48
47
  : remoteTopMoversMonitorDefinition,
49
48
  writesAtoms: ['topMoversAtom'],
50
49
  },
51
- {
52
- definition: cryptoNewsMonitorDefinition,
53
- writesAtoms: ['cryptoNewsAtom'],
54
- },
55
50
  {
56
51
  definition: apyRatesMonitorDefinition,
57
52
  writesAtoms: ['apyRatesAtom'],
package/src/index.js CHANGED
@@ -4,25 +4,34 @@ import createApi from './api'
4
4
  import attachAtoms from './atoms/attach'
5
5
  import { atomsToAttach } from './constants'
6
6
  import createIOC from './ioc'
7
+ import abTesting from './modules/ab-testing'
8
+ import blockchainMetadata from './modules/blockchain-metadata'
7
9
  import connectedOrigins from './modules/connected-origins'
10
+ import cryptoNews from './modules/crypto-news'
8
11
  import kyc from './modules/kyc'
9
12
  import locale from './modules/locale'
10
13
  import nfts from './modules/nfts'
14
+ import personalNotes from './modules/personal-notes'
11
15
  import referrals from './modules/referrals'
16
+ import remoteConfig from './modules/remote-config'
12
17
  import walletAccounts from './modules/wallet-accounts'
13
18
  import attachPlugins from './plugins/attach'
14
- import { createLoadWalletAccountsHandler } from './utils/blockchain-metadata'
15
19
 
16
20
  const createExodus = ({ adapters, config, port }) => {
17
21
  const ioc = createIOC({ adapters, config })
18
22
  const { headless: headlessConfig } = config
19
23
 
20
24
  ioc.use(walletAccounts())
25
+ ioc.use(blockchainMetadata())
26
+ ioc.use(remoteConfig())
21
27
  ioc.use(locale())
22
28
  ioc.use(nfts())
23
29
  ioc.use(kyc())
24
30
  ioc.use(referrals())
25
31
  ioc.use(connectedOrigins())
32
+ ioc.use(abTesting())
33
+ ioc.use(personalNotes())
34
+ ioc.use(cryptoNews())
26
35
 
27
36
  ioc.register({ definition: { id: 'port', type: 'port', factory: () => port } })
28
37
 
@@ -31,19 +40,11 @@ const createExodus = ({ adapters, config, port }) => {
31
40
 
32
41
  const { assetsModule, storage } = ioc.getByType('adapter')
33
42
 
34
- const {
35
- application,
36
- blockchainMetadata,
37
- enabledAssets,
38
- featureFlags,
39
- personalNotes,
40
- remoteConfig,
41
- unlockEncryptedStorage,
42
- } = ioc.getByType('module')
43
+ const { application, enabledAssets, featureFlags, unlockEncryptedStorage } =
44
+ ioc.getByType('module')
43
45
 
44
46
  const {
45
47
  apyRatesMonitor,
46
- cryptoNewsMonitor,
47
48
  feeMonitors,
48
49
  geolocationMonitor,
49
50
  marketHistory,
@@ -53,22 +54,9 @@ const createExodus = ({ adapters, config, port }) => {
53
54
 
54
55
  const { featureFlagAtoms } = ioc.getByType('atom-collection')
55
56
 
56
- const handleLoadWalletAccounts = createLoadWalletAccountsHandler({
57
- blockchainMetadata,
58
- port,
59
- })
60
-
61
- blockchainMetadata.on('load-wallet-accounts', handleLoadWalletAccounts)
62
- blockchainMetadata.on('tx-logs-update', (payload) => port.emit('tx-logs-update', payload))
63
- blockchainMetadata.on('account-states-update', (payload) =>
64
- port.emit('account-states-update', payload)
65
- )
66
-
67
57
  feeMonitors.on('fees-load', () => port.emit('fees-load', feeMonitors.getAllFeeData()))
68
58
  feeMonitors.on('fees-update', (payload) => port.emit('fees-update', payload))
69
59
 
70
- remoteConfig.on('sync', ({ current }) => port.emit('remote-config', current))
71
-
72
60
  // TODO: migrate to marketHistoryAtom. Will be easier once it's on headless
73
61
  marketHistory.on('market-history', (payload) => port.emit('market-history', payload))
74
62
  marketHistory.on('market-history-new-assets', (payload) =>
@@ -79,7 +67,6 @@ const createExodus = ({ adapters, config, port }) => {
79
67
  ratesMonitor.on('rates', (payload) => port.emit('rates', payload))
80
68
 
81
69
  application.hook('start', (payload) => {
82
- remoteConfig.load()
83
70
  featureFlags.load()
84
71
  geolocationMonitor.start()
85
72
 
@@ -89,28 +76,18 @@ const createExodus = ({ adapters, config, port }) => {
89
76
  application.hook('unlock', async () => {
90
77
  if (typeof storage.unlock === 'function') unlockEncryptedStorage(storage)
91
78
 
92
- remoteConfig.sync()
93
79
  marketHistory.start()
94
80
  ratesMonitor.start()
95
81
  feeMonitors.start()
96
82
  apyRatesMonitor.start()
97
83
 
98
84
  await assetsModule.load()
99
- await Promise.all([
100
- //
101
- blockchainMetadata.load(),
102
- enabledAssets.load(),
103
- ])
85
+ await enabledAssets.load()
104
86
 
105
87
  featureFlagAtoms.topMovers?.get().then(({ isOn }) => {
106
88
  if (!isOn) return
107
89
  topMoversMonitor.start()
108
90
  })
109
-
110
- featureFlagAtoms.cryptoNews?.get().then(({ isOn }) => {
111
- if (!isOn) return
112
- cryptoNewsMonitor.start()
113
- })
114
91
  })
115
92
 
116
93
  application.on('unlock', () => {
@@ -121,13 +98,9 @@ const createExodus = ({ adapters, config, port }) => {
121
98
  await Promise.all([
122
99
  //
123
100
  assetsModule.clear(),
124
- blockchainMetadata.clear(),
125
101
  enabledAssets.clear(),
126
102
  featureFlags.clear(),
127
103
  ])
128
-
129
- // TEMP: dont wait to clear as encrypted storage is not yet unlocked
130
- personalNotes.clear()
131
104
  })
132
105
 
133
106
  application.on('clear', () => {
package/src/ioc.js CHANGED
@@ -7,6 +7,7 @@ import namespaceConfig from '@exodus/dependency-preprocessors/src/preprocessors/
7
7
  import namespaceStorage from '@exodus/dependency-preprocessors/src/preprocessors/namespace-storage'
8
8
  import optional from '@exodus/dependency-preprocessors/src/preprocessors/optional'
9
9
  import readOnlyAtoms from '@exodus/dependency-preprocessors/src/preprocessors/read-only-atoms'
10
+ import assert from 'minimalistic-assert'
10
11
 
11
12
  import createDependencies from './dependencies'
12
13
 
@@ -40,6 +41,10 @@ const createIOC = ({ adapters, config }) => {
40
41
  }
41
42
 
42
43
  const use = (module) => {
44
+ for (const { definition } of module.definitions) {
45
+ assert(definition.type, `ioc.use: "${definition.id}" is missing type field`)
46
+ }
47
+
43
48
  registerMultiple(module.definitions)
44
49
  }
45
50
 
@@ -0,0 +1,13 @@
1
+ const abTestingApi = ({ abTesting }) => ({
2
+ abTesting: {
3
+ trackEvent: abTesting.trackEvent,
4
+ updateVariant: abTesting.updateVariant,
5
+ },
6
+ })
7
+
8
+ export default {
9
+ id: 'abTestingApi',
10
+ type: 'api',
11
+ factory: abTestingApi,
12
+ dependencies: ['abTesting'],
13
+ }
@@ -0,0 +1,26 @@
1
+ import { abTestingAtomDefinition } from '@exodus/ab-testing/atoms'
2
+ import abTestingDefinition from '@exodus/ab-testing/module'
3
+
4
+ import abTestingApiDefinition from './api'
5
+ import abTestingPluginDefinition from './plugin'
6
+
7
+ const abTesting = () => {
8
+ return {
9
+ id: 'abTesting',
10
+ definitions: [
11
+ {
12
+ definition: abTestingAtomDefinition,
13
+ storage: { namespace: 'abTesting' },
14
+ aliases: [{ implementationId: 'unsafeStorage', interfaceId: 'storage' }],
15
+ },
16
+ {
17
+ definition: abTestingDefinition,
18
+ writesAtom: ['abTestingAtom'],
19
+ },
20
+ { definition: abTestingPluginDefinition },
21
+ { definition: abTestingApiDefinition },
22
+ ],
23
+ }
24
+ }
25
+
26
+ export default abTesting
@@ -0,0 +1,21 @@
1
+ const abTestingLifecyclePlugin = ({ abTesting, featureFlagAtoms }) => {
2
+ const onStart = async () => {
3
+ featureFlagAtoms.abTesting?.get().then(({ isOn }) => {
4
+ if (!isOn) return
5
+ abTesting.load()
6
+ })
7
+ }
8
+
9
+ const onClear = async () => {
10
+ await abTesting.clear()
11
+ }
12
+
13
+ return { onStart, onClear }
14
+ }
15
+
16
+ export default {
17
+ id: 'abTestingLifecyclePlugin',
18
+ type: 'plugin',
19
+ factory: abTestingLifecyclePlugin,
20
+ dependencies: ['abTesting', 'featureFlagAtoms'],
21
+ }
@@ -0,0 +1,22 @@
1
+ const createBlockchainMetadataApi = ({ blockchainMetadata }) => ({
2
+ blockchainMetadata: {
3
+ getTxLog: blockchainMetadata.getTxLog,
4
+ getLoadedTxLogs: blockchainMetadata.getLoadedTxLogs,
5
+ updateTxs: blockchainMetadata.updateTxs,
6
+ overwriteTxs: blockchainMetadata.overwriteTxs,
7
+ clearTxs: blockchainMetadata.clearTxs,
8
+ removeTxs: blockchainMetadata.removeTxs,
9
+ getAccountState: blockchainMetadata.getAccountState,
10
+ getLoadedAccountStates: blockchainMetadata.getLoadedAccountStates,
11
+ updateAccountState: blockchainMetadata.updateAccountState,
12
+ removeAccountState: blockchainMetadata.removeAccountState,
13
+ batch: blockchainMetadata.batch,
14
+ },
15
+ })
16
+
17
+ export default {
18
+ id: 'createBlockchainMetadataApi',
19
+ type: 'api',
20
+ factory: createBlockchainMetadataApi,
21
+ dependencies: ['blockchainMetadata'],
22
+ }
@@ -0,0 +1,20 @@
1
+ import blockchainMetadataDefinition from '@exodus/blockchain-metadata/module'
2
+
3
+ import blockchainMetadataApiDefinition from './api'
4
+ import blockchainMetadataPluginDefinition from './plugin'
5
+
6
+ const blockchainMetadata = () => {
7
+ return {
8
+ id: 'blockchainMetadata',
9
+ definitions: [
10
+ {
11
+ definition: blockchainMetadataDefinition,
12
+ storage: { namespace: ['blockchain', 'v1'] },
13
+ },
14
+ { definition: blockchainMetadataPluginDefinition },
15
+ { definition: blockchainMetadataApiDefinition },
16
+ ],
17
+ }
18
+ }
19
+
20
+ export default blockchainMetadata
@@ -0,0 +1,30 @@
1
+ import { createLoadWalletAccountsHandler } from './utils'
2
+
3
+ const blockchainLifecyclePlugin = ({ blockchainMetadata, port }) => {
4
+ const handleLoadWalletAccounts = createLoadWalletAccountsHandler({ blockchainMetadata, port })
5
+
6
+ blockchainMetadata.on('load-wallet-accounts', handleLoadWalletAccounts)
7
+
8
+ blockchainMetadata.on('tx-logs-update', (payload) => port.emit('tx-logs-update', payload))
9
+
10
+ blockchainMetadata.on('account-states-update', (payload) =>
11
+ port.emit('account-states-update', payload)
12
+ )
13
+
14
+ const onUnlock = async () => {
15
+ await blockchainMetadata.load()
16
+ }
17
+
18
+ const onClear = async () => {
19
+ await blockchainMetadata.clear()
20
+ }
21
+
22
+ return { onUnlock, onClear }
23
+ }
24
+
25
+ export default {
26
+ id: 'blockchainLifecyclePlugin',
27
+ type: 'plugin',
28
+ factory: blockchainLifecyclePlugin,
29
+ dependencies: ['blockchainMetadata', 'port'],
30
+ }
@@ -0,0 +1,20 @@
1
+ import { cryptoNewsAtomDefinition } from '@exodus/crypto-news-monitor/atoms'
2
+ import cryptoNewsMonitorDefinition from '@exodus/crypto-news-monitor/monitor'
3
+
4
+ import cryptoNewsPluginDefinition from './plugin'
5
+
6
+ const cryptoNews = () => {
7
+ return {
8
+ id: 'cryptoNews',
9
+ definitions: [
10
+ { definition: cryptoNewsAtomDefinition },
11
+ {
12
+ definition: cryptoNewsMonitorDefinition,
13
+ writesAtoms: ['cryptoNewsAtom'],
14
+ },
15
+ { definition: cryptoNewsPluginDefinition },
16
+ ],
17
+ }
18
+ }
19
+
20
+ export default cryptoNews
@@ -0,0 +1,17 @@
1
+ const cryptoNewsPlugin = ({ cryptoNewsMonitor, featureFlagAtoms }) => {
2
+ const onUnlock = () => {
3
+ featureFlagAtoms.cryptoNews?.get().then(({ isOn }) => {
4
+ if (!isOn) return
5
+ cryptoNewsMonitor.start()
6
+ })
7
+ }
8
+
9
+ return { onUnlock }
10
+ }
11
+
12
+ export default {
13
+ id: 'cryptoNewsLifecyclePlugin',
14
+ type: 'plugin',
15
+ factory: cryptoNewsPlugin,
16
+ dependencies: ['cryptoNewsMonitor', 'featureFlagAtoms'],
17
+ }
@@ -0,0 +1,12 @@
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
+ }
@@ -0,0 +1,28 @@
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
+ { definition: { type: 'module', ...personalNotesDefinition } },
22
+ { definition: personalNotesPluginDefinition },
23
+ { definition: personalNotesApiDefinition },
24
+ ],
25
+ }
26
+ }
27
+
28
+ export default personalNotes
@@ -0,0 +1,15 @@
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
+ }
@@ -0,0 +1,13 @@
1
+ const createRemoteConfigApi = ({ remoteConfig }) => ({
2
+ remoteConfig: {
3
+ get: remoteConfig.get,
4
+ getAll: remoteConfig.getAll,
5
+ },
6
+ })
7
+
8
+ export default {
9
+ id: 'createRemoteConfigApi',
10
+ type: 'api',
11
+ factory: createRemoteConfigApi,
12
+ dependencies: ['remoteConfig'],
13
+ }
@@ -0,0 +1,28 @@
1
+ import createRemoteConfig from '@exodus/config/remote'
2
+ import EventEmitter from 'events/'
3
+
4
+ import remoteConfigApiDefinition from './api'
5
+ import remoteConfigPluginDefinition from './plugin'
6
+
7
+ const remoteConfig = () => {
8
+ return {
9
+ id: 'remoteConfig',
10
+ definitions: [
11
+ {
12
+ definition: {
13
+ id: 'remoteConfig',
14
+ type: 'module',
15
+ factory: (deps) => {
16
+ const eventEmitter = new EventEmitter().setMaxListeners(Number.POSITIVE_INFINITY)
17
+ return createRemoteConfig({ eventEmitter, ...deps })
18
+ },
19
+ dependencies: ['fetch', 'freeze', 'config', 'logger'],
20
+ },
21
+ },
22
+ { definition: remoteConfigPluginDefinition },
23
+ { definition: remoteConfigApiDefinition },
24
+ ],
25
+ }
26
+ }
27
+
28
+ export default remoteConfig
@@ -0,0 +1,20 @@
1
+ const remoteConfigLifecyclePlugin = ({ remoteConfig, port }) => {
2
+ remoteConfig.on('sync', ({ current }) => port.emit('remote-config', current))
3
+
4
+ const onStart = () => {
5
+ remoteConfig.load()
6
+ }
7
+
8
+ const onUnlock = () => {
9
+ remoteConfig.sync()
10
+ }
11
+
12
+ return { onUnlock, onStart }
13
+ }
14
+
15
+ export default {
16
+ id: 'remoteConfigLifecyclePlugin',
17
+ type: 'plugin',
18
+ factory: remoteConfigLifecyclePlugin,
19
+ dependencies: ['remoteConfig', 'port'],
20
+ }