@exodus/headless 2.0.0-alpha.43 → 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,13 @@
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
+
6
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)
7
14
 
8
15
  ### Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/headless",
3
- "version": "2.0.0-alpha.43",
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",
@@ -88,5 +88,5 @@
88
88
  "nock": "^13.3.1",
89
89
  "p-defer": "^4.0.0"
90
90
  },
91
- "gitHead": "67ed7c439d9d3626db03d8c926af3e1fbe19cf8f"
91
+ "gitHead": "1116abf16d19461a0bd9154799613bd97d2a6cd9"
92
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),
@@ -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
@@ -5,26 +5,33 @@ 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 blockchainMetadata from './modules/blockchain-metadata'
8
9
  import connectedOrigins from './modules/connected-origins'
10
+ import cryptoNews from './modules/crypto-news'
9
11
  import kyc from './modules/kyc'
10
12
  import locale from './modules/locale'
11
13
  import nfts from './modules/nfts'
14
+ import personalNotes from './modules/personal-notes'
12
15
  import referrals from './modules/referrals'
16
+ import remoteConfig from './modules/remote-config'
13
17
  import walletAccounts from './modules/wallet-accounts'
14
18
  import attachPlugins from './plugins/attach'
15
- import { createLoadWalletAccountsHandler } from './utils/blockchain-metadata'
16
19
 
17
20
  const createExodus = ({ adapters, config, port }) => {
18
21
  const ioc = createIOC({ adapters, config })
19
22
  const { headless: headlessConfig } = config
20
23
 
21
24
  ioc.use(walletAccounts())
25
+ ioc.use(blockchainMetadata())
26
+ ioc.use(remoteConfig())
22
27
  ioc.use(locale())
23
28
  ioc.use(nfts())
24
29
  ioc.use(kyc())
25
30
  ioc.use(referrals())
26
31
  ioc.use(connectedOrigins())
27
32
  ioc.use(abTesting())
33
+ ioc.use(personalNotes())
34
+ ioc.use(cryptoNews())
28
35
 
29
36
  ioc.register({ definition: { id: 'port', type: 'port', factory: () => port } })
30
37
 
@@ -33,19 +40,11 @@ const createExodus = ({ adapters, config, port }) => {
33
40
 
34
41
  const { assetsModule, storage } = ioc.getByType('adapter')
35
42
 
36
- const {
37
- application,
38
- blockchainMetadata,
39
- enabledAssets,
40
- featureFlags,
41
- personalNotes,
42
- remoteConfig,
43
- unlockEncryptedStorage,
44
- } = ioc.getByType('module')
43
+ const { application, enabledAssets, featureFlags, unlockEncryptedStorage } =
44
+ ioc.getByType('module')
45
45
 
46
46
  const {
47
47
  apyRatesMonitor,
48
- cryptoNewsMonitor,
49
48
  feeMonitors,
50
49
  geolocationMonitor,
51
50
  marketHistory,
@@ -55,22 +54,9 @@ const createExodus = ({ adapters, config, port }) => {
55
54
 
56
55
  const { featureFlagAtoms } = ioc.getByType('atom-collection')
57
56
 
58
- const handleLoadWalletAccounts = createLoadWalletAccountsHandler({
59
- blockchainMetadata,
60
- port,
61
- })
62
-
63
- blockchainMetadata.on('load-wallet-accounts', handleLoadWalletAccounts)
64
- blockchainMetadata.on('tx-logs-update', (payload) => port.emit('tx-logs-update', payload))
65
- blockchainMetadata.on('account-states-update', (payload) =>
66
- port.emit('account-states-update', payload)
67
- )
68
-
69
57
  feeMonitors.on('fees-load', () => port.emit('fees-load', feeMonitors.getAllFeeData()))
70
58
  feeMonitors.on('fees-update', (payload) => port.emit('fees-update', payload))
71
59
 
72
- remoteConfig.on('sync', ({ current }) => port.emit('remote-config', current))
73
-
74
60
  // TODO: migrate to marketHistoryAtom. Will be easier once it's on headless
75
61
  marketHistory.on('market-history', (payload) => port.emit('market-history', payload))
76
62
  marketHistory.on('market-history-new-assets', (payload) =>
@@ -81,7 +67,6 @@ const createExodus = ({ adapters, config, port }) => {
81
67
  ratesMonitor.on('rates', (payload) => port.emit('rates', payload))
82
68
 
83
69
  application.hook('start', (payload) => {
84
- remoteConfig.load()
85
70
  featureFlags.load()
86
71
  geolocationMonitor.start()
87
72
 
@@ -91,28 +76,18 @@ const createExodus = ({ adapters, config, port }) => {
91
76
  application.hook('unlock', async () => {
92
77
  if (typeof storage.unlock === 'function') unlockEncryptedStorage(storage)
93
78
 
94
- remoteConfig.sync()
95
79
  marketHistory.start()
96
80
  ratesMonitor.start()
97
81
  feeMonitors.start()
98
82
  apyRatesMonitor.start()
99
83
 
100
84
  await assetsModule.load()
101
- await Promise.all([
102
- //
103
- blockchainMetadata.load(),
104
- enabledAssets.load(),
105
- ])
85
+ await enabledAssets.load()
106
86
 
107
87
  featureFlagAtoms.topMovers?.get().then(({ isOn }) => {
108
88
  if (!isOn) return
109
89
  topMoversMonitor.start()
110
90
  })
111
-
112
- featureFlagAtoms.cryptoNews?.get().then(({ isOn }) => {
113
- if (!isOn) return
114
- cryptoNewsMonitor.start()
115
- })
116
91
  })
117
92
 
118
93
  application.on('unlock', () => {
@@ -123,13 +98,9 @@ const createExodus = ({ adapters, config, port }) => {
123
98
  await Promise.all([
124
99
  //
125
100
  assetsModule.clear(),
126
- blockchainMetadata.clear(),
127
101
  enabledAssets.clear(),
128
102
  featureFlags.clear(),
129
103
  ])
130
-
131
- // TEMP: dont wait to clear as encrypted storage is not yet unlocked
132
- personalNotes.clear()
133
104
  })
134
105
 
135
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,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
+ }