@exodus/fiat-balances 7.1.0 → 9.0.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 +24 -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/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,30 @@
|
|
|
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.0.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@8.0.0...@exodus/fiat-balances@9.0.0) (2023-08-31)
|
|
7
|
+
|
|
8
|
+
### ⚠ BREAKING CHANGES
|
|
9
|
+
|
|
10
|
+
- emit fiat balances from plugin (#3800)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- emit fiat balances from plugin ([#3800](https://github.com/ExodusMovement/exodus-hydra/issues/3800)) ([a65b208](https://github.com/ExodusMovement/exodus-hydra/commit/a65b208ddd7125a6a88e1cbc6c88f50322d39f2f))
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
- clone data ([#3794](https://github.com/ExodusMovement/exodus-hydra/issues/3794)) ([1726b0d](https://github.com/ExodusMovement/exodus-hydra/commit/1726b0db2558953f17ad1eb2b35820c1f1dc809a))
|
|
19
|
+
|
|
20
|
+
## [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)
|
|
21
|
+
|
|
22
|
+
### ⚠ BREAKING CHANGES
|
|
23
|
+
|
|
24
|
+
- THIS PACKAGE NOT AFFECTED, only tests. remove store and actions from setup redux (#3575)
|
|
25
|
+
|
|
26
|
+
### Bug Fixes
|
|
27
|
+
|
|
28
|
+
- load balances once on start ([#3599](https://github.com/ExodusMovement/exodus-hydra/issues/3599)) ([55367ca](https://github.com/ExodusMovement/exodus-hydra/commit/55367caec36e8046358200b36fad3c21f7383ccb))
|
|
29
|
+
|
|
6
30
|
## [7.1.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@7.0.1...@exodus/fiat-balances@7.1.0) (2023-08-23)
|
|
7
31
|
|
|
8
32
|
### Features
|
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.0.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": "^9.
|
|
38
|
+
"@exodus/atoms": "^5.6.0",
|
|
39
|
+
"@exodus/balances": "^9.1.1",
|
|
40
40
|
"@exodus/basic-utils": "^2.0.0",
|
|
41
41
|
"@exodus/blockchain-metadata": "*",
|
|
42
|
-
"@exodus/enabled-assets": "^8.
|
|
42
|
+
"@exodus/enabled-assets": "^8.1.2",
|
|
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": "237fc571a0180d65b7b4b81076375aa8b877addb"
|
|
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
|
}),
|