@exodus/balances 13.0.0 → 13.1.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 +16 -0
- package/atoms/asset-names-with-balance.js +40 -0
- package/atoms/assets-with-balance-count.js +3 -16
- package/atoms/funded-wallet-accounts.js +7 -5
- package/atoms/index.js +9 -1
- package/index.js +2 -0
- package/module/index.js +1 -1
- package/package.json +2 -2
- package/plugins/analytics.js +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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.1.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/balances@13.0.1...@exodus/balances@13.1.0) (2024-04-09)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- asset-names-with-balance atom ([#6406](https://github.com/ExodusMovement/exodus-hydra/issues/6406)) ([f006357](https://github.com/ExodusMovement/exodus-hydra/commit/f006357b81478fcb443d478d626cec89196f57cf))
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- use `assetNamesWithBalanceAtomDefinition` ([#6425](https://github.com/ExodusMovement/exodus-hydra/issues/6425)) ([9b65a23](https://github.com/ExodusMovement/exodus-hydra/commit/9b65a2367778d50c877a5c235784ee47938d101a))
|
|
15
|
+
|
|
16
|
+
## [13.0.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/balances@13.0.0...@exodus/balances@13.0.1) (2024-04-05)
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
- dedupe funded-wallet-accounts ([#6399](https://github.com/ExodusMovement/exodus-hydra/issues/6399)) ([bb9c97f](https://github.com/ExodusMovement/exodus-hydra/commit/bb9c97f08aed19a4b3390c1ec9ba46a1459a249c))
|
|
21
|
+
|
|
6
22
|
## [13.0.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/balances@12.6.1...@exodus/balances@13.0.0) (2024-03-21)
|
|
7
23
|
|
|
8
24
|
### ⚠ BREAKING CHANGES
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { compute, dedupe } from '@exodus/atoms'
|
|
2
|
+
|
|
3
|
+
const setsAreEqual = (setA, setB) => {
|
|
4
|
+
if (setA.size !== setB.size) {
|
|
5
|
+
return false
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
for (const item of setA) {
|
|
9
|
+
if (!setB.has(item)) {
|
|
10
|
+
return false
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return true
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const createAssetNamesWithBalanceAtom = ({ balancesAtom }) => {
|
|
18
|
+
let previousValue = new Set()
|
|
19
|
+
const selector = ({ balances }) => {
|
|
20
|
+
const assetsWithBalances = new Set()
|
|
21
|
+
|
|
22
|
+
Object.values(balances).forEach((accountBalances) => {
|
|
23
|
+
Object.keys(accountBalances).forEach((assetName) => {
|
|
24
|
+
if (!accountBalances[assetName]?.balance.isZero) {
|
|
25
|
+
assetsWithBalances.add(assetName)
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
if (!setsAreEqual(assetsWithBalances, previousValue)) {
|
|
31
|
+
previousValue = assetsWithBalances
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return previousValue
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return dedupe(compute({ atom: balancesAtom, selector }))
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default createAssetNamesWithBalanceAtom
|
|
@@ -1,21 +1,8 @@
|
|
|
1
1
|
import { compute } from '@exodus/atoms'
|
|
2
2
|
|
|
3
|
-
const createAssetsWithBalanceCountAtom = ({
|
|
4
|
-
const selector = (
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.values(balances).forEach((accountBalances) => {
|
|
8
|
-
Object.keys(accountBalances).forEach((assetName) => {
|
|
9
|
-
if (!accountBalances[assetName]?.balance.isZero) {
|
|
10
|
-
assetsWithBalances.add(assetName)
|
|
11
|
-
}
|
|
12
|
-
})
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
return assetsWithBalances.size
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return compute({ atom: balancesAtom, selector })
|
|
3
|
+
const createAssetsWithBalanceCountAtom = ({ assetNamesWithBalanceAtom }) => {
|
|
4
|
+
const selector = (assetNamesWithBalance) => assetNamesWithBalance.size
|
|
5
|
+
return compute({ atom: assetNamesWithBalanceAtom, selector })
|
|
19
6
|
}
|
|
20
7
|
|
|
21
8
|
export default createAssetsWithBalanceCountAtom
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { combine, compute } from '@exodus/atoms'
|
|
1
|
+
import { combine, compute, dedupe } from '@exodus/atoms'
|
|
2
2
|
import { mapValues } from '@exodus/basic-utils'
|
|
3
3
|
|
|
4
4
|
const computeFundedWalletAccounts = ({ walletAccounts, balances }) => {
|
|
@@ -14,10 +14,12 @@ const createFundedWalletAccountsAtom = ({ balancesAtom, enabledWalletAccountsAto
|
|
|
14
14
|
balances: balancesAtom,
|
|
15
15
|
})
|
|
16
16
|
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
return dedupe(
|
|
18
|
+
compute({
|
|
19
|
+
atom: walletAccountsBalanceAtom,
|
|
20
|
+
selector: computeFundedWalletAccounts,
|
|
21
|
+
})
|
|
22
|
+
)
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
export default createFundedWalletAccountsAtom
|
package/atoms/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import createAssetNamesWithBalanceAtom from './asset-names-with-balance'
|
|
1
2
|
import createAssetsWithBalanceCountAtom from './assets-with-balance-count'
|
|
2
3
|
import createBalancesAtom from './balances'
|
|
3
4
|
import createFundedWalletAccountsAtom from './funded-wallet-accounts'
|
|
@@ -24,9 +25,16 @@ export const fundedWalletAccountsAtomDefinition = {
|
|
|
24
25
|
dependencies: ['balancesAtom', 'enabledWalletAccountsAtom'],
|
|
25
26
|
}
|
|
26
27
|
|
|
28
|
+
export const assetNamesWithBalanceAtomDefinition = {
|
|
29
|
+
id: 'assetNamesWithBalanceAtom',
|
|
30
|
+
type: 'atom',
|
|
31
|
+
factory: createAssetNamesWithBalanceAtom,
|
|
32
|
+
dependencies: ['balancesAtom'],
|
|
33
|
+
}
|
|
34
|
+
|
|
27
35
|
export const assetsWithBalanceCountAtomDefinition = {
|
|
28
36
|
id: 'assetsWithBalanceCountAtom',
|
|
29
37
|
type: 'atom',
|
|
30
38
|
factory: createAssetsWithBalanceCountAtom,
|
|
31
|
-
dependencies: ['
|
|
39
|
+
dependencies: ['assetNamesWithBalanceAtom'],
|
|
32
40
|
}
|
package/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
hasBalanceAtomDefinition,
|
|
5
5
|
fundedWalletAccountsAtomDefinition,
|
|
6
6
|
assetsWithBalanceCountAtomDefinition,
|
|
7
|
+
assetNamesWithBalanceAtomDefinition,
|
|
7
8
|
} from './atoms'
|
|
8
9
|
import balancesReportDefinition from './report'
|
|
9
10
|
import { balancesLifecyclePluginDefinition, balancesAnalyticsPluginDefinition } from './plugins'
|
|
@@ -32,6 +33,7 @@ const balances = (walletConfig) => {
|
|
|
32
33
|
config,
|
|
33
34
|
},
|
|
34
35
|
{ definition: balancesAtomDefinition },
|
|
36
|
+
{ definition: assetNamesWithBalanceAtomDefinition },
|
|
35
37
|
{ definition: assetsWithBalanceCountAtomDefinition },
|
|
36
38
|
{
|
|
37
39
|
definition: hasBalanceAtomDefinition,
|
package/module/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isNumberUnit } from '@exodus/currency'
|
|
2
2
|
import { TxSet } from '@exodus/models'
|
|
3
|
-
import ExodusModule from '@exodus/module'
|
|
3
|
+
import ExodusModule from '@exodus/module' // eslint-disable-line import/no-deprecated
|
|
4
4
|
import { cloneDeepWith, isEmpty, merge, set, zipObject } from 'lodash'
|
|
5
5
|
import { difference, flattenToPaths, pick } from '@exodus/basic-utils'
|
|
6
6
|
import makeConcurrent from 'make-concurrent'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/balances",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.1.0",
|
|
4
4
|
"description": "Tracks crypto balances across enabled wallet accounts.",
|
|
5
5
|
"author": "Exodus Movement Inc.",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"events": "^3.3.0",
|
|
59
59
|
"redux": "^4.2.1"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "e3229e4313cd509df06eb7b689f29a7d257f82f2"
|
|
62
62
|
}
|
package/plugins/analytics.js
CHANGED
|
@@ -6,14 +6,14 @@ const createBalancesAnalyticsPlugin = ({
|
|
|
6
6
|
let subscriptions = []
|
|
7
7
|
|
|
8
8
|
const onStart = () => {
|
|
9
|
-
analytics.
|
|
9
|
+
analytics.requireDefaultEventProperties(['hasBalance', 'numberOfAssets'])
|
|
10
10
|
|
|
11
11
|
const unsubscribeBalanceAtom = hasBalanceAtom.observe((hasBalance) =>
|
|
12
|
-
analytics.
|
|
12
|
+
analytics.setDefaultEventProperties({ hasBalance })
|
|
13
13
|
)
|
|
14
14
|
|
|
15
15
|
const unsubscribeBalanceCountAtom = assetsWithBalanceCountAtom.observe((numberOfAssets) =>
|
|
16
|
-
analytics.
|
|
16
|
+
analytics.setDefaultEventProperties({ numberOfAssets })
|
|
17
17
|
)
|
|
18
18
|
|
|
19
19
|
subscriptions = [unsubscribeBalanceAtom, unsubscribeBalanceCountAtom]
|