@exodus/fiat-balances 13.0.0 → 13.0.2

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
+ ## [13.0.2](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@13.0.1...@exodus/fiat-balances@13.0.2) (2025-01-20)
7
+
8
+ ### Bug Fixes
9
+
10
+ - fix(fiat-balances): assets with balance above favorite assets on sort (#11117)
11
+
12
+ ## [13.0.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@13.0.0...@exodus/fiat-balances@13.0.1) (2025-01-02)
13
+
14
+ ### Bug Fixes
15
+
16
+ - fix: memoize selector result (#10901)
17
+
6
18
  ## [13.0.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@12.5.2...@exodus/fiat-balances@13.0.0) (2024-12-23)
7
19
 
8
20
  ### ⚠ BREAKING CHANGES
package/README.md CHANGED
@@ -10,7 +10,7 @@ yarn add @exodus/fiat-balances
10
10
 
11
11
  ## Usage
12
12
 
13
- This feature is designed to be used together with `@exodus/headless`. See [using the sdk](../../docs/docs-website/docs/development/using-the-sdk.md).
13
+ This feature is designed to be used together with `@exodus/headless`. See [using the sdk](../../docs/development/using-the-sdk.md).
14
14
 
15
15
  ### Play with it
16
16
 
@@ -37,7 +37,7 @@ selectors.fiatBalances.byAsset(store.getState()).ethereum.toDefaultString({ unit
37
37
 
38
38
  ### API Side
39
39
 
40
- See [using the sdk](../../docs/docs-website/docs/development/using-the-sdk.md#setup-the-api-side) for more details on how features plug into the SDK. Note that the balances feature currently doesn't provide a top level API and is meant to be used purely through selectors.
40
+ See [using the sdk](../../docs/development/using-the-sdk.md#setup-the-api-side) for more details on how features plug into the SDK. Note that the balances feature currently doesn't provide a top level API and is meant to be used purely through selectors.
41
41
 
42
42
  If you're building a feature that requires balances, add a dependency on the `fiatBalancesAtom` as below.
43
43
 
@@ -64,7 +64,7 @@ const myModuleDefinition = {
64
64
 
65
65
  ### UI Side
66
66
 
67
- See [using the sdk](../../docs/docs-website/docs/development/using-the-sdk.md#events) for more details on basic UI-side setup.
67
+ See [using the sdk](../../docs/development/using-the-sdk.md#events) for more details on basic UI-side setup.
68
68
 
69
69
  ```js
70
70
  import { selectors } from '~/ui/flux'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/fiat-balances",
3
- "version": "13.0.0",
3
+ "version": "13.0.2",
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": "MIT",
@@ -44,16 +44,16 @@
44
44
  "devDependencies": {
45
45
  "@exodus/assets": "^9.1.0",
46
46
  "@exodus/assets-base": "^8.1.17",
47
- "@exodus/assets-feature": "^5.14.1",
47
+ "@exodus/assets-feature": "^6.0.4",
48
48
  "@exodus/available-assets": "^8.7.0",
49
- "@exodus/balances": "^13.5.1",
49
+ "@exodus/balances": "^13.5.4",
50
50
  "@exodus/blockchain-metadata": "^15.7.1",
51
51
  "@exodus/combined-assets-meta": "^1.3.0",
52
52
  "@exodus/enabled-assets": "^10.8.2",
53
53
  "@exodus/favorite-assets": "^2.4.3",
54
54
  "@exodus/fee-data-monitors": "^5.0.3",
55
- "@exodus/models": "^12.3.0",
56
- "@exodus/rates-monitor": "^4.5.0",
55
+ "@exodus/models": "^12.4.0",
56
+ "@exodus/rates-monitor": "^4.7.0",
57
57
  "@exodus/redux-dependency-injection": "^4.1.1",
58
58
  "@exodus/solana-meta": "^1.0.4",
59
59
  "@exodus/storage-memory": "^2.2.2",
@@ -64,5 +64,5 @@
64
64
  "publishConfig": {
65
65
  "access": "public"
66
66
  },
67
- "gitHead": "5e60408602f75be3c7b3961446ec927a4eec5189"
67
+ "gitHead": "98dadedc1d95cdb24a57d612d47981386f81a357"
68
68
  }
@@ -1,12 +1,12 @@
1
- import { memoize } from 'lodash' // eslint-disable-line @exodus/restricted-imports/prefer-basic-utils -- TODO: fix next time we touch this file
1
+ import { keyBy, memoize, orderBy } from '@exodus/basic-utils'
2
+ import { isDustAmount } from '@exodus/formatting/lib/asset'
2
3
  import { createSelector } from 'reselect'
3
4
  import { isMultiNetworkAsset } from '../utils'
4
- import { keyBy, orderBy } from '@exodus/basic-utils'
5
- import { isDustAmount } from '@exodus/formatting/lib/asset'
6
5
 
7
6
  const SORTING_MAP = [
8
- [(a) => a.sortAssetMetaData.isFavoriteAsset, 'desc'],
7
+ [(a) => a.sortAssetMetaData.fiatBalance && a.sortAssetMetaData.isFavoriteAsset, 'desc'],
9
8
  [(a) => a.sortAssetMetaData.fiatBalance, 'desc'],
9
+ [(a) => a.sortAssetMetaData.isFavoriteAsset, 'desc'],
10
10
  [(a) => a.sortAssetMetaData.isBaseAsset, 'desc'],
11
11
  [(a) => a.sortAssetMetaData.hasBalance, 'desc'],
12
12
  [(a) => a.sortAssetMetaData.isDust, 'asc'],
@@ -24,8 +24,9 @@ const sortAssetsSelectorFactoryCreator = ({
24
24
  ignoreMarketCapAssets,
25
25
  assetsListSelector,
26
26
  }) =>
27
- memoize((walletAccount) =>
28
- createSelector(
27
+ memoize((walletAccount) => {
28
+ let lastResult
29
+ return createSelector(
29
30
  assetsListSelector,
30
31
  (state) => getAccountAssetsBalanceSelector(state)(walletAccount),
31
32
  (state) => fiatBalancesByAssetSourceSelector(state)[walletAccount],
@@ -78,9 +79,22 @@ const sortAssetsSelectorFactoryCreator = ({
78
79
  })
79
80
 
80
81
  const sorted = orderBy(assetsWithMetaData, SORT_KEYS, SORT_ORDER)
81
- return sorted.map((assetWithMetaData) => assetsMap[assetWithMetaData.name])
82
+ const namesOnly = sorted.map((assetWithMetaData) => assetWithMetaData.name)
83
+ const lastSortedAssetNames = lastResult ? lastResult.map((a) => a.name) : null
84
+ // Compare newResult with lastResult for reference equality
85
+ if (
86
+ lastSortedAssetNames &&
87
+ namesOnly.length === lastSortedAssetNames.length &&
88
+ namesOnly.every((item, i) => item === lastSortedAssetNames[i])
89
+ ) {
90
+ return lastResult
91
+ }
92
+
93
+ lastResult = sorted.map((assetWithMetaData) => assetsMap[assetWithMetaData.name])
94
+
95
+ return lastResult
82
96
  }
83
97
  )
84
- )
98
+ })
85
99
 
86
100
  export default sortAssetsSelectorFactoryCreator