@exodus/fiat-balances 13.7.2 → 13.7.3

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.7.3](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@13.7.2...@exodus/fiat-balances@13.7.3) (2026-03-05)
7
+
8
+ ### Performance
9
+
10
+ - perf(fiat-balances): optimize cloneBalances with structure-aware shallow clone (#15481)
11
+
6
12
  ## [13.7.2](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@13.7.1...@exodus/fiat-balances@13.7.2) (2026-02-25)
7
13
 
8
14
  ### Performance
@@ -1,5 +1,4 @@
1
1
  import { set } from '@exodus/basic-utils'
2
- import { isNumberUnit } from '@exodus/currency'
3
2
  import fiatCurrencies from '@exodus/fiat-currencies'
4
3
  import { combine } from '@exodus/atoms'
5
4
 
@@ -11,17 +10,43 @@ const areKeysSame = (a, b) => {
11
10
  return keysB.every((key) => aKeySet.has(key))
12
11
  }
13
12
 
14
- export const cloneBalances = (balances) => {
15
- if (isNumberUnit(balances)) {
16
- return balances
13
+ const shallowClone = (obj) => ({ ...obj })
14
+
15
+ const clone2Levels = (obj) => {
16
+ const result = Object.create(null)
17
+ for (const key of Object.keys(obj)) {
18
+ result[key] = { ...obj[key] }
17
19
  }
18
20
 
19
- const cloned = Object.create(Object.getPrototypeOf(balances))
20
- for (const key in balances) {
21
- cloned[key] = cloneBalances(balances[key])
21
+ return result
22
+ }
23
+
24
+ const clone3Levels = (obj) => {
25
+ const result = Object.create(null)
26
+ for (const key1 of Object.keys(obj)) {
27
+ const level1 = obj[key1]
28
+ const clonedLevel1 = Object.create(null)
29
+ for (const key2 of Object.keys(level1)) {
30
+ clonedLevel1[key2] = { ...level1[key2] }
31
+ }
32
+
33
+ result[key1] = clonedLevel1
22
34
  }
23
35
 
24
- return cloned
36
+ return result
37
+ }
38
+
39
+ export const cloneBalances = (wrapper) => {
40
+ const balances = wrapper.balances
41
+ return {
42
+ balances: {
43
+ totals: shallowClone(balances.totals),
44
+ byWalletAccount: clone2Levels(balances.byWalletAccount),
45
+ byAssetSource: clone3Levels(balances.byAssetSource),
46
+ byBaseAssetSource: clone3Levels(balances.byBaseAssetSource),
47
+ byAsset: clone2Levels(balances.byAsset),
48
+ },
49
+ }
25
50
  }
26
51
 
27
52
  class FiatBalances {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/fiat-balances",
3
- "version": "13.7.2",
3
+ "version": "13.7.3",
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",
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@exodus/atoms": "^9.0.0",
38
- "@exodus/basic-utils": "^3.0.1",
38
+ "@exodus/basic-utils": "^3.7.3",
39
39
  "@exodus/currency": "^5.0.2",
40
40
  "@exodus/fiat-currencies": "^1.2.3",
41
41
  "@exodus/formatting": "^9.0.0",
@@ -48,7 +48,7 @@
48
48
  "@exodus/assets-base": "^10.0.0",
49
49
  "@exodus/assets-feature": "^9.0.1",
50
50
  "@exodus/available-assets": "^8.11.0",
51
- "@exodus/balances": "^13.15.1",
51
+ "@exodus/balances": "^13.15.2",
52
52
  "@exodus/blockchain-metadata": "^17.1.0",
53
53
  "@exodus/combined-assets-meta": "^3.3.2",
54
54
  "@exodus/enabled-assets": "^10.11.0",
@@ -67,5 +67,5 @@
67
67
  "access": "public",
68
68
  "provenance": false
69
69
  },
70
- "gitHead": "3ff15cc5f430736df2959cded07977ab3d45ca70"
70
+ "gitHead": "d234e06c7b4a7e49eb7b8e3082a28c4fab19c0ce"
71
71
  }