@exodus/balances 13.5.0 → 13.5.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,12 @@
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.5.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/balances@13.5.0...@exodus/balances@13.5.1) (2024-11-29)
7
+
8
+ ### Bug Fixes
9
+
10
+ - fix: balances map equality check (#10620)
11
+
6
12
  ## [13.5.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/balances@13.4.0...@exodus/balances@13.5.0) (2024-11-29)
7
13
 
8
14
  ### Features
@@ -1,12 +1,13 @@
1
1
  import { compute, dedupe } from '@exodus/atoms'
2
2
 
3
- const mapsAreEqual = (mapA, mapB) => {
3
+ const numberUnitMapsAreEqual = (mapA, mapB) => {
4
4
  if (mapA.size !== mapB.size) {
5
5
  return false
6
6
  }
7
7
 
8
- for (const item of mapA) {
9
- if (!mapB.has(item)) {
8
+ for (const [key, val] of mapA) {
9
+ const itemB = mapB.get(key)
10
+ if (!itemB || !itemB.equals(val)) {
10
11
  return false
11
12
  }
12
13
  }
@@ -21,19 +22,19 @@ const createAssetTotalWalletAmountsAtom = ({ balancesAtom }) => {
21
22
 
22
23
  Object.values(balances).forEach((accountBalances) => {
23
24
  Object.keys(accountBalances).forEach((assetName) => {
24
- if (assetsWithBalances.has(assetName)) {
25
- const currentAssetBalance = assetsWithBalances.get(assetName)
26
- assetsWithBalances.set(
27
- assetName,
28
- accountBalances[assetName]?.balance.add(currentAssetBalance)
29
- )
30
- } else {
31
- assetsWithBalances.set(assetName, accountBalances[assetName]?.balance)
25
+ const accountAssetBalance = accountBalances[assetName] && accountBalances[assetName].balance
26
+ if (accountAssetBalance) {
27
+ if (assetsWithBalances.has(assetName)) {
28
+ const currentAssetBalance = assetsWithBalances.get(assetName)
29
+ assetsWithBalances.set(assetName, accountAssetBalance.add(currentAssetBalance))
30
+ } else {
31
+ assetsWithBalances.set(assetName, accountAssetBalance)
32
+ }
32
33
  }
33
34
  })
34
35
  })
35
36
 
36
- if (!mapsAreEqual(assetsWithBalances, previousValue)) {
37
+ if (!numberUnitMapsAreEqual(assetsWithBalances, previousValue)) {
37
38
  previousValue = assetsWithBalances
38
39
  }
39
40
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/balances",
3
- "version": "13.5.0",
3
+ "version": "13.5.1",
4
4
  "description": "Tracks crypto balances across enabled wallet accounts.",
5
5
  "author": "Exodus Movement, Inc.",
6
6
  "license": "MIT",
@@ -65,5 +65,5 @@
65
65
  "publishConfig": {
66
66
  "access": "public"
67
67
  },
68
- "gitHead": "d979dacecad62ad66a5761afc08d6ea362ca05a5"
68
+ "gitHead": "16255e10556dd9fdcd811351f7fea30c101a4fe7"
69
69
  }
@@ -27,7 +27,7 @@ const createBalancesAnalyticsPlugin = ({
27
27
  const assetBalances = assetsToTrackForBalances.reduce((acc, obj) => {
28
28
  acc[obj.analyticsName] = getAssetAmountFromNumberUnit(balances.get(obj.assetName))
29
29
  return acc
30
- }, {})
30
+ }, Object.create(null))
31
31
  analytics.setDefaultEventProperties(assetBalances)
32
32
  })
33
33