@exodus/headless 2.0.0-alpha.67 → 2.0.0-alpha.7

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +0 -486
  2. package/README.md +4 -133
  3. package/package.json +19 -51
  4. package/src/api.js +44 -11
  5. package/src/application.js +39 -54
  6. package/src/dependencies/atoms.js +21 -2
  7. package/src/dependencies/index.js +1 -8
  8. package/src/dependencies/modules.js +21 -2
  9. package/src/dependencies/utils.js +4 -0
  10. package/src/index.js +38 -91
  11. package/src/ioc.js +6 -32
  12. package/src/unlock-encrypted-storage.js +1 -3
  13. package/src/utils/blockchain-metadata.js +48 -0
  14. package/src/atoms/attach.js +0 -31
  15. package/src/atoms/base-asset-names-to-monitor.js +0 -38
  16. package/src/constants.js +0 -38
  17. package/src/dependencies/plugins.js +0 -7
  18. package/src/features/available-assets/index.js +0 -15
  19. package/src/features/balances/index.js +0 -14
  20. package/src/features/blockchain-metadata/api.js +0 -23
  21. package/src/features/blockchain-metadata/index.js +0 -20
  22. package/src/features/blockchain-metadata/plugin.js +0 -31
  23. package/src/features/blockchain-metadata/utils.js +0 -11
  24. package/src/features/enabled-assets/api.js +0 -19
  25. package/src/features/enabled-assets/index.js +0 -26
  26. package/src/features/enabled-assets/plugin.js +0 -19
  27. package/src/features/feature-flags/api.js +0 -15
  28. package/src/features/feature-flags/index.js +0 -37
  29. package/src/features/feature-flags/plugin.js +0 -19
  30. package/src/features/fees/index.js +0 -16
  31. package/src/features/fees/plugin.js +0 -18
  32. package/src/features/geolocation/index.js +0 -20
  33. package/src/features/geolocation/plugin.js +0 -15
  34. package/src/features/locale/api.js +0 -14
  35. package/src/features/locale/index.js +0 -50
  36. package/src/features/locale/plugin.js +0 -15
  37. package/src/features/nfts/api.js +0 -14
  38. package/src/features/nfts/index.js +0 -33
  39. package/src/features/nfts/plugin.js +0 -24
  40. package/src/features/pricing/api.js +0 -15
  41. package/src/features/pricing/index.js +0 -35
  42. package/src/features/rates/api.js +0 -13
  43. package/src/features/rates/index.js +0 -22
  44. package/src/features/rates/plugin.js +0 -18
  45. package/src/features/remote-config/api.js +0 -14
  46. package/src/features/remote-config/index.js +0 -28
  47. package/src/features/remote-config/plugin.js +0 -21
  48. package/src/plugins/attach.js +0 -25
  49. package/src/plugins/index.js +0 -5
  50. package/src/plugins/log-lifecycle.js +0 -26
@@ -2,6 +2,10 @@ export const wrapConstant = ({ id, type, value }) => ({
2
2
  definition: { id, type, factory: () => value },
3
3
  })
4
4
 
5
+ export const insertIf = (module, enabled) => {
6
+ return enabled ? [module] : []
7
+ }
8
+
5
9
  export const withType =
6
10
  (type) =>
