@exodus/balances 13.12.0 → 13.13.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 +6 -0
- package/module/index.js +26 -19
- package/package.json +4 -3
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.13.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/balances@13.12.0...@exodus/balances@13.13.0) (2025-07-16)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- feat: track errors from balances module (#13237)
|
|
11
|
+
|
|
6
12
|
## [13.12.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/balances@13.11.0...@exodus/balances@13.12.0) (2025-07-10)
|
|
7
13
|
|
|
8
14
|
### Features
|
package/module/index.js
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
|
+
import { safeString } from '@exodus/safe-string'
|
|
1
2
|
import { isNumberUnit } from '@exodus/currency'
|
|
2
3
|
import { TxSet } from '@exodus/models'
|
|
3
4
|
import lodash from 'lodash'
|
|
4
5
|
import { difference as getChanges } from '@exodus/atoms'
|
|
5
|
-
import {
|
|
6
|
-
cloneDeepWith,
|
|
7
|
-
difference,
|
|
8
|
-
flattenToPaths,
|
|
9
|
-
pickByArrayPaths,
|
|
10
|
-
set,
|
|
11
|
-
} from '@exodus/basic-utils'
|
|
6
|
+
import { difference, flattenToPaths, pick, set } from '@exodus/basic-utils'
|
|
12
7
|
import makeConcurrent from 'make-concurrent'
|
|
13
8
|
import { processAssetBalances, validateBalances } from './balances-utils.js'
|
|
14
9
|
import defaultConfig from '../default-config.js'
|
|
15
10
|
|
|
16
11
|
const { isEmpty, merge, zipObject } = lodash
|
|
17
12
|
|
|
18
|
-
export const cloneBalances = (balances) =>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
export const cloneBalances = (balances) => {
|
|
14
|
+
if (isNumberUnit(balances)) {
|
|
15
|
+
return balances
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const cloned = Object.create(Object.getPrototypeOf(balances))
|
|
19
|
+
for (const key in balances) {
|
|
20
|
+
cloned[key] = cloneBalances(balances[key])
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return cloned
|
|
24
|
+
}
|
|
24
25
|
|
|
25
26
|
const zipNonNull = (keys, values) =>
|
|
26
27
|
zipObject(
|
|
@@ -46,7 +47,7 @@ class Balances {
|
|
|
46
47
|
#enabledWalletAccountsAtom
|
|
47
48
|
#loaded = false
|
|
48
49
|
#subscriptions = []
|
|
49
|
-
|
|
50
|
+
#errorTracking
|
|
50
51
|
constructor({
|
|
51
52
|
assetsModule,
|
|
52
53
|
availableAssetNamesAtom,
|
|
@@ -57,6 +58,7 @@ class Balances {
|
|
|
57
58
|
txLogsAtom,
|
|
58
59
|
accountStatesAtom,
|
|
59
60
|
feeDataAtom,
|
|
61
|
+
errorTracking,
|
|
60
62
|
}) {
|
|
61
63
|
this.#logger = logger
|
|
62
64
|
this.#assetsModule = assetsModule
|
|
@@ -68,6 +70,7 @@ class Balances {
|
|
|
68
70
|
this.#txLogsAtom = txLogsAtom
|
|
69
71
|
this.#feeDataAtom = feeDataAtom
|
|
70
72
|
this.#enabledWalletAccountsAtom = enabledWalletAccountsAtom
|
|
73
|
+
this.#errorTracking = errorTracking
|
|
71
74
|
|
|
72
75
|
const shareQueue =
|
|
73
76
|
(fn) =>
|
|
@@ -78,12 +81,12 @@ class Balances {
|
|
|
78
81
|
}
|
|
79
82
|
|
|
80
83
|
const swallowErrors =
|
|
81
|
-
(fn) =>
|
|
84
|
+
(fn, method) =>
|
|
82
85
|
async (...args) => {
|
|
83
86
|
try {
|
|
84
87
|
return await fn(...args)
|
|
85
88
|
} catch (error) {
|
|
86
|
-
this.#
|
|
89
|
+
this.#errorTracking.track({ error: new Error(method, { cause: error }) })
|
|
87
90
|
}
|
|
88
91
|
}
|
|
89
92
|
|
|
@@ -93,8 +96,11 @@ class Balances {
|
|
|
93
96
|
this.#handleFeeDataUpdate = shareQueue(this.#handleFeeDataUpdate)
|
|
94
97
|
this.#recompute = shareQueue(this.#recompute)
|
|
95
98
|
this.#onAssetsChanged = shareQueue(this.#onAssetsChanged)
|
|
96
|
-
this.#getBalancesForAssetSource = swallowErrors(
|
|
97
|
-
|
|
99
|
+
this.#getBalancesForAssetSource = swallowErrors(
|
|
100
|
+
this.#getBalancesForAssetSource,
|
|
101
|
+
safeString`getBalancesForAssetSource`
|
|
102
|
+
)
|
|
103
|
+
this.#setWalletAccounts = swallowErrors(this.#setWalletAccounts, safeString`setWalletAccounts`)
|
|
98
104
|
}
|
|
99
105
|
|
|
100
106
|
load = async () => {
|
|
@@ -206,7 +212,7 @@ class Balances {
|
|
|
206
212
|
zero,
|
|
207
213
|
})
|
|
208
214
|
return validateBalances({
|
|
209
|
-
balances:
|
|
215
|
+
balances: pick(balances, this.#balanceFields),
|
|
210
216
|
asset,
|
|
211
217
|
zero,
|
|
212
218
|
logger: this.#logger,
|
|
@@ -426,6 +432,7 @@ const balancesDefinition = {
|
|
|
426
432
|
'txLogsAtom',
|
|
427
433
|
'accountStatesAtom',
|
|
428
434
|
'feeDataAtom',
|
|
435
|
+
'errorTracking',
|
|
429
436
|
],
|
|
430
437
|
public: true,
|
|
431
438
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/balances",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.13.0",
|
|
4
4
|
"description": "Tracks crypto balances across enabled wallet accounts.",
|
|
5
5
|
"author": "Exodus Movement, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,13 +34,14 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@exodus/atoms": "^9.0.0",
|
|
37
|
-
"@exodus/basic-utils": "^
|
|
37
|
+
"@exodus/basic-utils": "^3.0.1",
|
|
38
38
|
"@exodus/core-selectors": "^3.0.0",
|
|
39
39
|
"@exodus/currency": "^5.0.2",
|
|
40
40
|
"@exodus/errors": "^3.0.0",
|
|
41
41
|
"@exodus/models": "^12.0.1",
|
|
42
42
|
"@exodus/multi-account-redux": "^2.0.1",
|
|
43
43
|
"@exodus/redux-dependency-injection": "^4.0.3",
|
|
44
|
+
"@exodus/safe-string": "^1.1.0",
|
|
44
45
|
"@exodus/typeforce": "^1.18.0",
|
|
45
46
|
"@exodus/zod": "^3.24.2",
|
|
46
47
|
"lodash": "^4.17.21",
|
|
@@ -67,5 +68,5 @@
|
|
|
67
68
|
"publishConfig": {
|
|
68
69
|
"access": "public"
|
|
69
70
|
},
|
|
70
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "f2359d974180d0af6e116f209da34dbee4ef8cff"
|
|
71
72
|
}
|