@exodus/fiat-balances 8.0.0 → 9.1.0
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 +20 -0
- package/module/fiat-balances.js +8 -3
- package/package.json +7 -7
- package/plugin/index.js +34 -12
- package/redux/index.js +2 -2
- package/redux/selectors/byWalletAccount.js +15 -0
- package/redux/selectors/byWalletAccountField.js +12 -0
- package/redux/selectors/index.js +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,26 @@
|
|
|
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
|
+
## [9.1.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@9.0.0...@exodus/fiat-balances@9.1.0) (2023-09-13)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- add more selectors for fiat-balances ([#4018](https://github.com/ExodusMovement/exodus-hydra/issues/4018)) ([f4ccc17](https://github.com/ExodusMovement/exodus-hydra/commit/f4ccc17b433ce3a43c47c06aa9aa076f874b589b))
|
|
11
|
+
|
|
12
|
+
## [9.0.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@8.0.0...@exodus/fiat-balances@9.0.0) (2023-08-31)
|
|
13
|
+
|
|
14
|
+
### ⚠ BREAKING CHANGES
|
|
15
|
+
|
|
16
|
+
- emit fiat balances from plugin (#3800)
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
- emit fiat balances from plugin ([#3800](https://github.com/ExodusMovement/exodus-hydra/issues/3800)) ([a65b208](https://github.com/ExodusMovement/exodus-hydra/commit/a65b208ddd7125a6a88e1cbc6c88f50322d39f2f))
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
- clone data ([#3794](https://github.com/ExodusMovement/exodus-hydra/issues/3794)) ([1726b0d](https://github.com/ExodusMovement/exodus-hydra/commit/1726b0db2558953f17ad1eb2b35820c1f1dc809a))
|
|
25
|
+
|
|
6
26
|
## [8.0.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@7.1.0...@exodus/fiat-balances@8.0.0) (2023-08-25)
|
|
7
27
|
|
|
8
28
|
### ⚠ BREAKING CHANGES
|
package/module/fiat-balances.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { conversionByRate } from '@exodus/currency'
|
|
1
|
+
import { conversionByRate, isNumberUnit } from '@exodus/currency'
|
|
2
2
|
import ExodusModule from '@exodus/module'
|
|
3
|
-
import { isEqual, set } from 'lodash'
|
|
3
|
+
import { cloneDeepWith, isEqual, set } from 'lodash'
|
|
4
4
|
import fiatCurrencies from '@exodus/fiat-currencies'
|
|
5
5
|
import { combine } from '@exodus/atoms'
|
|
6
6
|
|
|
@@ -9,6 +9,11 @@ const areKeysSame = (a, b) => isEqual(Object.keys(a).sort(), Object.keys(b).sort
|
|
|
9
9
|
|
|
10
10
|
const MODULE_ID = 'fiatBalances'
|
|
11
11
|
|
|
12
|
+
const cloneBalances = (balances) =>
|
|
13
|
+
cloneDeepWith(balances, (val) => {
|
|
14
|
+
if (isNumberUnit(val)) return val
|
|
15
|
+
})
|
|
16
|
+
|
|
12
17
|
class FiatBalances extends ExodusModule {
|
|
13
18
|
#assetsModule
|
|
14
19
|
#balanceFields
|
|
@@ -232,7 +237,7 @@ class FiatBalances extends ExodusModule {
|
|
|
232
237
|
|
|
233
238
|
#flush = () => {
|
|
234
239
|
this._logger.log('fiat balances updated')
|
|
235
|
-
const data = { balances: this.#balances }
|
|
240
|
+
const data = cloneBalances({ balances: this.#balances })
|
|
236
241
|
this.#fiatBalancesAtom.set((current) => (isEqual(current, data) ? current : data))
|
|
237
242
|
}
|
|
238
243
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/fiat-balances",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.1.0",
|
|
4
4
|
"description": "Track asset and portfolio fiat balances based on changes in crypto balances and the user's preferred fiat currency",
|
|
5
5
|
"author": "Exodus Movement Inc.",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -35,19 +35,19 @@
|
|
|
35
35
|
"reselect": "^3.0.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@exodus/atoms": "^5.
|
|
39
|
-
"@exodus/balances": "^
|
|
38
|
+
"@exodus/atoms": "^5.7.0",
|
|
39
|
+
"@exodus/balances": "^11.0.2",
|
|
40
40
|
"@exodus/basic-utils": "^2.0.0",
|
|
41
41
|
"@exodus/blockchain-metadata": "*",
|
|
42
|
-
"@exodus/enabled-assets": "^
|
|
42
|
+
"@exodus/enabled-assets": "^9.0.1",
|
|
43
43
|
"@exodus/models": "^8.9.0",
|
|
44
|
-
"@exodus/redux-dependency-injection": "^
|
|
45
|
-
"@exodus/storage-memory": "^2.1.
|
|
44
|
+
"@exodus/redux-dependency-injection": "^3.0.0",
|
|
45
|
+
"@exodus/storage-memory": "^2.1.1",
|
|
46
46
|
"@exodus/wallet-accounts": "*",
|
|
47
47
|
"eslint": "^8.44.0",
|
|
48
48
|
"events": "^3.3.0",
|
|
49
49
|
"jest": "^29.1.2",
|
|
50
50
|
"redux": "^4.2.1"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "09e675f8a93be57b1e718db0a2af00477340875e"
|
|
53
53
|
}
|
package/plugin/index.js
CHANGED
|
@@ -1,21 +1,43 @@
|
|
|
1
|
+
import createAtomObserver from '@exodus/atoms/src/factories/observer'
|
|
2
|
+
|
|
1
3
|
const createFiatBalancesPlugin = ({
|
|
2
4
|
port,
|
|
3
5
|
fiatBalancesAtom,
|
|
4
6
|
optimisticFiatBalancesAtom,
|
|
5
7
|
fiatBalances,
|
|
6
8
|
optimisticFiatBalances,
|
|
7
|
-
}) =>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
})
|
|
9
|
+
}) => {
|
|
10
|
+
const fiatBalancesAtomObserver = createAtomObserver({
|
|
11
|
+
port,
|
|
12
|
+
atom: fiatBalancesAtom,
|
|
13
|
+
event: 'fiatBalances',
|
|
14
|
+
})
|
|
15
|
+
const optimisticFiatBalancesAtomObserver = optimisticFiatBalancesAtom
|
|
16
|
+
? createAtomObserver({
|
|
17
|
+
port,
|
|
18
|
+
atom: optimisticFiatBalancesAtom,
|
|
19
|
+
event: 'optimisticFiatBalances',
|
|
20
|
+
})
|
|
21
|
+
: null
|
|
22
|
+
fiatBalancesAtomObserver.register()
|
|
23
|
+
optimisticFiatBalancesAtomObserver?.register()
|
|
24
|
+
return {
|
|
25
|
+
onStart: () => {
|
|
26
|
+
fiatBalances.load()
|
|
27
|
+
optimisticFiatBalances?.load()
|
|
28
|
+
fiatBalancesAtomObserver.start()
|
|
29
|
+
optimisticFiatBalancesAtomObserver?.start()
|
|
30
|
+
},
|
|
31
|
+
onLoad: () => {
|
|
32
|
+
fiatBalancesAtomObserver.start()
|
|
33
|
+
optimisticFiatBalancesAtomObserver?.start()
|
|
34
|
+
},
|
|
35
|
+
onStop: () => {
|
|
36
|
+
fiatBalancesAtomObserver.unregister()
|
|
37
|
+
optimisticFiatBalancesAtomObserver?.unregister()
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
}
|
|
19
41
|
|
|
20
42
|
const fiatBalancesPluginDefinition = {
|
|
21
43
|
id: 'fiatBalancesPlugin',
|
package/redux/index.js
CHANGED
|
@@ -33,7 +33,7 @@ const createFiatBalancesReduxDefinition = ({ optimisticActivityEnabled }) => ({
|
|
|
33
33
|
type: 'redux-module',
|
|
34
34
|
initialState,
|
|
35
35
|
eventReducers: {
|
|
36
|
-
|
|
36
|
+
fiatBalances: (state, { balances }) => {
|
|
37
37
|
const data = prepareData({ state, payload: balances })
|
|
38
38
|
|
|
39
39
|
return {
|
|
@@ -43,7 +43,7 @@ const createFiatBalancesReduxDefinition = ({ optimisticActivityEnabled }) => ({
|
|
|
43
43
|
optimisticData: optimisticActivityEnabled ? state.optimisticData : data,
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
|
|
46
|
+
optimisticFiatBalances: (state, { balances }) => ({
|
|
47
47
|
...state,
|
|
48
48
|
optimisticData: prepareData({ state, payload: balances }),
|
|
49
49
|
}),
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { mapValues } from '@exodus/basic-utils'
|
|
2
|
+
|
|
3
|
+
const resultFunction = (balancesByWalletAccount) =>
|
|
4
|
+
mapValues(balancesByWalletAccount, (balances) => balances.balance)
|
|
5
|
+
|
|
6
|
+
const byWalletAccountSelector = {
|
|
7
|
+
id: 'byWalletAccount',
|
|
8
|
+
resultFunction,
|
|
9
|
+
dependencies: [
|
|
10
|
+
//
|
|
11
|
+
{ selector: 'byWalletAccountField' },
|
|
12
|
+
],
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default byWalletAccountSelector
|
package/redux/selectors/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import byAssetSourceSelector from './byAssetSource'
|
|
2
|
+
import byWalletAccountSelector from './byWalletAccount'
|
|
3
|
+
import byWalletAccountFieldSelector from './byWalletAccountField'
|
|
2
4
|
import byAssetSourceFieldSelector from './byAssetSourceField'
|
|
3
5
|
import byAssetInActiveAccountSelector from './byAssetInActiveAccount'
|
|
4
6
|
import optimisticByAssetInActiveAccountSelector from './optimisticByAssetInActiveAccount'
|
|
@@ -14,6 +16,8 @@ export default [
|
|
|
14
16
|
byAssetSourceSelector,
|
|
15
17
|
byAssetSourceFieldSelector,
|
|
16
18
|
byAssetInActiveAccountSelector,
|
|
19
|
+
byWalletAccountSelector,
|
|
20
|
+
byWalletAccountFieldSelector,
|
|
17
21
|
optimisticByAssetInActiveAccountSelector,
|
|
18
22
|
optimisticByAssetSourceSelector,
|
|
19
23
|
optimisticByAssetSourceFieldSelector,
|