@exodus/fiat-balances 11.1.0 → 12.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 CHANGED
@@ -3,6 +3,23 @@
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
+ ## [12.1.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@12.0.0...@exodus/fiat-balances@12.1.0) (2024-08-23)
7
+
8
+ ### Features
9
+
10
+ - upgrade formatting lib ([#8628](https://github.com/ExodusMovement/exodus-hydra/issues/8628)) ([5b60628](https://github.com/ExodusMovement/exodus-hydra/commit/5b60628586bf734933b46742f2bbe49174ffd6f9))
11
+
12
+ ## [12.0.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@11.1.0...@exodus/fiat-balances@12.0.0) (2024-08-16)
13
+
14
+ ### ⚠ BREAKING CHANGES
15
+
16
+ - return $0 if fiat amount is zero. fix percentage formatter (#8442)
17
+
18
+ ### Features
19
+
20
+ - bump formatting to v4 ([#8404](https://github.com/ExodusMovement/exodus-hydra/issues/8404)) ([df68f5e](https://github.com/ExodusMovement/exodus-hydra/commit/df68f5e3e853200efdfd018c17809f5cd7598ea3))
21
+ - return $0 if fiat amount is zero. fix percentage formatter ([#8442](https://github.com/ExodusMovement/exodus-hydra/issues/8442)) ([54b76b5](https://github.com/ExodusMovement/exodus-hydra/commit/54b76b5b9984520a7c56058ce6fa0dd797f1cfd0))
22
+
6
23
  ## [11.1.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@11.0.0...@exodus/fiat-balances@11.1.0) (2024-08-13)
7
24
 
8
25
  ### Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/fiat-balances",
3
- "version": "11.1.0",
3
+ "version": "12.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,8 +35,8 @@
35
35
  "@exodus/atoms": "^8.0.0",
36
36
  "@exodus/basic-utils": "^2.5.1",
37
37
  "@exodus/currency": "^2.1.2",
38
- "@exodus/fiat-currencies": "^1.0.0",
39
- "@exodus/formatting": "^1.2.1",
38
+ "@exodus/fiat-currencies": "^1.1.0",
39
+ "@exodus/formatting": "^6.0.0",
40
40
  "@exodus/module": "^1.1.0",
41
41
  "@exodus/typeforce": "^1.18.1",
42
42
  "lodash": "^4.17.21",
@@ -46,23 +46,23 @@
46
46
  "devDependencies": {
47
47
  "@exodus/assets": "^9.1.0",
48
48
  "@exodus/assets-base": "^8.1.17",
49
- "@exodus/assets-feature": "^5.10.0",
50
- "@exodus/available-assets": "^8.4.1",
51
- "@exodus/balances": "^13.2.3",
49
+ "@exodus/assets-feature": "^5.11.0",
50
+ "@exodus/available-assets": "^8.5.0",
51
+ "@exodus/balances": "^13.3.0",
52
52
  "@exodus/blockchain-metadata": "^15.3.5",
53
53
  "@exodus/combined-assets-meta": "^1.3.0",
54
- "@exodus/enabled-assets": "^10.5.2",
54
+ "@exodus/enabled-assets": "^10.7.0",
55
55
  "@exodus/favorite-assets": "^2.4.3",
56
- "@exodus/fee-data-monitors": "^4.2.1",
56
+ "@exodus/fee-data-monitors": "^4.3.0",
57
57
  "@exodus/locale": "^2.2.2",
58
58
  "@exodus/models": "^8.9.0",
59
- "@exodus/rates-monitor": "^4.3.3",
60
- "@exodus/redux-dependency-injection": "^4.0.0",
59
+ "@exodus/rates-monitor": "^4.4.0",
60
+ "@exodus/redux-dependency-injection": "^4.0.1",
61
61
  "@exodus/solana-meta": "^1.0.4",
62
- "@exodus/storage-memory": "^2.1.1",
62
+ "@exodus/storage-memory": "^2.2.0",
63
63
  "@exodus/wallet-accounts": "^16.8.2",
64
64
  "events": "^3.3.0",
65
65
  "redux": "^4.2.1"
66
66
  },
67
- "gitHead": "aa8877dca42334fb1c98613ea10d29ac8a2a5d05"
67
+ "gitHead": "8b45e5b5e807c1afd9c32173199d3a2733c591e8"
68
68
  }
@@ -1,45 +1,25 @@
1
1
  import { isNumberUnit } from '@exodus/currency'
2
- import { getFiatAdaptiveFraction } from '@exodus/formatting/lib/price'
3
- import { hasLeftCurrencySymbol, units } from '@exodus/fiat-currencies'
4
- import { formatCurrency, LEFT_FORMAT, RIGHT_FORMAT } from '@exodus/formatting/lib/currency'
5
-
6
- function formatPrice(
7
- price,
8
- { useGrouping = true, format = '%v', symbol, fraction = 2, convertDust = true } = {}
9
- ) {
10
- const priceNumber = Number(price)
11
- const isDust = priceNumber < Math.pow(10, -fraction) && priceNumber > 0
12
- if (convertDust && isDust) {
13
- return `~${formatCurrency(0, {
14
- minFraction: 0,
15
- maxFraction: 0,
16
- format,
17
- symbol,
18
- useGrouping,
19
- })}`
20
- }
21
-
22
- return formatCurrency(price, {
23
- minFraction: fraction,
24
- maxFraction: fraction,
25
- format,
26
- symbol,
27
- useGrouping,
28
- })
29
- }
2
+ import { formatPrice, getFiatAdaptiveFraction } from '@exodus/formatting/lib/price'
30
3
 
31
4
  const resultFunction =
32
5
  (currency) =>
33
- (fiatValue, { customCurrency, adaptiveFraction, useGrouping, convertDust } = {}) => {
6
+ (
7
+ fiatValue,
8
+ {
9
+ customCurrency,
10
+ adaptiveFraction, // use adaptiveFraction when convert crypto amount (balance for example) to fiat
11
+ useGrouping,
12
+ convertDust,
13
+ } = {}
14
+ ) => {
34
15
  const fiatCurrency = customCurrency || currency
35
16
  const value = isNumberUnit(fiatValue) ? fiatValue.toDefaultNumber() : fiatValue
36
17
 
37
18
  return formatPrice(value, {
38
- format: hasLeftCurrencySymbol(fiatCurrency) ? LEFT_FORMAT : RIGHT_FORMAT,
39
- symbol: units[fiatCurrency].symbol,
40
- fraction: adaptiveFraction ? getFiatAdaptiveFraction(value) : undefined,
19
+ currency: fiatCurrency,
41
20
  useGrouping,
42
21
  convertDust,
22
+ fraction: adaptiveFraction ? getFiatAdaptiveFraction(value) : undefined,
43
23
  })
44
24
  }
45
25
 
@@ -17,7 +17,7 @@ const selectorFactory =
17
17
  return {
18
18
  balance: balances[asset] || asset.currency.ZERO,
19
19
  fiatValue,
20
- formattedFiatValue: formatFiat(fiatValue),
20
+ formattedFiatValue: formatFiat(fiatValue, { adaptiveFraction: true }),
21
21
  }
22
22
  }
23
23
 
@@ -48,7 +48,7 @@ const selectorFactory =
48
48
  combinedAssets,
49
49
  balance: combinedBalance,
50
50
  fiatValue: combinedFiatValue,
51
- formattedFiatValue: formatFiat(combinedFiatValue),
51
+ formattedFiatValue: formatFiat(combinedFiatValue, { adaptiveFraction: true }),
52
52
  }
53
53
  }
54
54