@exodus/headless 2.0.0-alpha.5 → 2.0.0-alpha.51

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 (82) hide show
  1. package/CHANGELOG.md +351 -0
  2. package/README.md +133 -4
  3. package/package.json +53 -14
  4. package/src/api.js +11 -23
  5. package/src/application.js +44 -34
  6. package/src/atoms/attach.js +31 -0
  7. package/src/atoms/base-asset-names-to-monitor.js +36 -0
  8. package/src/constants.js +36 -0
  9. package/src/dependencies/atoms.js +21 -4
  10. package/src/dependencies/index.js +8 -1
  11. package/src/dependencies/modules.js +6 -12
  12. package/src/dependencies/plugins.js +7 -0
  13. package/src/index.js +76 -5
  14. package/src/ioc.js +40 -7
  15. package/src/modules/ab-testing/api.js +13 -0
  16. package/src/modules/ab-testing/index.js +26 -0
  17. package/src/modules/ab-testing/plugin.js +21 -0
  18. package/src/modules/address-provider/api.js +14 -0
  19. package/src/modules/address-provider/index.js +15 -0
  20. package/src/modules/apy-rates/index.js +20 -0
  21. package/src/modules/apy-rates/plugin.js +14 -0
  22. package/src/modules/balances/index.js +14 -0
  23. package/src/modules/blockchain-metadata/api.js +22 -0
  24. package/src/modules/blockchain-metadata/index.js +20 -0
  25. package/src/modules/blockchain-metadata/plugin.js +30 -0
  26. package/src/modules/blockchain-metadata/utils.js +11 -0
  27. package/src/modules/connected-origins/api.js +23 -0
  28. package/src/modules/connected-origins/index.js +31 -0
  29. package/src/modules/connected-origins/plugin.js +18 -0
  30. package/src/modules/crypto-news/index.js +20 -0
  31. package/src/modules/crypto-news/plugin.js +17 -0
  32. package/src/modules/enabled-assets/api.js +18 -0
  33. package/src/modules/enabled-assets/index.js +26 -0
  34. package/src/modules/enabled-assets/plugin.js +18 -0
  35. package/src/modules/feature-flags/api.js +14 -0
  36. package/src/modules/feature-flags/index.js +37 -0
  37. package/src/modules/feature-flags/plugin.js +18 -0
  38. package/src/modules/fees/index.js +16 -0
  39. package/src/modules/fees/plugin.js +17 -0
  40. package/src/modules/fiat-balances/index.js +10 -0
  41. package/src/modules/fiat-balances/non-dust-balance-asset-names-atom.js +10 -0
  42. package/src/modules/geolocation/index.js +20 -0
  43. package/src/modules/geolocation/plugin.js +14 -0
  44. package/src/modules/kyc/api.js +14 -0
  45. package/src/modules/kyc/index.js +19 -0
  46. package/src/modules/kyc/plugin.js +21 -0
  47. package/src/modules/locale/api.js +13 -0
  48. package/src/modules/locale/index.js +50 -0
  49. package/src/modules/locale/plugin.js +14 -0
  50. package/src/modules/market-history/index.js +66 -0
  51. package/src/modules/market-history/plugin.js +21 -0
  52. package/src/modules/nfts/api.js +13 -0
  53. package/src/modules/nfts/index.js +33 -0
  54. package/src/modules/nfts/plugin.js +23 -0
  55. package/src/modules/personal-notes/api.js +12 -0
  56. package/src/modules/personal-notes/index.js +31 -0
  57. package/src/modules/personal-notes/plugin.js +15 -0
  58. package/src/modules/pricing/api.js +14 -0
  59. package/src/modules/pricing/index.js +35 -0
  60. package/src/modules/rates/api.js +12 -0
  61. package/src/modules/rates/index.js +22 -0
  62. package/src/modules/rates/plugin.js +17 -0
  63. package/src/modules/referrals/api.js +13 -0
  64. package/src/modules/referrals/index.js +28 -0
  65. package/src/modules/referrals/plugin.js +21 -0
  66. package/src/modules/remote-config/api.js +13 -0
  67. package/src/modules/remote-config/index.js +28 -0
  68. package/src/modules/remote-config/plugin.js +20 -0
  69. package/src/modules/top-movers/index.js +23 -0
  70. package/src/modules/top-movers/plugin.js +17 -0
  71. package/src/modules/wallet/api.js +34 -0
  72. package/src/modules/wallet/index.js +24 -0
  73. package/src/modules/wallet/locked-atom.js +10 -0
  74. package/src/modules/wallet/restore-atom.js +10 -0
  75. package/src/modules/wallet/restore-plugin.js +17 -0
  76. package/src/modules/wallet-accounts/api.js +16 -0
  77. package/src/modules/wallet-accounts/index.js +29 -0
  78. package/src/modules/wallet-accounts/plugin.js +18 -0
  79. package/src/plugins/attach.js +25 -0
  80. package/src/plugins/index.js +5 -0
  81. package/src/plugins/log-lifecycle.js +25 -0
  82. package/src/unlock-encrypted-storage.js +1 -1
