@exodus/balances 13.5.0 → 13.5.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 +12 -0
- package/atoms/asset-total-wallet-amounts.js +13 -12
- package/module/index.js +9 -9
- package/package.json +6 -6
- package/plugins/analytics.js +1 -1
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.5.2](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/balances@13.5.1...@exodus/balances@13.5.2) (2025-01-03)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- fix: only compute balances for available assets (#10958)
|
|
11
|
+
|
|
12
|
+
## [13.5.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/balances@13.5.0...@exodus/balances@13.5.1) (2024-11-29)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
- fix: balances map equality check (#10620)
|
|
17
|
+
|
|
6
18
|
## [13.5.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/balances@13.4.0...@exodus/balances@13.5.0) (2024-11-29)
|
|
7
19
|
|
|
8
20
|
### Features
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { compute, dedupe } from '@exodus/atoms'
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const numberUnitMapsAreEqual = (mapA, mapB) => {
|
|
4
4
|
if (mapA.size !== mapB.size) {
|
|
5
5
|
return false
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
for (const
|
|
9
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
assetsWithBalances.
|
|
27
|
-
assetName
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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 (!
|
|
37
|
+
if (!numberUnitMapsAreEqual(assetsWithBalances, previousValue)) {
|
|
37
38
|
previousValue = assetsWithBalances
|
|
38
39
|
}
|
|
39
40
|
|
package/module/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isNumberUnit } from '@exodus/currency'
|
|
2
2
|
import { TxSet } from '@exodus/models'
|
|
3
3
|
import lodash from 'lodash'
|
|
4
|
+
import { difference as getChanges } from '@exodus/atoms'
|
|
4
5
|
import { difference, flattenToPaths, pick, set } from '@exodus/basic-utils'
|
|
5
6
|
import makeConcurrent from 'make-concurrent'
|
|
6
7
|
import { processAssetBalances, validateBalances } from './balances-utils.js'
|
|
@@ -22,7 +23,7 @@ const zipNonNull = (keys, values) =>
|
|
|
22
23
|
class Balances {
|
|
23
24
|
#logger
|
|
24
25
|
#assetsModule
|
|
25
|
-
#
|
|
26
|
+
#availableAssetNamesAtom
|
|
26
27
|
#balanceFieldsConfig
|
|
27
28
|
#balanceFields
|
|
28
29
|
#walletAccounts = [] // string[]
|
|
@@ -38,7 +39,7 @@ class Balances {
|
|
|
38
39
|
|
|
39
40
|
constructor({
|
|
40
41
|
assetsModule,
|
|
41
|
-
|
|
42
|
+
availableAssetNamesAtom,
|
|
42
43
|
enabledWalletAccountsAtom,
|
|
43
44
|
config,
|
|
44
45
|
logger,
|
|
@@ -48,7 +49,7 @@ class Balances {
|
|
|
48
49
|
}) {
|
|
49
50
|
this.#logger = logger
|
|
50
51
|
this.#assetsModule = assetsModule
|
|
51
|
-
this.#
|
|
52
|
+
this.#availableAssetNamesAtom = availableAssetNamesAtom
|
|
52
53
|
this.#balanceFieldsConfig = config?.balanceFieldsConfig || defaultConfig.balanceFieldsConfig
|
|
53
54
|
this.#balanceFields = config?.balanceFields || defaultConfig.balanceFields
|
|
54
55
|
this.#balancesAtom = balancesAtom
|
|
@@ -101,10 +102,9 @@ class Balances {
|
|
|
101
102
|
this.#handleTxLogUpdate({ walletAccount, assetName, txLog })
|
|
102
103
|
)
|
|
103
104
|
),
|
|
104
|
-
this.#
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
105
|
+
getChanges(this.#availableAssetNamesAtom).observe(({ previous = [], current }) => {
|
|
106
|
+
const added = difference(current, previous)
|
|
107
|
+
if (added.length > 0) this.#onAssetsChanged(added)
|
|
108
108
|
})
|
|
109
109
|
)
|
|
110
110
|
}
|
|
@@ -217,7 +217,7 @@ class Balances {
|
|
|
217
217
|
|
|
218
218
|
#onAssetsChanged = async (added) => {
|
|
219
219
|
if (
|
|
220
|
-
added.every((
|
|
220
|
+
added.every((name) =>
|
|
221
221
|
this.#walletAccounts.every((walletAccount) => !!this.#balances?.[walletAccount]?.[name])
|
|
222
222
|
)
|
|
223
223
|
) {
|
|
@@ -362,13 +362,13 @@ const balancesDefinition = {
|
|
|
362
362
|
factory: createBalances,
|
|
363
363
|
dependencies: [
|
|
364
364
|
'assetsModule',
|
|
365
|
+
'availableAssetNamesAtom',
|
|
365
366
|
'enabledWalletAccountsAtom',
|
|
366
367
|
'config',
|
|
367
368
|
'logger',
|
|
368
369
|
'balancesAtom',
|
|
369
370
|
'txLogsAtom',
|
|
370
371
|
'accountStatesAtom',
|
|
371
|
-
'assetsAtom',
|
|
372
372
|
],
|
|
373
373
|
public: true,
|
|
374
374
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/balances",
|
|
3
|
-
"version": "13.5.
|
|
3
|
+
"version": "13.5.2",
|
|
4
4
|
"description": "Tracks crypto balances across enabled wallet accounts.",
|
|
5
5
|
"author": "Exodus Movement, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -51,19 +51,19 @@
|
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@exodus/assets": "^11.0.0",
|
|
53
53
|
"@exodus/assets-base": "^10.0.0",
|
|
54
|
-
"@exodus/assets-feature": "^
|
|
54
|
+
"@exodus/assets-feature": "^6.0.1",
|
|
55
55
|
"@exodus/available-assets": "^8.7.0",
|
|
56
56
|
"@exodus/bitcoin-meta": "^2.0.0",
|
|
57
|
-
"@exodus/blockchain-metadata": "^15.7.
|
|
57
|
+
"@exodus/blockchain-metadata": "^15.7.1",
|
|
58
58
|
"@exodus/ethereum-meta": "^2.0.0",
|
|
59
|
-
"@exodus/fee-data-monitors": "^5.0.
|
|
59
|
+
"@exodus/fee-data-monitors": "^5.0.3",
|
|
60
60
|
"@exodus/storage-memory": "^2.2.2",
|
|
61
|
-
"@exodus/wallet-accounts": "^17.1.
|
|
61
|
+
"@exodus/wallet-accounts": "^17.1.3",
|
|
62
62
|
"events": "^3.3.0",
|
|
63
63
|
"redux": "^4.2.1"
|
|
64
64
|
},
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "2b30d69ddf8f4d0ebd3bcc4d4280d3ea12906673"
|
|
69
69
|
}
|
package/plugins/analytics.js
CHANGED
|
@@ -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
|
|