7
11
  ({ definition, ...rest }) => ({
package/src/index.js CHANGED
@@ -1,121 +1,68 @@
1
- import addressProvider from '@exodus/address-provider'
2
- import { pick } from '@exodus/basic-utils'
3
- import keychain from '@exodus/keychain'
4
- import marketHistory from '@exodus/market-history'
5
- import restoreProgressTracker from '@exodus/restore-progress-tracker'
6
- import wallet from '@exodus/wallet'
7
- import walletAccounts from '@exodus/wallet-accounts'
8
-
9
- import createApi from './api'
10
- import attachAtoms from './atoms/attach'
11
- import { atomsToAttach } from './constants'
12
- import availableAssets from './features/available-assets'
13
- import balances from './features/balances'
14
- import blockchainMetadata from './features/blockchain-metadata'
15
- import enabledAssets from './features/enabled-assets'
16
- import featureFlags from './features/feature-flags'
17
- import fees from './features/fees'
18
- import geolocation from './features/geolocation'
19
- import locale from './features/locale'
20
- import nfts from './features/nfts'
21
- import pricing from './features/pricing'
22
- import rates from './features/rates'
23
- import remoteConfig from './features/remote-config'
24
1
  import createIOC from './ioc'
25
- import attachPlugins from './plugins/attach'
2
+ import createApi from './api'
3
+ import {
4
+ createAccountStatesUpdateHandler,
5
+ createLoadWalletAccountsHandler,
6
+ } from './utils/blockchain-metadata'
26
7
 
27
8
  const createExodus = ({ adapters, config, port }) => {
28
9
  const ioc = createIOC({ adapters, config })
29
- const { headless: headlessConfig } = config
30
-
31
- ioc.use(wallet())
32
- ioc.use(keychain(config.keychain))
33
- ioc.use(walletAccounts())
34
- ioc.use(blockchainMetadata())
35
- ioc.use(availableAssets())
36
- ioc.use(enabledAssets())
37
- ioc.use(balances())
38
- ioc.use(remoteConfig())
39
- ioc.use(geolocation())
40
- ioc.use(marketHistory())
41
- ioc.use(pricing())
42
- ioc.use(fees())
43
- ioc.use(rates())
44
- ioc.use(featureFlags())
45
- ioc.use(locale())
46
- ioc.use(nfts())
47
- ioc.use(addressProvider({ config: config.addressProvider }))
48
- ioc.use(restoreProgressTracker())
49
-
50
- ioc.register({ definition: { id: 'port', type: 'port', factory: () => port } })
51
-
52
10
  const resolve = () => {
53
11
  ioc.resolve()
54
12
 
55
13
  const { assetsModule, storage } = ioc.getByType('adapter')
56
14
 
57
- const { application, wallet, unlockEncryptedStorage } = ioc.getByType('module')
58
-
59
- application.on('start', (payload) => port.emit('start', payload))
60
-
61
- application.on('load', (args) => port.emit('load', args))
15
+ const { application, unlockEncryptedStorage, blockchainMetadata, walletAccounts } =
16
+ ioc.getByType('module')
62
17
 
63
- application.on('create', async ({ hasPassphraseSet }) => {
64
- const isLocked = await wallet.isLocked()
65
-
66
- port.emit('create', {
67
- walletExists: true,
68
- hasPassphraseSet,
69
- isLocked,
70
- isBackedUp: false,
71
- isRestoring: false,
72
- })
18
+ const handleLoadWalletAccounts = createLoadWalletAccountsHandler({
19
+ blockchainMetadata,
20
+ port,
21
+ config,
73
22
  })
74
-
75
- application.on('unlock', () => port.emit('unlock'))
76
-
77
- application.on('lock', () => port.emit('lock'))
78
-
79
- application.on('backup', () => port.emit('backup'))
80
-
81
- application.on('restore', () => port.emit('restore'))
82
-
83
- application.on('restore-completed', () => {
84
- port.emit('restore-completed')
23
+ const handleAccountStatesUpdate = createAccountStatesUpdateHandler({
24
+ blockchainMetadata,
25
+ port,
26
+ config,
85
27
  })
86
28
 
87
- application.on('change-passphrase', () => port.emit('passphrase-changed'))
29
+ blockchainMetadata.on('load-wallet-accounts', handleLoadWalletAccounts)
30
+ blockchainMetadata.on('tx-logs-update', (payload) => port.emit('tx-logs-update', payload))
31
+ blockchainMetadata.on('account-states-update', handleAccountStatesUpdate)
88
32
 
89
- application.on('import', () => port.emit('import', { walletExists: true }))
33
+ application.hook('start', () => {
34
+ port.emit('start')
35
+ })
90
36
 
91
37
  application.hook('unlock', async () => {
92
38
  if (typeof storage.unlock === 'function') unlockEncryptedStorage(storage)
93
39
 
94
40
  await assetsModule.load()
41
+ await walletAccounts.load()
42
+ await blockchainMetadata.load()
95
43
  })
96
44
 
97
- application.hook('clear', async () => {
98
- await assetsModule.clear()
45
+ application.on('unlock', () => {
46
+ port.emit('unlock')
99
47
  })
100
48
 
101
- application.on('clear', () => port.emit('clear'))
102
-
103
- application.on('restart', (payload) => port.emit('restart', payload))
104
-
105
- attachAtoms({
106
- port,
107
- application,
108
- logger: ioc.get('createLogger')('attachAtoms'),
109
- atoms: pick(ioc.getByType('atom'), atomsToAttach),
110
- lifecycleEvents: headlessConfig?.attachAtomsLifecycleEvents,
49
+ application.hook('clear', async () => {
50
+ await Promise.all([
51
+ //
52
+ assetsModule.clear(),
53
+ walletAccounts.clear(),
54
+ blockchainMetadata.clear(),
55
+ ])
56
+
57
+ port.emit('clear')
111
58
  })
112
59
 
113
- attachPlugins({
114
- application,
115
- plugins: ioc.getByType('plugin'),
116
- logger: ioc.get('createLogger')('attachPlugins'),
60
+ application.on('restart', (payload) => {
61
+ port.emit('restart', payload)
117
62
  })
118
63
 
64
+ application.start()
65
+
119
66
  return createApi({ ioc, port })
120
67
  }
121
68
 
package/src/ioc.js CHANGED
@@ -1,56 +1,30 @@
1
1
  import createIocContainer from '@exodus/dependency-injection'
2
2
  import preprocess from '@exodus/dependency-preprocessors'
3
3
  import alias from '@exodus/dependency-preprocessors/src/preprocessors/alias'
4
- import devModeAtoms from '@exodus/dependency-preprocessors/src/preprocessors/dev-mode-atoms'
5
4
  import logify from '@exodus/dependency-preprocessors/src/preprocessors/logify'
6
5
  import namespaceConfig from '@exodus/dependency-preprocessors/src/preprocessors/namespace-config'
7
6
  import namespaceStorage from '@exodus/dependency-preprocessors/src/preprocessors/namespace-storage'
8
- import optional from '@exodus/dependency-preprocessors/src/preprocessors/optional'
9
- import readOnlyAtoms from '@exodus/dependency-preprocessors/src/preprocessors/read-only-atoms'
10
- import assert from 'minimalistic-assert'
11
7
 
12
8
  import createDependencies from './dependencies'
13
9
 
14
10
  const createIOC = ({ adapters, config }) => {
15
11
  const { createLogger } = adapters
16
- const { readOnlyAtoms: readOnlyAtomsConfig, devModeAtoms: devModeAtomsConfig } = config.ioc ?? {}
17
-
18
- const ioc = createIocContainer({ logger: createLogger('exodus:ioc') })
19
12
 
13
+ const logger = createLogger('exodus:ioc')
14
+ const dependencies = createDependencies({ adapters, config })
20
15
  const preprocessors = [
21
16
  logify({ createLogger }),
22
17
  namespaceConfig(),
23
18
  alias(),
24
19
  // NOTE: order matters, this should come after `alias`
25
20
  namespaceStorage(),
26
- readOnlyAtoms({
27
- logger: createLogger('exodus:read-only-atoms'),
28
- warn: true,
29
- ...readOnlyAtomsConfig,
30
- }),
31
- optional(),
32
- ...(devModeAtomsConfig ? [devModeAtoms(devModeAtomsConfig)] : []),
33
21
  ]
22
+ const definitions = preprocess({ dependencies, preprocessors })
23
+ const ioc = createIocContainer({ logger })
34
24
 
35
- const registerMultiple = (dependencies) => {
36
- ioc.registerMultiple(preprocess({ dependencies, preprocessors }))
37
- }
38
-
39
- const register = (dependency) => {
40
- registerMultiple([dependency])
41
- }
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
-
48
- registerMultiple(module.definitions)
49
- }
50
-
51
- registerMultiple(createDependencies({ adapters, config }))
25
+ ioc.registerMultiple(definitions)
52
26
 
53
- return { ...ioc, register, registerMultiple, use }
27
+ return ioc
54
28
  }
55
29
 
56
30
  export default createIOC
@@ -1,4 +1,4 @@
1
- import { EXODUS_KEY_IDS } from '@exodus/keychain/module'
1
+ import { EXODUS_KEY_IDS } from '@exodus/keychain'
2
2
 
3
3
  const createUnlockEncryptedStorage = ({ keychain }) => {
4
4
  return async (encryptedStorage) => {
@@ -12,10 +12,8 @@ const createUnlockEncryptedStorage = ({ keychain }) => {
12
12
  }
13
13
  }
14
14
 
15
- // eslint-disable-next-line @exodus/export-default/named
16
15
  export default {
17
16
  id: 'unlockEncryptedStorage',
18
- type: 'module',
19
17
  factory: createUnlockEncryptedStorage,
20
18
  dependencies: ['keychain'],
21
19
  }
@@ -0,0 +1,48 @@
1
+ import { mapValues } from '@exodus/basic-utils'
2
+
3
+ const createAccountStatesTransformer = ({ serializePortPayloads, blockchainMetadata }) => {
4
+ return serializePortPayloads
5
+ ? (payload) =>
6
+ mapValues(payload, (byAsset, walletAccount) =>
7
+ mapValues(
8
+ byAsset,
9
+ (accountState, assetName) =>
10
+ blockchainMetadata.serializePayload({ walletAccount, assetName, accountState })
11
+ .accountState
12
+ )
13
+ )
14
+ : (payload) => payload
15
+ }
16
+
17
+ export function createAccountStatesUpdateHandler({
18
+ port,
19
+ blockchainMetadata,
20
+ config: { serializePortPayloads = false },
21
+ }) {
22
+ const transform = createAccountStatesTransformer({ serializePortPayloads, blockchainMetadata })
23
+
24
+ return (payload) => {
25
+ port.emit('account-states-update', transform(payload))
26
+ }
27
+ }
28
+
29
+ export function createLoadWalletAccountsHandler({
30
+ port,
31
+ blockchainMetadata,
32
+ config: { serializePortPayloads = false },
33
+ }) {
34
+ const transformAccountStates = createAccountStatesTransformer({
35
+ serializePortPayloads,
36
+ blockchainMetadata,
37
+ })
38
+
39
+ return async () => {
40
+ const [txLogs, accountStates] = await Promise.all([
41
+ blockchainMetadata.getLoadedTxLogs(),
42
+ blockchainMetadata.getLoadedAccountStates(),
43
+ ])
44
+
45
+ port.emit('tx-logs', txLogs)
46
+ port.emit('account-states', transformAccountStates(accountStates))
47
+ }
48
+ }
@@ -1,31 +0,0 @@
1
- const emitAtomValue = async (opts) => {
2
- const { port, atomId, atom } = opts
3
- const value = 'value' in opts ? opts.value : await atom.get()
4
- port.emit(atomId, value)
5
- }
6
-
7
- export const emitFromAtoms = ({ atoms, port }) =>
8
- Object.entries(atoms).forEach(async ([atomId, atom]) => emitAtomValue({ port, atomId, atom }))
9
-
10
- const attachAtom = ({ port, application, logger, atom, atomId, lifecycleEvents }) => {
11
- let loaded = false
12
-
13
- lifecycleEvents.forEach((event) =>
14
- application.on(event, async () => {
15
- loaded = true
16
- await emitAtomValue({ port, atomId, atom })
17
- })
18
- )
19
-
20
- atom.observe((value) => {
21
- if (loaded) emitAtomValue({ port, atomId, atom, value })
22
- })
23
- }
24
-
25
- const attachAtoms = ({ port, application, logger, atoms, lifecycleEvents = ['start'] }) => {
26
- for (const [atomId, atom] of Object.entries(atoms)) {
27
- attachAtom({ port, application, logger, atom, atomId, lifecycleEvents })
28
- }
29
- }
30
-
31
- export default attachAtoms
@@ -1,38 +0,0 @@
1
- import { combine, compute } from '@exodus/atoms'
2
- import { uniq } from 'lodash'
3
-
4
- const getNetworks = (assetNames, assets) =>
5
- uniq(
6
- assetNames
7
- .map((assetName) => assets[assetName]?.baseAsset.name)
8
- .filter((assetName) => !!assetName && !assets[assetName].isCombined)
9
- )
10
-
11
- const createBaseAssetNamesToMonitorAtom = ({
12
- assetsModule,
13
- enabledAssetsAtom,
14
- restoreAtom,
15
- availableAssetNamesAtom,
16
- }) => {
17
- const selector = ({ isRestore, enabledAssets, availableAssetNames }) => {
18
- const assetNames = isRestore ? availableAssetNames : Object.keys(enabledAssets)
19
- return getNetworks(assetNames, assetsModule.getAssets())
20
- }
21
-
22
- return compute({
23
- atom: combine({
24
- isRestore: restoreAtom,
25
- enabledAssets: enabledAssetsAtom,
26
- availableAssetNames: availableAssetNamesAtom,
27
- }),
28
- selector,
29
- })
30
- }
31
-
32
- // eslint-disable-next-line @exodus/export-default/named
33
- export default {
34
- id: 'baseAssetNamesToMonitorAtom',
35
- type: 'atom',
36
- factory: createBaseAssetNamesToMonitorAtom,
37
- dependencies: ['assetsModule', 'availableAssetNamesAtom', 'enabledAssetsAtom', 'restoreAtom'],
38
- }
package/src/constants.js DELETED
@@ -1,38 +0,0 @@
1
- export const atomsToAttach = [
2
- 'abTestingAtom',
3
- 'apyRatesAtom',
4
- 'availableAssetNamesAtom',
5
- 'balancesAtom',
6
- 'connectedOriginsAtom',
7
- 'cryptoNewsAtom',
8
- 'currencyAtom',
9
- 'enabledWalletAccountsAtom',
10
- 'featureFlagsAtom',
11
- 'geolocationAtom',
12
- 'kycAtom',
13
- 'languageAtom',
14
- 'nftsConfigAtom',
15
- 'personalNotesAtom',
16
- 'referralsAtom',
17
- 'topMoversAtom',
18
- 'walletAccountsAtom',
19
- 'restoringAssetsAtom',
20
- ]
21
-
22
- export const LifecycleHook = Object.freeze({
23
- Lock: 'lock',
24
- Unlock: 'unlock',
25
- Clear: 'clear',
26
- Import: 'import',
27
- Migrate: 'migrate',
28
- Start: 'start',
29
- Restart: 'restart',
30
- Load: 'load',
31
- Unload: 'unload',
32
- Create: 'create',
33
- Backup: 'backup',
34
- Restore: 'restore',
35
- RestoreCompleted: 'restore-completed',
36
- AssetsSynced: 'assets-synced',
37
- ChangePassphrase: 'change-passphrase',
38
- })
@@ -1,7 +0,0 @@
1
- import plugins from '../plugins'
2
- import { withType } from './utils'
3
-
4
- const createPluginDependencies = () =>
5
- plugins.map((definition) => ({ definition })).map(withType('plugin'))
6
-
7
- export default createPluginDependencies
@@ -1,15 +0,0 @@
1
- import { availableAssetNamesAtomDefinition } from '@exodus/available-assets/atoms'
2
- import availableAssetsModuleDefinition from '@exodus/available-assets/module'
3
-
4
- const availableAssets = () => ({
5
- id: 'availableAssets',
6
- definitions: [
7
- {
8
- definition: { type: 'module', ...availableAssetsModuleDefinition },
9
- writesAtoms: ['availableAssetNamesAtom'],
10
- },
11
- { definition: availableAssetNamesAtomDefinition },
12
- ],
13
- })
14
-
15
- export default availableAssets
@@ -1,14 +0,0 @@
1
- import { balancesAtomDefinition } from '@exodus/balances/atoms'
2
- import balancesDefinition from '@exodus/balances/module'
3
-
4
- const balances = () => {
5
- return {
6
- id: 'balances',
7
- definitions: [
8
- { definition: balancesDefinition, writesAtoms: ['balancesAtom'] },
9
- { definition: balancesAtomDefinition },
10
- ],
11
- }
12
- }
13
-
14
- export default balances
@@ -1,23 +0,0 @@
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
- // eslint-disable-next-line @exodus/export-default/named
18
- export default {
19
- id: 'createBlockchainMetadataApi',
20
- type: 'api',
21
- factory: createBlockchainMetadataApi,
22
- dependencies: ['blockchainMetadata'],
23
- }
@@ -1,20 +0,0 @@
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
@@ -1,31 +0,0 @@
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
- // eslint-disable-next-line @exodus/export-default/named
26
- export default {
27
- id: 'blockchainLifecyclePlugin',
28
- type: 'plugin',
29
- factory: blockchainLifecyclePlugin,
30
- dependencies: ['blockchainMetadata', 'port'],
31
- }
@@ -1,11 +0,0 @@
1
- export function createLoadWalletAccountsHandler({ port, blockchainMetadata }) {
2
- return async () => {
3
- const [txLogs, accountStates] = await Promise.all([
4
- blockchainMetadata.getLoadedTxLogs(),
5
- blockchainMetadata.getLoadedAccountStates(),
6
- ])
7
-
8
- port.emit('tx-logs', txLogs)
9
- port.emit('account-states', accountStates)
10
- }
11
- }
@@ -1,19 +0,0 @@
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
- // eslint-disable-next-line @exodus/export-default/named
14
- export default {
15
- id: 'enabledAssetsApi',
16
- type: 'api',
17
- factory: enabledAssetsApi,
18
- dependencies: ['enabledAssets', 'assetsModule'],
19
- }
@@ -1,26 +0,0 @@
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
@@ -1,19 +0,0 @@
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
- // eslint-disable-next-line @exodus/export-default/named
14
- export default {
15
- id: 'enabledAssetsLifecyclePlugin',
16
- type: 'plugin',
17
- factory: createEnabledAssetsLifecyclePlugin,
18
- dependencies: ['enabledAssets'],
19
- }
@@ -1,15 +0,0 @@
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
- // eslint-disable-next-line @exodus/export-default/named
10
- export default {
11
- id: 'featureFlagsApi',
12
- type: 'api',
13
- factory: featureFlagsApi,
14
- dependencies: ['featureFlagAtoms'],
15
- }
@@ -1,37 +0,0 @@
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 featureFlagsApiDefinition from './api'
9
- import featureFlagsPluginDefinition from './plugin'
10
-
11
- const featureFlags = () => {
12
- return {
13
- id: 'featureFlags',
14
- definitions: [
15
- {
16
- definition: featureFlagsDefinition,
17
- writesAtoms: ['featureFlagAtoms'],
18
- },
19
- {
20
- definition: featureFlagAtomsDefinition,
21
- storage: { namespace: 'featureFlags' },
22
- aliases: [
23
- {
24
- implementationId: 'unsafeStorage',
25
- interfaceId: 'storage',
26
- },
27
- ],
28
- },
29
- { definition: featureFlagsAtomDefinition },
30
- { definition: remoteConfigFeatureFlagAtomsDefinition },
31
- { definition: featureFlagsPluginDefinition },
32
- { definition: featureFlagsApiDefinition },
33
- ],
34
- }
35
- }
36
-
37
- export default featureFlags