@exodus/fiat-balances 13.8.0 → 13.8.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.8.1](https://github.com/ExodusMovement/exodus/compare/@exodus/fiat-balances@13.8.0...@exodus/fiat-balances@13.8.1) (2026-11-23)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **fiat-balances:** serialize balance and rate updates ([#49747](https://github.com/ExodusMovement/exodus/issues/49747)) ([432febd](https://github.com/ExodusMovement/exodus/commit/432febd85cc34551734e54b3968e024770bc3719))
11
+
6
12
  ## [13.8.0](https://github.com/ExodusMovement/exodus/compare/@exodus/fiat-balances@13.7.5...@exodus/fiat-balances@13.8.0) (2026-11-08)
7
13
 
8
14
  ### Features
@@ -65,6 +65,8 @@ class FiatBalances {
65
65
  // #balances.byAssetSource: Object,
66
66
  // #balances.byBaseAssetSource: Object,
67
67
  #subscriptions = []
68
+ #pendingUpdate = Promise.resolve()
69
+ #needsRecompute = true
68
70
 
69
71
  constructor({
70
72
  assetsAtom,
@@ -86,14 +88,25 @@ class FiatBalances {
86
88
  })
87
89
  }
88
90
 
91
+ #enqueueUpdate = (update) => {
92
+ // Rates and balances are observed on separate atoms, each with its own queue.
93
+ const pending = this.#pendingUpdate.then(update)
94
+ // Keep processing updates if an observer reports a failure.
95
+ this.#pendingUpdate = pending.catch(() => {})
96
+ return pending
97
+ }
98
+
89
99
  load = () => {
90
100
  this.#subscriptions.push(
91
- this.#inputAtom.observe(({ currency, rates }) => {
92
- this.#fiatCurrency = currency
93
- this.#cachedRates = rates
94
- this.#maybeRecompute()
95
- }),
96
- this.#balancesAtom.observe(this.#setBalances)
101
+ this.#inputAtom.observe(({ currency, rates }) =>
102
+ this.#enqueueUpdate(() => {
103
+ this.#fiatCurrency = currency
104
+ this.#cachedRates = rates
105
+ this.#needsRecompute = true
106
+ if (this.#isReady()) return this.#recompute()
107
+ })
108
+ ),
109
+ this.#balancesAtom.observe((update) => this.#enqueueUpdate(() => this.#setBalances(update)))
97
110
  )
98
111
  }
99
112
 
@@ -126,10 +139,6 @@ class FiatBalances {
126
139
  return fiatCurrency.defaultUnit(value.mul(fiatRate).toDefaultNumber())
127
140
  }
128
141
 
129
- #maybeRecompute = () => {
130
- if (this.#isReady()) void this.#recompute()
131
- }
132
-
133
142
  #recompute = async () => {
134
143
  this.#reset()
135
144
 
@@ -206,16 +215,18 @@ class FiatBalances {
206
215
  }
207
216
 
208
217
  this.#recomputeWalletTotals()
218
+ this.#needsRecompute = false
209
219
  }
210
220
 
211
221
  #setBalances = async ({ balances, changes }) => {
212
222
  const needsRecompute =
213
- !this.#balances.byWalletAccount ||
223
+ this.#needsRecompute ||
214
224
  !changes ||
215
225
  // adding/removing walletAccounts is fairly rare, recompute to reduce code complexity
216
226
  (this.#latestAssetBalances && !areKeysSame(this.#latestAssetBalances, balances))
217
227
 
218
228
  this.#latestAssetBalances = balances
229
+ this.#needsRecompute = true
219
230
  if (!this.#isReady()) return
220
231
 
221
232
  if (needsRecompute) return this.#recompute()
@@ -284,9 +295,8 @@ class FiatBalances {
284
295
  )
285
296
  })
286
297
 
287
- if (!needsFlush) return
288
-
289
- this.#recomputeWalletTotals()
298
+ if (needsFlush) this.#recomputeWalletTotals()
299
+ this.#needsRecompute = false
290
300
  }
291
301
 
292
302
  #recomputeWalletTotals = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/fiat-balances",
3
- "version": "13.8.0",
3
+ "version": "13.8.1",
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,10 +35,10 @@
35
35
  "url": "https://github.com/ExodusMovement/exodus/issues?q=is%3Aissue+is%3Aopen+label%3Afiat-balances"
36
36
  },
37
37
  "dependencies": {
38
- "@exodus/atoms": "^10.3.5",
38
+ "@exodus/atoms": "^10.3.7",
39
39
  "@exodus/basic-utils": "^5.2.1",
40
40
  "@exodus/currency": "^6.4.2",
41
- "@exodus/fiat-currencies": "^1.3.1",
41
+ "@exodus/fiat-currencies": "^1.3.2",
42
42
  "@exodus/formatting": "^11.1.1",
43
43
  "lodash": "^4.17.21",
44
44
  "reselect": "^3.0.1"
@@ -46,15 +46,15 @@
46
46
  "devDependencies": {
47
47
  "@exodus/assets": "^11.0.0",
48
48
  "@exodus/assets-base": "^12.0.0",
49
- "@exodus/assets-feature": "^9.7.0",
50
- "@exodus/available-assets": "^8.11.2",
51
- "@exodus/balances": "^13.16.1",
52
- "@exodus/blockchain-metadata": "^17.2.1",
53
- "@exodus/combined-assets-meta": "^3.3.2",
54
- "@exodus/enabled-assets": "^10.12.0",
49
+ "@exodus/assets-feature": "^10.0.0",
50
+ "@exodus/assets-test-meta": "^1.0.0",
51
+ "@exodus/available-assets": "^8.11.3",
52
+ "@exodus/balances": "^13.17.5",
53
+ "@exodus/blockchain-metadata": "^17.2.2",
54
+ "@exodus/enabled-assets": "^10.12.2",
55
55
  "@exodus/favorite-assets": "^2.6.1",
56
56
  "@exodus/fee-data-monitors": "^5.0.6",
57
- "@exodus/models": "^13.3.3",
57
+ "@exodus/models": "^13.3.4",
58
58
  "@exodus/rates-monitor": "^4.16.0",
59
59
  "@exodus/redux-dependency-injection": "^5.0.0",
60
60
  "@exodus/solana-meta": "^2.0.0",
@@ -68,5 +68,5 @@
68
68
  "access": "public",
69
69
  "provenance": false
70
70
  },
71
- "gitHead": "029a93c0112bc16a8a870d43af66b4c197adb9ea"
71
+ "gitHead": "52de3f3cc091dd7fc82056bada3513d880a6a96d"
72
72
  }