@exodus/headless 2.0.0-alpha.24 → 2.0.0-alpha.26
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 +12 -0
- package/package.json +5 -2
- package/src/api.js +17 -1
- package/src/atoms/base-asset-names-to-monitor.js +21 -0
- package/src/constants.js +1 -0
- package/src/dependencies/atoms.js +13 -0
- package/src/dependencies/modules.js +5 -0
- package/src/dependencies/monitors.js +2 -0
- package/src/index.js +9 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
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.26](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.25...@exodus/headless@2.0.0-alpha.26) (2023-05-30)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- integrate feeMonitors into headless ([#1732](https://github.com/ExodusMovement/exodus-hydra/issues/1732)) ([5a4b9b4](https://github.com/ExodusMovement/exodus-hydra/commit/5a4b9b4e2e7b70ac550775860a3bf5474e21a4d0))
|
|
11
|
+
|
|
12
|
+
## [2.0.0-alpha.25](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.24...@exodus/headless@2.0.0-alpha.25) (2023-05-26)
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
- migrate connected origins to headless ([#1702](https://github.com/ExodusMovement/exodus-hydra/issues/1702)) ([7f6678e](https://github.com/ExodusMovement/exodus-hydra/commit/7f6678eabc5a66dbf11002f021bb700bec3d32f3))
|
|
17
|
+
|
|
6
18
|
## [2.0.0-alpha.24](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/headless@2.0.0-alpha.23...@exodus/headless@2.0.0-alpha.24) (2023-05-26)
|
|
7
19
|
|
|
8
20
|
### Features
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/headless",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.26",
|
|
4
4
|
"description": "The headless Exodus wallet SDK",
|
|
5
5
|
"author": "Exodus Movement Inc",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -33,11 +33,13 @@
|
|
|
33
33
|
"@exodus/basic-utils": "^2.0.0",
|
|
34
34
|
"@exodus/blockchain-metadata": "^8.0.1",
|
|
35
35
|
"@exodus/config": "^7.0.0",
|
|
36
|
+
"@exodus/connected-origins": "^1.1.2",
|
|
36
37
|
"@exodus/dependency-injection": "^1.2.0",
|
|
37
38
|
"@exodus/dependency-preprocessors": "^2.4.0",
|
|
38
39
|
"@exodus/enabled-assets": "^6.0.1",
|
|
39
40
|
"@exodus/exodus-pricing-client": "^1.1.0",
|
|
40
41
|
"@exodus/feature-flags": "^2.0.1",
|
|
42
|
+
"@exodus/fee-monitors": "^1.0.0",
|
|
41
43
|
"@exodus/fetch": "^1.2.1",
|
|
42
44
|
"@exodus/geolocation": "^2.0.0",
|
|
43
45
|
"@exodus/key-identifier-provider": "^1.1.3",
|
|
@@ -59,6 +61,7 @@
|
|
|
59
61
|
"devDependencies": {
|
|
60
62
|
"@exodus/algorand-lib": "^2.0.1",
|
|
61
63
|
"@exodus/algorand-meta": "^1.1.4",
|
|
64
|
+
"@exodus/bitcoin-lib": "^2.2.1",
|
|
62
65
|
"@exodus/bitcoin-meta": "^1.0.0",
|
|
63
66
|
"@exodus/currency": "^2.2.0",
|
|
64
67
|
"@exodus/ethereum-lib": "^2.22.2",
|
|
@@ -78,5 +81,5 @@
|
|
|
78
81
|
"nock": "^13.3.1",
|
|
79
82
|
"p-defer": "^4.0.0"
|
|
80
83
|
},
|
|
81
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "e423fd0fa1cbf41c4af86b6ebe25905cd4cecba0"
|
|
82
85
|
}
|
package/src/api.js
CHANGED
|
@@ -14,15 +14,17 @@ const createApi = ({ ioc, port }) => {
|
|
|
14
14
|
remoteConfig,
|
|
15
15
|
wallet,
|
|
16
16
|
walletAccounts,
|
|
17
|
+
connectedOrigins,
|
|
17
18
|
} = ioc.getByType('module')
|
|
18
19
|
|
|
19
|
-
const { ratesMonitor } = ioc.getByType('monitor')
|
|
20
|
+
const { ratesMonitor, feeMonitors } = ioc.getByType('monitor')
|
|
20
21
|
|
|
21
22
|
const {
|
|
22
23
|
// ...
|
|
23
24
|
currencyAtom,
|
|
24
25
|
enabledWalletAccountsAtom,
|
|
25
26
|
languageAtom,
|
|
27
|
+
connectedOriginsAtom,
|
|
26
28
|
} = ioc.getByType('atom')
|
|
27
29
|
|
|
28
30
|
// TODO: do this on 'unload'
|
|
@@ -30,6 +32,7 @@ const createApi = ({ ioc, port }) => {
|
|
|
30
32
|
kyc.stop()
|
|
31
33
|
referrals.stop()
|
|
32
34
|
remoteConfig.stop()
|
|
35
|
+
feeMonitors.stop()
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
return {
|
|
@@ -115,6 +118,19 @@ const createApi = ({ ioc, port }) => {
|
|
|
115
118
|
subscribe: port.subscribe.bind(port),
|
|
116
119
|
unsubscribe: port.unsubscribe.bind(port),
|
|
117
120
|
stop,
|
|
121
|
+
connectedOrigins: {
|
|
122
|
+
get: connectedOriginsAtom.get,
|
|
123
|
+
add: connectedOrigins.add,
|
|
124
|
+
untrust: connectedOrigins.untrust,
|
|
125
|
+
isTrusted: connectedOrigins.isTrusted,
|
|
126
|
+
isAutoApprove: connectedOrigins.isAutoApprove,
|
|
127
|
+
setFavorite: connectedOrigins.setFavorite,
|
|
128
|
+
setAutoApprove: connectedOrigins.setAutoApprove,
|
|
129
|
+
connect: connectedOrigins.connect,
|
|
130
|
+
disconnect: connectedOrigins.disconnect,
|
|
131
|
+
updateConnection: connectedOrigins.updateConnection,
|
|
132
|
+
clearConnections: connectedOrigins.clearConnections,
|
|
133
|
+
},
|
|
118
134
|
}
|
|
119
135
|
}
|
|
120
136
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { compute } from '@exodus/atoms'
|
|
2
|
+
import { uniq } from 'lodash'
|
|
3
|
+
|
|
4
|
+
const getEnabledNetworks = (enabledAssetsData, assets) => {
|
|
5
|
+
const enabledAssetNames = Object.keys(enabledAssetsData)
|
|
6
|
+
|
|
7
|
+
return uniq(
|
|
8
|
+
enabledAssetNames.map((assetName) => assets[assetName]?.baseAsset.name).filter(Boolean)
|
|
9
|
+
)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const createBaseAssetNamesToMonitorAtom = ({ assetsModule, enabledAssetsAtom }) => {
|
|
13
|
+
const selector = (enabledAssets) => getEnabledNetworks(enabledAssets, assetsModule.getAssets())
|
|
14
|
+
return compute({ atom: enabledAssetsAtom, selector })
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default {
|
|
18
|
+
id: 'baseAssetNamesToMonitorAtom',
|
|
19
|
+
factory: createBaseAssetNamesToMonitorAtom,
|
|
20
|
+
dependencies: ['assetsModule', 'enabledAssetsAtom'],
|
|
21
|
+
}
|
package/src/constants.js
CHANGED
|
@@ -6,6 +6,7 @@ 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 { connectedOriginsAtomDefinition } from '@exodus/connected-origins/atoms'
|
|
9
10
|
import {
|
|
10
11
|
enabledAndDisabledAssetsAtomDefinition,
|
|
11
12
|
enabledAssetsAtomDefinition,
|
|
@@ -21,6 +22,7 @@ import {
|
|
|
21
22
|
walletAccountsAtomDefinition,
|
|
22
23
|
} from '@exodus/wallet-accounts/atoms'
|
|
23
24
|
|
|
25
|
+
import baseAssetNamesToMonitorAtomDefinition from '../atoms/base-asset-names-to-monitor'
|
|
24
26
|
import { withType } from './utils'
|
|
25
27
|
|
|
26
28
|
const createAtomDependencies = () =>
|
|
@@ -144,6 +146,17 @@ const createAtomDependencies = () =>
|
|
|
144
146
|
},
|
|
145
147
|
],
|
|
146
148
|
},
|
|
149
|
+
{
|
|
150
|
+
definition: connectedOriginsAtomDefinition,
|
|
151
|
+
storage: { namespace: 'connectedOrigins' },
|
|
152
|
+
aliases: [
|
|
153
|
+
{
|
|
154
|
+
implementationId: 'unsafeStorage',
|
|
155
|
+
interfaceId: 'storage',
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
},
|
|
159
|
+
{ definition: baseAssetNamesToMonitorAtomDefinition },
|
|
147
160
|
].map(withType('atom'))
|
|
148
161
|
|
|
149
162
|
export default createAtomDependencies
|
|
@@ -5,6 +5,7 @@ import availableAssetsModuleDefinition from '@exodus/available-assets/module'
|
|
|
5
5
|
import balancesDefinition from '@exodus/balances/module'
|
|
6
6
|
import blockchainMetadataDefinition from '@exodus/blockchain-metadata/module'
|
|
7
7
|
import createRemoteConfig from '@exodus/config/remote'
|
|
8
|
+
import connectedOriginsDefinition from '@exodus/connected-origins/module'
|
|
8
9
|
import enabledAssetsModuleDefinition from '@exodus/enabled-assets/module'
|
|
9
10
|
import createExodusPricingClient from '@exodus/exodus-pricing-client'
|
|
10
11
|
import featureFlagsDefinition from '@exodus/feature-flags/module'
|
|
@@ -130,6 +131,10 @@ const createModuleDependencies = ({ config }) =>
|
|
|
130
131
|
{
|
|
131
132
|
definition: personalNotesDefinition,
|
|
132
133
|
},
|
|
134
|
+
{
|
|
135
|
+
definition: connectedOriginsDefinition,
|
|
136
|
+
writesAtoms: ['connectedOriginsAtom'],
|
|
137
|
+
},
|
|
133
138
|
].map(withType('module'))
|
|
134
139
|
|
|
135
140
|
export default createModuleDependencies
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import feeMonitorsDefinition from '@exodus/fee-monitors/monitor'
|
|
1
2
|
import geolocationMonitorDefinition from '@exodus/geolocation/monitor'
|
|
2
3
|
import marketHistoryMonitorDefinition from '@exodus/market-history/module'
|
|
3
4
|
import ratesMonitorDefinition from '@exodus/rates-monitor/module'
|
|
@@ -33,6 +34,7 @@ const createMonitorDependencies = () =>
|
|
|
33
34
|
],
|
|
34
35
|
},
|
|
35
36
|
{ definition: ratesMonitorDefinition, writesAtoms: ['ratesAtom'] },
|
|
37
|
+
{ definition: feeMonitorsDefinition },
|
|
36
38
|
].map(withType('monitor'))
|
|
37
39
|
|
|
38
40
|
export default createMonitorDependencies
|
package/src/index.js
CHANGED
|
@@ -29,9 +29,11 @@ const createExodus = ({ adapters, config, port }) => {
|
|
|
29
29
|
remoteConfig,
|
|
30
30
|
unlockEncryptedStorage,
|
|
31
31
|
walletAccounts,
|
|
32
|
+
connectedOrigins,
|
|
32
33
|
} = ioc.getByType('module')
|
|
33
34
|
|
|
34
|
-
const { geolocationMonitor, marketHistory, ratesMonitor } =
|
|
35
|
+
const { geolocationMonitor, marketHistory, ratesMonitor, feeMonitors } =
|
|
36
|
+
ioc.getByType('monitor')
|
|
35
37
|
|
|
36
38
|
const { featureFlagAtoms } = ioc.getByType('atom-collection')
|
|
37
39
|
|
|
@@ -46,6 +48,9 @@ const createExodus = ({ adapters, config, port }) => {
|
|
|
46
48
|
port.emit('account-states-update', payload)
|
|
47
49
|
)
|
|
48
50
|
|
|
51
|
+
feeMonitors.on('fees-load', () => port.emit('fees-load', feeMonitors.getAllFeeData()))
|
|
52
|
+
feeMonitors.on('fees-update', (payload) => port.emit('fees-update', payload))
|
|
53
|
+
|
|
49
54
|
remoteConfig.on('sync', ({ current }) => port.emit('remote-config', current))
|
|
50
55
|
|
|
51
56
|
// TODO: migrate to marketHistoryAtom. Will be easier once it's on headless
|
|
@@ -71,8 +76,10 @@ const createExodus = ({ adapters, config, port }) => {
|
|
|
71
76
|
remoteConfig.sync()
|
|
72
77
|
marketHistory.start()
|
|
73
78
|
ratesMonitor.start()
|
|
79
|
+
feeMonitors.start()
|
|
74
80
|
|
|
75
81
|
await assetsModule.load()
|
|
82
|
+
await connectedOrigins.load()
|
|
76
83
|
await walletAccounts.load()
|
|
77
84
|
await Promise.all([
|
|
78
85
|
//
|
|
@@ -98,6 +105,7 @@ const createExodus = ({ adapters, config, port }) => {
|
|
|
98
105
|
walletAccounts.clear(),
|
|
99
106
|
blockchainMetadata.clear(),
|
|
100
107
|
enabledAssets.clear(),
|
|
108
|
+
connectedOrigins.clear(),
|
|
101
109
|
])
|
|
102
110
|
|
|
103
111
|
// TEMP: dont wait for set to complete as encrypted storage is not yet unlocked
|