@exodus/fiat-balances 13.6.0 → 13.6.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.6.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@13.6.0...@exodus/fiat-balances@13.6.1) (2025-10-21)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- fix(fiat-balances): initialize USD balance properties immediately on plugin start (#14136)
|
|
11
|
+
|
|
6
12
|
## [13.6.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@13.5.3...@exodus/fiat-balances@13.6.0) (2025-07-10)
|
|
7
13
|
|
|
8
14
|
### Features
|
package/module/fiat-balances.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { set } from '@exodus/basic-utils'
|
|
2
2
|
import { isNumberUnit } from '@exodus/currency'
|
|
3
|
+
// eslint-disable-next-line no-restricted-imports -- TODO: Fix this the next time the file is edited.
|
|
3
4
|
import lodash from 'lodash'
|
|
4
5
|
import fiatCurrencies from '@exodus/fiat-currencies'
|
|
5
6
|
import { combine } from '@exodus/atoms'
|
|
@@ -9,12 +10,18 @@ const { isEqual } = lodash
|
|
|
9
10
|
// not super efficient, so we're assuming small objects, like { [walletAccount]: xyz }
|
|
10
11
|
const areKeysSame = (a, b) => isEqual(Object.keys(a).sort(), Object.keys(b).sort())
|
|
11
12
|
|
|
12
|
-
export const cloneBalances = (balances) =>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
+
}
|
|
18
25
|
|
|
19
26
|
class FiatBalances {
|
|
20
27
|
#logger
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/fiat-balances",
|
|
3
|
-
"version": "13.6.
|
|
3
|
+
"version": "13.6.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,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@exodus/atoms": "^9.0.0",
|
|
38
|
-
"@exodus/basic-utils": "^
|
|
38
|
+
"@exodus/basic-utils": "^3.0.1",
|
|
39
39
|
"@exodus/currency": "^5.0.2",
|
|
40
40
|
"@exodus/fiat-currencies": "^1.2.3",
|
|
41
41
|
"@exodus/formatting": "^9.0.0",
|
|
@@ -46,25 +46,26 @@
|
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@exodus/assets": "^11.0.0",
|
|
48
48
|
"@exodus/assets-base": "^10.0.0",
|
|
49
|
-
"@exodus/assets-feature": "^8.1
|
|
50
|
-
"@exodus/available-assets": "^8.
|
|
51
|
-
"@exodus/balances": "^13.
|
|
52
|
-
"@exodus/blockchain-metadata": "^
|
|
49
|
+
"@exodus/assets-feature": "^8.7.1",
|
|
50
|
+
"@exodus/available-assets": "^8.8.0",
|
|
51
|
+
"@exodus/balances": "^13.13.1",
|
|
52
|
+
"@exodus/blockchain-metadata": "^16.0.0",
|
|
53
53
|
"@exodus/combined-assets-meta": "^3.3.2",
|
|
54
|
-
"@exodus/enabled-assets": "^10.10.
|
|
54
|
+
"@exodus/enabled-assets": "^10.10.4",
|
|
55
55
|
"@exodus/favorite-assets": "^2.6.0",
|
|
56
56
|
"@exodus/fee-data-monitors": "^5.0.4",
|
|
57
|
-
"@exodus/models": "^12.
|
|
58
|
-
"@exodus/rates-monitor": "^4.14.
|
|
59
|
-
"@exodus/redux-dependency-injection": "^4.1.
|
|
57
|
+
"@exodus/models": "^12.17.1",
|
|
58
|
+
"@exodus/rates-monitor": "^4.14.7",
|
|
59
|
+
"@exodus/redux-dependency-injection": "^4.1.2",
|
|
60
60
|
"@exodus/solana-meta": "^2.0.0",
|
|
61
|
-
"@exodus/storage-memory": "^2.
|
|
62
|
-
"@exodus/wallet-accounts": "^
|
|
61
|
+
"@exodus/storage-memory": "^2.3.0",
|
|
62
|
+
"@exodus/wallet-accounts": "^20.1.0",
|
|
63
63
|
"events": "^3.3.0",
|
|
64
64
|
"redux": "^4.2.1"
|
|
65
65
|
},
|
|
66
66
|
"publishConfig": {
|
|
67
|
-
"access": "public"
|
|
67
|
+
"access": "public",
|
|
68
|
+
"provenance": false
|
|
68
69
|
},
|
|
69
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "19a582f72f1dad4ad63a8e6c2ea7680cd9a484d5"
|
|
70
71
|
}
|
package/plugin/analytics.js
CHANGED
|
@@ -4,26 +4,44 @@ const createFiatBalancesAnalyticsPlugin = ({
|
|
|
4
4
|
config: { assetsToTrackForBalances },
|
|
5
5
|
}) => {
|
|
6
6
|
let subscriptions = []
|
|
7
|
+
|
|
8
|
+
const setBalanceProperties = (balances) => {
|
|
9
|
+
const assetFiatBalances = assetsToTrackForBalances.reduce((acc, obj) => {
|
|
10
|
+
// Always set a value, default to 0 if balance doesn't exist
|
|
11
|
+
acc[obj.analyticsName] = balances?.byAsset[obj.assetName]?.balance.toDefaultNumber() ?? 0
|
|
12
|
+
return acc
|
|
13
|
+
}, Object.create(null))
|
|
14
|
+
analytics.setDefaultEventProperties({
|
|
15
|
+
...assetFiatBalances,
|
|
16
|
+
// Always set totalBalanceUsd, default to 0 if not available
|
|
17
|
+
totalBalanceUsd: balances?.totals?.balance?.toDefaultNumber() ?? 0,
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
|
|
7
21
|
const onStart = () => {
|
|
22
|
+
// Set initial properties to 0 immediately
|
|
23
|
+
setBalanceProperties(undefined)
|
|
24
|
+
|
|
25
|
+
// Start observing future updates
|
|
8
26
|
const unsubscribeBalancesAtom = fiatBalancesAtom.observe(({ balances }) => {
|
|
9
|
-
|
|
10
|
-
acc[obj.analyticsName] = balances?.byAsset[obj.assetName]?.balance.toDefaultNumber()
|
|
11
|
-
return acc
|
|
12
|
-
}, Object.create(null))
|
|
13
|
-
analytics.setDefaultEventProperties({
|
|
14
|
-
...assetFiatBalances,
|
|
15
|
-
totalBalanceUsd: balances?.totals?.balance?.toDefaultNumber(),
|
|
16
|
-
})
|
|
27
|
+
setBalanceProperties(balances)
|
|
17
28
|
})
|
|
18
29
|
|
|
19
30
|
subscriptions = [unsubscribeBalancesAtom]
|
|
20
31
|
}
|
|
21
32
|
|
|
33
|
+
const onUnlock = () => {
|
|
34
|
+
// Load current balance value after wallet is unlocked (non-blocking)
|
|
35
|
+
fiatBalancesAtom.get().then((currentValue) => {
|
|
36
|
+
setBalanceProperties(currentValue?.balances)
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
22
40
|
const onStop = () => {
|
|
23
41
|
subscriptions.forEach((unsubscribe) => unsubscribe())
|
|
24
42
|
}
|
|
25
43
|
|
|
26
|
-
return { onStart, onStop }
|
|
44
|
+
return { onStart, onUnlock, onStop }
|
|
27
45
|
}
|
|
28
46
|
|
|
29
47
|
const fiatBalancesAnalyticsPluginDefinition = {
|
package/report/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mapValues,
|
|
1
|
+
import { mapValues, pick, pickBy } from '@exodus/basic-utils'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* sample report
|
|
@@ -21,9 +21,8 @@ const fiatBalancesReportDefinition = {
|
|
|
21
21
|
])
|
|
22
22
|
|
|
23
23
|
const softwareWalletAccountNames = Object.keys(pickBy(walletAccounts, (w) => w.isSoftware))
|
|
24
|
-
return mapValues(
|
|
25
|
-
|
|
26
|
-
({ balance }) => balance.toDefaultString({ unit: true })
|
|
24
|
+
return mapValues(pick(balances.byWalletAccount, softwareWalletAccountNames), ({ balance }) =>
|
|
25
|
+
balance.toDefaultString({ unit: true })
|
|
27
26
|
)
|
|
28
27
|
},
|
|
29
28
|
}),
|