@exodus/fiat-balances 10.6.0 → 10.7.1
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
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
|
+
## [10.7.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@10.7.0...@exodus/fiat-balances@10.7.1) (2024-05-03)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- export shared folder ([#6801](https://github.com/ExodusMovement/exodus-hydra/issues/6801)) ([69ff0fc](https://github.com/ExodusMovement/exodus-hydra/commit/69ff0fc3d55f1b8acb9f6d1c99a4823cd972d870))
|
|
11
|
+
|
|
12
|
+
## [10.7.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@10.6.0...@exodus/fiat-balances@10.7.0) (2024-05-02)
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
- conversions selector ([#6751](https://github.com/ExodusMovement/exodus-hydra/issues/6751)) ([91c17fa](https://github.com/ExodusMovement/exodus-hydra/commit/91c17fab578b15e028e2d0ffdc283bec2ad6c7c4))
|
|
17
|
+
|
|
6
18
|
## [10.6.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@10.5.0...@exodus/fiat-balances@10.6.0) (2024-04-23)
|
|
7
19
|
|
|
8
20
|
### Features
|
package/module/fiat-balances.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isNumberUnit } from '@exodus/currency'
|
|
2
2
|
import ExodusModule from '@exodus/module' // eslint-disable-line import/no-deprecated
|
|
3
3
|
import { cloneDeepWith, isEqual, set } from 'lodash'
|
|
4
4
|
import fiatCurrencies from '@exodus/fiat-currencies'
|
|
5
5
|
import { combine } from '@exodus/atoms'
|
|
6
|
+
import { getCreateConversion } from '../shared/get-create-conversion.js'
|
|
6
7
|
|
|
7
8
|
// not super efficient, so we're assuming small objects, like { [walletAccount]: xyz }
|
|
8
9
|
const areKeysSame = (a, b) => isEqual(Object.keys(a).sort(), Object.keys(b).sort())
|
|
@@ -76,15 +77,8 @@ class FiatBalances extends ExodusModule {
|
|
|
76
77
|
const fiatCurrency = fiatCurrencies[this.#fiatCurrency]
|
|
77
78
|
const rates = this.#cachedRates[this.#fiatCurrency]
|
|
78
79
|
const asset = this.#assetsModule.getAsset(assetName)
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (fiatCurrency.defaultUnit.unitName === 'USD') {
|
|
82
|
-
fiatRate = rates?.[asset.ticker]?.priceUSD || 0
|
|
83
|
-
} else {
|
|
84
|
-
fiatRate = rates?.[asset.ticker]?.price || 0
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return conversionByRate(asset.currency, fiatCurrency, fiatRate)
|
|
80
|
+
|
|
81
|
+
return getCreateConversion(fiatCurrency, rates)(asset)
|
|
88
82
|
}
|
|
89
83
|
|
|
90
84
|
#convertToFiat = ({ assetName, value }) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/fiat-balances",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.7.1",
|
|
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",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"redux",
|
|
16
16
|
"atoms",
|
|
17
17
|
"plugin",
|
|
18
|
+
"shared",
|
|
18
19
|
"README.md",
|
|
19
20
|
"CHANGELOG.md",
|
|
20
21
|
"!**/__tests__/**"
|
|
@@ -42,21 +43,21 @@
|
|
|
42
43
|
"devDependencies": {
|
|
43
44
|
"@exodus/assets": "^9.1.0",
|
|
44
45
|
"@exodus/assets-base": "^8.1.17",
|
|
45
|
-
"@exodus/assets-feature": "^5.1
|
|
46
|
+
"@exodus/assets-feature": "^5.3.1",
|
|
46
47
|
"@exodus/available-assets": "^8.1.0",
|
|
47
|
-
"@exodus/balances": "^13.1.
|
|
48
|
+
"@exodus/balances": "^13.1.2",
|
|
48
49
|
"@exodus/blockchain-metadata": "*",
|
|
49
50
|
"@exodus/combined-assets-meta": "^1.3.0",
|
|
50
|
-
"@exodus/enabled-assets": "^10.
|
|
51
|
+
"@exodus/enabled-assets": "^10.3.0",
|
|
51
52
|
"@exodus/favorite-assets": "^2.4.1",
|
|
52
53
|
"@exodus/models": "^8.9.0",
|
|
53
54
|
"@exodus/rates-monitor": "^4.2.0",
|
|
54
|
-
"@exodus/redux-dependency-injection": "^3.
|
|
55
|
+
"@exodus/redux-dependency-injection": "^3.1.0",
|
|
55
56
|
"@exodus/solana-meta": "^1.0.4",
|
|
56
57
|
"@exodus/storage-memory": "^2.1.1",
|
|
57
58
|
"@exodus/wallet-accounts": "*",
|
|
58
59
|
"events": "^3.3.0",
|
|
59
60
|
"redux": "^4.2.1"
|
|
60
61
|
},
|
|
61
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "6a35a8f527d9e4f0a1ac2474e48548c274e8a38a"
|
|
62
63
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { getCreateConversion } from '../../shared/get-create-conversion.js'
|
|
2
|
+
import { mapValues } from '@exodus/basic-utils'
|
|
3
|
+
|
|
4
|
+
const resultFunction = (fiatCurrency, assets, rates) => {
|
|
5
|
+
const createConversion = getCreateConversion(fiatCurrency, rates)
|
|
6
|
+
return mapValues(assets, (asset) => createConversion(asset))
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const conversionsSelectorDefinition = {
|
|
10
|
+
id: 'conversions',
|
|
11
|
+
resultFunction,
|
|
12
|
+
dependencies: [
|
|
13
|
+
//
|
|
14
|
+
{ selector: 'currencyUnitType', module: 'locale' },
|
|
15
|
+
{ selector: 'all', module: 'assets' },
|
|
16
|
+
{ selector: 'fiatRates', module: 'rates' },
|
|
17
|
+
],
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default conversionsSelectorDefinition
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { getCreateConversion } from '../../shared/get-create-conversion.js'
|
|
2
|
+
|
|
3
|
+
const resultFunction = (fiatCurrency, rates, assets) => (assetName) =>
|
|
4
|
+
getCreateConversion(fiatCurrency, rates)(assets[assetName])
|
|
5
|
+
|
|
6
|
+
const createConversionSelectorDefinition = {
|
|
7
|
+
id: 'createConversion',
|
|
8
|
+
resultFunction,
|
|
9
|
+
dependencies: [
|
|
10
|
+
//
|
|
11
|
+
{ selector: 'currencyUnitType', module: 'locale' },
|
|
12
|
+
{ selector: 'all', module: 'assets' },
|
|
13
|
+
{ selector: 'fiatRates', module: 'rates' },
|
|
14
|
+
],
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default createConversionSelectorDefinition
|
package/redux/selectors/index.js
CHANGED
|
@@ -26,6 +26,8 @@ import sortedEnabledAssetsWithBalanceInActiveAccountSelector from './sorted-asse
|
|
|
26
26
|
import createEnabledAssetsWithBalanceSelector from './helpers/create-enabled-assets-with-balance'
|
|
27
27
|
import sortedEnabledAssetsWithTotalBalanceSelector from './sorted-assets/enabled/with-total-balance'
|
|
28
28
|
import sortedEnabledAssetsWithParentCombinedWithBalanceInActiveAccountSelectorDefinition from './sorted-assets/enabled/with-parent-combined-with-balance-in-active-account'
|
|
29
|
+
import conversionsSelector from './conversions.js'
|
|
30
|
+
import createConversionSelector from './create-conversion.js'
|
|
29
31
|
|
|
30
32
|
export default function createSelectorDefinitions(config) {
|
|
31
33
|
return [
|
|
@@ -57,5 +59,7 @@ export default function createSelectorDefinitions(config) {
|
|
|
57
59
|
sortedEnabledAssetsWithTotalBalanceSelector,
|
|
58
60
|
sortedAssetsWithTotalBalanceSelector,
|
|
59
61
|
getFormatFiatSelector,
|
|
62
|
+
conversionsSelector,
|
|
63
|
+
createConversionSelector,
|
|
60
64
|
]
|
|
61
65
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { conversionByRate } from '@exodus/currency'
|
|
2
|
+
|
|
3
|
+
export const getCreateConversion = (fiatCurrency, rates) => (asset) => {
|
|
4
|
+
let fiatRate
|
|
5
|
+
// HACK: Super hacky, terrible, the rates state object should have the prices split up by sub-objects per fiat
|
|
6
|
+
if (fiatCurrency.defaultUnit.unitName === 'USD') {
|
|
7
|
+
fiatRate = rates?.[asset.ticker]?.priceUSD || 0
|
|
8
|
+
} else {
|
|
9
|
+
fiatRate = rates?.[asset.ticker]?.price || 0
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return conversionByRate(asset.currency, fiatCurrency, fiatRate)
|
|
13
|
+
}
|