@exodus/headless 2.0.0-alpha.6 → 2.0.0-alpha.60
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 +423 -0
- package/README.md +133 -4
- package/package.json +54 -17
- package/src/api.js +11 -31
- package/src/application.js +54 -39
- package/src/atoms/attach.js +31 -0
- package/src/atoms/base-asset-names-to-monitor.js +37 -0
- package/src/constants.js +37 -0
- package/src/dependencies/atoms.js +2 -21
- package/src/dependencies/index.js +8 -1
- package/src/dependencies/modules.js +2 -16
- package/src/dependencies/plugins.js +7 -0
- package/src/dependencies/utils.js +0 -4
- package/src/features/available-assets/index.js +15 -0
- package/src/features/balances/index.js +14 -0
- package/src/features/blockchain-metadata/api.js +22 -0
- package/src/features/blockchain-metadata/index.js +20 -0
- package/src/features/blockchain-metadata/plugin.js +30 -0
- package/src/features/blockchain-metadata/utils.js +11 -0
- package/src/features/enabled-assets/api.js +18 -0
- package/src/features/enabled-assets/index.js +26 -0
- package/src/features/enabled-assets/plugin.js +18 -0
- package/src/features/feature-flags/api.js +14 -0
- package/src/features/feature-flags/index.js +37 -0
- package/src/features/feature-flags/plugin.js +18 -0
- package/src/features/fees/index.js +16 -0
- package/src/features/fees/plugin.js +17 -0
- package/src/features/fiat-balances/index.js +10 -0
- package/src/features/fiat-balances/non-dust-balance-asset-names-atom.js +10 -0
- package/src/features/geolocation/index.js +20 -0
- package/src/features/geolocation/plugin.js +14 -0
- package/src/features/locale/api.js +13 -0
- package/src/features/locale/index.js +50 -0
- package/src/features/locale/plugin.js +14 -0
- package/src/features/market-history/index.js +66 -0
- package/src/features/market-history/plugin.js +21 -0
- package/src/features/nfts/api.js +13 -0
- package/src/features/nfts/index.js +33 -0
- package/src/features/nfts/plugin.js +23 -0
- package/src/features/pricing/api.js +14 -0
- package/src/features/pricing/index.js +35 -0
- package/src/features/rates/api.js +12 -0
- package/src/features/rates/index.js +22 -0
- package/src/features/rates/plugin.js +17 -0
- package/src/features/remote-config/api.js +13 -0
- package/src/features/remote-config/index.js +28 -0
- package/src/features/remote-config/plugin.js +20 -0
- package/src/features/wallet/api.js +34 -0
- package/src/features/wallet/index.js +24 -0
- package/src/features/wallet/locked-atom.js +10 -0
- package/src/features/wallet/restore-atom.js +10 -0
- package/src/features/wallet/restore-plugin.js +17 -0
- package/src/features/wallet-accounts/api.js +16 -0
- package/src/features/wallet-accounts/index.js +29 -0
- package/src/features/wallet-accounts/plugin.js +18 -0
- package/src/index.js +102 -18
- package/src/ioc.js +40 -7
- package/src/plugins/attach.js +25 -0
- package/src/plugins/index.js +5 -0
- package/src/plugins/log-lifecycle.js +26 -0
- package/src/unlock-encrypted-storage.js +1 -1
|
@@ -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,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,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
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const localePlugin = ({ languageAtom }) => {
|
|
2
|
+
const onClear = async () => {
|
|
3
|
+
await languageAtom.set(undefined)
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
return { onClear }
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
id: 'localeLifecyclePlugin',
|
|
11
|
+
type: 'plugin',
|
|
12
|
+
factory: localePlugin,
|
|
13
|
+
dependencies: ['languageAtom'],
|
|
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,13 @@
|
|
|
1
|
+
const createNftsApi = ({ nfts, nftsMonitor }) => ({
|
|
2
|
+
nfts: {
|
|
3
|
+
upsertConfig: nfts.upsertConfig,
|
|
4
|
+
setMonitorInterval: nftsMonitor.setInterval,
|
|
5
|
+
},
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
id: 'createNftsApi',
|
|
10
|
+
type: 'api',
|
|
11
|
+
factory: createNftsApi,
|
|
12
|
+
dependencies: ['nfts', 'nftsMonitor'],
|
|
13
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { nftsCacheAtomDefinition, nftsConfigsAtomDefinition } from '@exodus/nfts/atoms'
|
|
2
|
+
import nftsModuleDefinition from '@exodus/nfts/module'
|
|
3
|
+
import nftsMonitorDefinition from '@exodus/nfts/monitor'
|
|
4
|
+
|
|
5
|
+
import nftsApiDefinition from './api'
|
|
6
|
+
import nftsPluginDefinition from './plugin'
|
|
7
|
+
|
|
8
|
+
// TODO: Add type to module definitions
|
|
9
|
+
const nfts = () => {
|
|
10
|
+
return {
|
|
11
|
+
id: 'nfts',
|
|
12
|
+
definitions: [
|
|
13
|
+
{
|
|
14
|
+
definition: { type: 'atom', ...nftsCacheAtomDefinition },
|
|
15
|
+
storage: { namespace: 'nftsCache' },
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
definition: { type: 'atom', ...nftsConfigsAtomDefinition },
|
|
19
|
+
aliases: [{ implementationId: 'unsafeStorage', interfaceId: 'storage' }],
|
|
20
|
+
storage: { namespace: 'nfts-config' },
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
definition: { type: 'monitor', ...nftsMonitorDefinition },
|
|
24
|
+
writesAtoms: ['nftsCacheAtom'],
|
|
25
|
+
},
|
|
26
|
+
{ definition: nftsModuleDefinition, writesAtoms: ['nftsCacheAtom', 'nftsConfigAtom'] },
|
|
27
|
+
{ definition: nftsPluginDefinition },
|
|
28
|
+
{ definition: nftsApiDefinition },
|
|
29
|
+
],
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default nfts
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const nftsLifecyclePlugin = ({ nfts, nftsMonitor, port }) => {
|
|
2
|
+
// TODO: Move to onStart, but needs testing first
|
|
3
|
+
nftsMonitor.on('nfts', (data) => port.emit('nfts', data))
|
|
4
|
+
nftsMonitor.on('nfts-txs', (data) => port.emit('nfts-txs', data))
|
|
5
|
+
|
|
6
|
+
const onUnlock = () => {
|
|
7
|
+
nfts.load()
|
|
8
|
+
nftsMonitor.start()
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const onClear = () => {
|
|
12
|
+
nfts.clear()
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return { onUnlock, onClear }
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
id: 'nftsLifecyclePlugin',
|
|
20
|
+
type: 'plugin',
|
|
21
|
+
factory: nftsLifecyclePlugin,
|
|
22
|
+
dependencies: ['nfts', 'nftsMonitor', 'port'],
|
|
23
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const pricingApi = ({ pricingClient }) => ({
|
|
2
|
+
pricing: {
|
|
3
|
+
currentPrice: pricingClient.currentPrice,
|
|
4
|
+
historicalPrice: pricingClient.historicalPrice,
|
|
5
|
+
ticker: pricingClient.ticker,
|
|
6
|
+
},
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
id: 'pricingApi',
|
|
11
|
+
type: 'api',
|
|
12
|
+
factory: pricingApi,
|
|
13
|
+
dependencies: ['pricingClient'],
|
|
14
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createRemoteConfigAtomFactory } from '@exodus/atoms'
|
|
2
|
+
import createExodusPricingClient from '@exodus/exodus-pricing-client'
|
|
3
|
+
|
|
4
|
+
import pricingApi from './api'
|
|
5
|
+
|
|
6
|
+
const pricing = () => {
|
|
7
|
+
return {
|
|
8
|
+
id: 'pricing',
|
|
9
|
+
definitions: [
|
|
10
|
+
{
|
|
11
|
+
definition: {
|
|
12
|
+
id: 'pricingClient',
|
|
13
|
+
type: 'module',
|
|
14
|
+
factory: createExodusPricingClient,
|
|
15
|
+
dependencies: ['fetch', 'pricingServerUrlAtom'],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
definition: {
|
|
20
|
+
id: 'pricingServerUrlAtom',
|
|
21
|
+
type: 'atom',
|
|
22
|
+
factory: ({ config, remoteConfig }) =>
|
|
23
|
+
createRemoteConfigAtomFactory({ remoteConfig })({
|
|
24
|
+
path: config.pricingServerPath,
|
|
25
|
+
defaultValue: config.defaultPricingServerUrl,
|
|
26
|
+
}),
|
|
27
|
+
dependencies: ['config', 'remoteConfig'],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{ definition: pricingApi },
|
|
31
|
+
],
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default pricing
|
|
@@ -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,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
|
+
}
|