@exodus/balances 12.5.0 → 12.6.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 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
+ ## [12.6.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/balances@12.5.1...@exodus/balances@12.6.0) (2024-01-12)
7
+
8
+ ### Features
9
+
10
+ - move assets with balances count atom to balances module ([#5379](https://github.com/ExodusMovement/exodus-hydra/issues/5379)) ([4d86b5a](https://github.com/ExodusMovement/exodus-hydra/commit/4d86b5a080cf9cf8bebf029e474cfe138a73d49e))
11
+
12
+ ## [12.5.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/balances@12.5.0...@exodus/balances@12.5.1) (2024-01-11)
13
+
14
+ ### Bug Fixes
15
+
16
+ - unconfirmed balance selector must account only for incomming txs ([#5351](https://github.com/ExodusMovement/exodus-hydra/issues/5351)) ([4cf6565](https://github.com/ExodusMovement/exodus-hydra/commit/4cf656532f7b336734d3fc091f00e92642b5fa9c))
17
+
6
18
  ## [12.5.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/balances@12.4.0...@exodus/balances@12.5.0) (2024-01-11)
7
19
 
8
20
  ### Features
@@ -0,0 +1,21 @@
1
+ import { compute } from '@exodus/atoms'
2
+
3
+ const createAssetsWithBalanceCountAtom = ({ balancesAtom }) => {
4
+ const selector = ({ balances }) => {
5
+ const assetsWithBalances = new Set()
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 })
19
+ }
20
+
21
+ export default createAssetsWithBalanceCountAtom
package/atoms/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import createAssetsWithBalanceCountAtom from './assets-with-balance-count'
1
2
  import createBalancesAtom from './balances'
2
3
  import createFundedWalletAccountsAtom from './funded-wallet-accounts'
3
4
  import createHasBalanceAtom from './has-balance'
@@ -22,3 +23,10 @@ export const fundedWalletAccountsAtomDefinition = {
22
23
  factory: createFundedWalletAccountsAtom,
23
24
  dependencies: ['balancesAtom', 'enabledWalletAccountsAtom'],
24
25
  }
26
+
27
+ export const assetsWithBalanceCountAtomDefinition = {
28
+ id: 'assetsWithBalanceCountAtom',
29
+ type: 'atom',
30
+ factory: createAssetsWithBalanceCountAtom,
31
+ dependencies: ['balancesAtom'],
32
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/balances",
3
- "version": "12.5.0",
3
+ "version": "12.6.0",
4
4
  "description": "Tracks crypto balances across enabled wallet accounts.",
5
5
  "author": "Exodus Movement Inc.",
6
6
  "license": "UNLICENSED",
@@ -46,7 +46,7 @@
46
46
  "devDependencies": {
47
47
  "@exodus/assets": "^8.0.94",
48
48
  "@exodus/assets-base": "^8.1.10",
49
- "@exodus/assets-feature": "^4.0.1",
49
+ "@exodus/assets-feature": "^4.1.0",
50
50
  "@exodus/bitcoin-meta": "^1.0.1",
51
51
  "@exodus/blockchain-metadata": "^9.0.1",
52
52
  "@exodus/ethereum-meta": "^1.0.30",
@@ -58,5 +58,5 @@
58
58
  "jest": "^29.1.2",
59
59
  "redux": "^4.2.1"
60
60
  },
61
- "gitHead": "49b8b73234d3e602779ec5965b600eb1398ed6c7"
61
+ "gitHead": "873f103b45c562e5fd3369a30bfb7c7e95363efa"
62
62
  }
@@ -1,16 +1,26 @@
1
- const createBalancesAnalyticsPlugin = ({ analytics, hasBalanceAtom }) => {
2
- let unsubscribe
1
+ const createBalancesAnalyticsPlugin = ({
2
+ analytics,
3
+ hasBalanceAtom,
4
+ assetsWithBalanceCountAtom,
5
+ }) => {
6
+ let subscriptions = []
3
7
 
4
8
  const onStart = () => {
5
- analytics.requireDefaultProperties(['hasBalance'])
9
+ analytics.requireDefaultProperties(['hasBalance', 'numberOfAssets'])
6
10
 
7
- unsubscribe = hasBalanceAtom.observe((hasBalance) => {
11
+ const unsubscribeBalanceAtom = hasBalanceAtom.observe((hasBalance) =>
8
12
  analytics.setDefaultProperties({ hasBalance })
9
- })
13
+ )
14
+
15
+ const unsubscribeBalanceCountAtom = assetsWithBalanceCountAtom.observe((numberOfAssets) =>
16
+ analytics.setDefaultProperties({ numberOfAssets })
17
+ )
18
+
19
+ subscriptions = [unsubscribeBalanceAtom, unsubscribeBalanceCountAtom]
10
20
  }
11
21
 
12
22
  const onStop = () => {
13
- unsubscribe?.()
23
+ subscriptions.forEach((unsubscribe) => unsubscribe())
14
24
  }
15
25
 
16
26
  return { onStart, onStop }
package/plugins/index.js CHANGED
@@ -12,5 +12,5 @@ export const balancesAnalyticsPluginDefinition = {
12
12
  id: 'balancesAnalyticsPlugin',
13
13
  type: 'plugin',
14
14
  factory: createBalancesAnalyticsPlugin,
15
- dependencies: ['analytics', 'hasBalanceAtom'],
15
+ dependencies: ['analytics', 'hasBalanceAtom', 'assetsWithBalanceCountAtom'],
16
16
  }
@@ -5,11 +5,11 @@ export const getUnconfirmedBalance = ({ asset, txs }) => {
5
5
  let result = asset.currency.ZERO
6
6
 
7
7
  for (const tx of txs) {
8
- const isIncommingTX = tx.coinAmount.isPositive
8
+ const isIncommingTX = !tx.sent
9
9
  const isUnconfirmed = !tx.failed && tx.pending
10
10
 
11
- if (isUnconfirmed) {
12
- result = isIncommingTX ? result.add(tx.coinAmount) : result.sub(tx.coinAmount)
11
+ if (isUnconfirmed && isIncommingTX) {
12
+ result = result.add(tx.coinAmount)
13
13
  }
14
14
  }
15
15