@exodus/fiat-balances 10.13.1 → 11.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 CHANGED
@@ -3,6 +3,22 @@
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
+ ## [11.0.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@10.13.2...@exodus/fiat-balances@11.0.0) (2024-08-12)
7
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ - convert fiat dust value in selector to ~0 (#8320)
11
+
12
+ ### Features
13
+
14
+ - convert fiat dust value in selector to ~0 ([#8320](https://github.com/ExodusMovement/exodus-hydra/issues/8320)) ([78d9126](https://github.com/ExodusMovement/exodus-hydra/commit/78d91269ffb909134da391bfd98ef34915ae4b37))
15
+
16
+ ## [10.13.2](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@10.13.1...@exodus/fiat-balances@10.13.2) (2024-08-06)
17
+
18
+ ### Bug Fixes
19
+
20
+ - default config ([#8225](https://github.com/ExodusMovement/exodus-hydra/issues/8225)) ([73f636c](https://github.com/ExodusMovement/exodus-hydra/commit/73f636caaf471fe82a337788fbbc40fc17ab1475))
21
+
6
22
  ## [10.13.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@10.13.0...@exodus/fiat-balances@10.13.1) (2024-08-06)
7
23
 
8
24
  ### Bug Fixes
package/index.js CHANGED
@@ -22,7 +22,11 @@ const DEFAULT_BALANCE_FIELDS = ['balance']
22
22
  const fiatBalances = (
23
23
  {
24
24
  optimistic = false,
25
- nonDustAssets: { balanceThresholdsUsd, balanceThresholdByChainUsd, defaultBalanceThresholdUsd },
25
+ nonDustAssets: {
26
+ balanceThresholdsUsd,
27
+ balanceThresholdByChainUsd,
28
+ defaultBalanceThresholdUsd,
29
+ } = Object.create(null),
26
30
  balanceFields = DEFAULT_BALANCE_FIELDS,
27
31
  } = Object.create(null)
28
32
  ) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/fiat-balances",
3
- "version": "10.13.1",
3
+ "version": "11.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",
@@ -46,7 +46,7 @@
46
46
  "devDependencies": {
47
47
  "@exodus/assets": "^9.1.0",
48
48
  "@exodus/assets-base": "^8.1.17",
49
- "@exodus/assets-feature": "^5.9.0",
49
+ "@exodus/assets-feature": "^5.10.0",
50
50
  "@exodus/available-assets": "^8.4.1",
51
51
  "@exodus/balances": "^13.2.3",
52
52
  "@exodus/blockchain-metadata": "^15.3.5",
@@ -64,5 +64,5 @@
64
64
  "events": "^3.3.0",
65
65
  "redux": "^4.2.1"
66
66
  },
67
- "gitHead": "0f17df0522993b8997cf609728697afd7e46ae00"
67
+ "gitHead": "5010b9c3937b9fa235e174b74f11197a462b3d5d"
68
68
  }
@@ -3,7 +3,22 @@ import { getFiatAdaptiveFraction } from '@exodus/formatting/lib/price'
3
3
  import { hasLeftCurrencySymbol, units } from '@exodus/fiat-currencies'
4
4
  import { formatCurrency, LEFT_FORMAT, RIGHT_FORMAT } from '@exodus/formatting/lib/currency'
5
5
 
6
- function formatPrice(price, { useGrouping = true, format = '%v', symbol, fraction = 2 } = {}) {
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
+
7
22
  return formatCurrency(price, {
8
23
  minFraction: fraction,
9
24
  maxFraction: fraction,
@@ -15,7 +30,7 @@ function formatPrice(price, { useGrouping = true, format = '%v', symbol, fractio
15
30
 
16
31
  const resultFunction =
17
32
  (currency) =>
18
- (fiatValue, { customCurrency, adaptiveFraction } = {}) => {
33
+ (fiatValue, { customCurrency, adaptiveFraction, useGrouping, convertDust } = {}) => {
19
34
  const fiatCurrency = customCurrency || currency
20
35
  const value = isNumberUnit(fiatValue) ? fiatValue.toDefaultNumber() : fiatValue
21
36
 
@@ -23,6 +38,8 @@ const resultFunction =
23
38
  format: hasLeftCurrencySymbol(fiatCurrency) ? LEFT_FORMAT : RIGHT_FORMAT,
24
39
  symbol: units[fiatCurrency].symbol,
25
40
  fraction: adaptiveFraction ? getFiatAdaptiveFraction(value) : undefined,
41
+ useGrouping,
42
+ convertDust,
26
43
  })
27
44
  }
28
45