@@ -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,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,14 @@
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
@@ -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,11 @@
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
+ }
@@ -0,0 +1,23 @@
1
+ const connectedOriginsApi = ({ connectedOrigins, connectedOriginsAtom }) => ({
2
+ connectedOrigins: {
3
+ get: connectedOriginsAtom.get,
4
+ add: connectedOrigins.add,
5
+ clear: connectedOrigins.clear,
6
+ untrust: connectedOrigins.untrust,
7
+ isTrusted: connectedOrigins.isTrusted,
8
+ isAutoApprove: connectedOrigins.isAutoApprove,
9
+ setFavorite: connectedOrigins.setFavorite,
10
+ setAutoApprove: connectedOrigins.setAutoApprove,
11
+ connect: connectedOrigins.connect,
12
+ disconnect: connectedOrigins.disconnect,
13
+ updateConnection: connectedOrigins.updateConnection,
14
+ clearConnections: connectedOrigins.clearConnections,
15
+ },
16
+ })
17
+
18
+ export default {
19
+ id: 'connectedOriginsApi',
20
+ type: 'api',
21
+ factory: connectedOriginsApi,
22
+ dependencies: ['connectedOrigins', 'connectedOriginsAtom'],
23
+ }
@@ -0,0 +1,31 @@
1
+ import { connectedOriginsAtomDefinition } from '@exodus/connected-origins/atoms'
2
+ import connectedOriginsDefinition from '@exodus/connected-origins/module'
3
+
4
+ import connectedOriginsApiDefinition from './api'
5
+ import connectedOriginsPluginDefinition from './plugin'
6
+
7
+ const connectedOrigins = () => {
8
+ return {
9
+ id: 'connectedOrigins',
10
+ definitions: [
11
+ {
12
+ definition: connectedOriginsAtomDefinition,
13
+ storage: { namespace: 'connectedOrigins' },
14
+ aliases: [
15
+ {
16
+ implementationId: 'unsafeStorage',
17
+ interfaceId: 'storage',
18
+ },
19
+ ],
20
+ },
21
+ {
22
+ definition: connectedOriginsDefinition,
23
+ writesAtoms: ['connectedOriginsAtom'],
24
+ },
25
+ { definition: connectedOriginsPluginDefinition },
26
+ { definition: connectedOriginsApiDefinition },
27
+ ],
28
+ }
29
+ }
30
+
31
+ export default connectedOrigins
@@ -0,0 +1,18 @@
1
+ const connectedOriginsPlugin = ({ connectedOrigins }) => {
2
+ const onUnlock = async () => {
3
+ await connectedOrigins.load()
4
+ }
5
+
6
+ const onClear = async () => {
7
+ await connectedOrigins.clear()
8
+ }
9
+
10
+ return { onUnlock, onClear }
11
+ }
12
+
13
+ export default {
14
+ id: 'connectedOriginsLifecyclePlugin',
15
+ type: 'plugin',
16
+ factory: connectedOriginsPlugin,
17
+ dependencies: ['connectedOrigins'],
18
+ }
@@ -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,18 @@
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
+ export default {
14
+ id: 'enabledAssetsApi',
15
+ type: 'api',
16
+ factory: enabledAssetsApi,
17
+ dependencies: ['enabledAssets', 'assetsModule'],
18
+ }
@@ -0,0 +1,26 @@
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
@@ -0,0 +1,18 @@
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
+ export default {
14
+ id: 'enabledAssetsLifecyclePlugin',
15
+ type: 'plugin',
16
+ factory: createEnabledAssetsLifecyclePlugin,
17
+ dependencies: ['enabledAssets'],
18
+ }
@@ -0,0 +1,14 @@
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
+ export default {
10
+ id: 'featureFlagsApi',
11
+ type: 'api',
12
+ factory: featureFlagsApi,
13
+ dependencies: ['featureFlagAtoms'],
14
+ }
@@ -0,0 +1,37 @@
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
@@ -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,10 @@
1
+ import nonDustBalanceAssetNamesAtomDefinition from './non-dust-balance-asset-names-atom'
2
+
3
+ const fiatBalances = () => {
4
+ return {
5
+ id: 'fiatBalances',
6
+ definitions: [{ definition: nonDustBalanceAssetNamesAtomDefinition }],
7
+ }
8
+ }
9
+
10
+ export default fiatBalances
@@ -0,0 +1,10 @@
1
+ import { createInMemoryAtom } from '@exodus/atoms'
2
+
3
+ const nonDustBalanceAssetNamesAtomDefinition = {
4
+ id: 'nonDustBalanceAssetNamesAtom',
5
+ type: 'atom',
6
+ factory: () => createInMemoryAtom({ defaultValue: [] }),
7
+ dependencies: [],
8
+ }
9
+
10
+ export default nonDustBalanceAssetNamesAtomDefinition
@@ -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,14 @@
1
+ const kycApi = ({ kyc }) => ({
2
+ kyc: {
3
+ start: kyc.start,
4
+ sync: kyc.sync,
5
+ requestKycToken: kyc.requestKycToken,
6
+ },
7
+ })
8
+
9
+ export default {
10
+ id: 'kycApi',
11
+ type: 'api',
12
+ factory: kycApi,
13
+ dependencies: ['kyc'],
14
+ }
@@ -0,0 +1,19 @@
1
+ import { kycAtomDefinition } from '@exodus/kyc/atoms'
2
+ import kycDefinition from '@exodus/kyc/module'
3
+
4
+ import kycApi from './api'
5
+ import kycPlugin from './plugin'
6
+
7
+ const kyc = () => {
8
+ return {
9
+ id: 'kyc',
10
+ definitions: [
11
+ { definition: kycAtomDefinition },
12
+ { definition: kycDefinition, writesAtoms: ['kycAtom'] },
13
+ { definition: kycPlugin },
14
+ { definition: kycApi },
15
+ ],
16
+ }
17
+ }
18
+
19
+ export default kyc
@@ -0,0 +1,21 @@
1
+ const kycPlugin = ({ kyc, featureFlagAtoms }) => {
2
+ const onUnlock = () => {
3
+ featureFlagAtoms.referrals?.get().then(({ isOn }) => {
4
+ if (!isOn) return
5
+ kyc.load()
6
+ })
7
+ }
8
+
9
+ const onUnload = () => {
10
+ kyc.stop()
11
+ }
12
+
13
+ return { onUnlock, onUnload }
14
+ }
15
+
16
+ export default {
17
+ id: 'kycLifecyclePlugin',
18
+ type: 'plugin',
19
+ factory: kycPlugin,
20
+ dependencies: ['kyc', 'featureFlagAtoms'],
21
+ }
@@ -0,0 +1,13 @@
1
+ const localeApi = ({ languageAtom, currencyAtom }) => ({
2
+ locale: {
3
+ setLanguage: (value) => languageAtom.set(value),
4
+ setCurrency: (value) => currencyAtom.set(value),
5
+ },
6
+ })
7
+
8
+ export default {
9
+ id: 'localeApi',
10
+ type: 'api',
11
+ factory: localeApi,
12
+ dependencies: ['languageAtom', 'currencyAtom'],
13
+ }
@@ -0,0 +1,50 @@
1
+ import { createStorageAtomFactory } from '@exodus/atoms'
2
+ import { createFusionAtom } from '@exodus/fusion/atoms'
3
+
4
+ import localeApiDefinition from './api'
5
+ import localePluginDefinition from './plugin'
6
+
7
+ const locale = () => {
8
+ return {
9
+ id: 'locale',
10
+ definitions: [
11
+ {
12
+ definition: {
13
+ id: 'currencyAtom',
14
+ type: 'atom',
15
+ factory: ({ fusion, config }) =>
16
+ createFusionAtom({
17
+ fusion,
18
+ path: `private.currency`,
19
+ defaultValue: config.defaultValue,
20
+ }),
21
+ dependencies: ['fusion', 'config'],
22
+ },
23
+ },
24
+ {
25
+ definition: {
26
+ id: 'languageAtom',
27
+ type: 'atom',
28
+ factory: ({ storage, config }) =>
29
+ createStorageAtomFactory({ storage })({
30
+ key: 'language',
31
+ defaultValue: config.defaultValue,
32
+ isSoleWriter: true,
33
+ }),
34
+ dependencies: ['storage', 'config'],
35
+ },
36
+ aliases: [
37
+ {
38
+ implementationId: 'unsafeStorage',
39
+ interfaceId: 'storage',
40
+ },
41
+ ],
42
+ storage: { namespace: 'locale' },
43
+ },
44
+ { definition: localePluginDefinition, writesAtoms: ['languageAtom'] },
45
+ { definition: localeApiDefinition, writesAtoms: ['languageAtom', 'currencyAtom'] },
46
+ ],
47
+ }
48
+ }
49
+
50
+ export default locale