@exodus/balances 12.2.0 → 12.3.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,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
+ ## [12.3.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/balances@12.2.0...@exodus/balances@12.3.0) (2024-01-05)
7
+
8
+ ### Features
9
+
10
+ - add selector to compute balance by asset ([#5258](https://github.com/ExodusMovement/exodus-hydra/issues/5258)) ([4d50ddc](https://github.com/ExodusMovement/exodus-hydra/commit/4d50ddca485d1da794fafe04f40b1fef97a982ec))
11
+
6
12
  ## [12.2.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/balances@12.1.0...@exodus/balances@12.2.0) (2024-01-03)
7
13
 
8
14
  ### Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/balances",
3
- "version": "12.2.0",
3
+ "version": "12.3.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
  "jest": "^29.1.2",
59
59
  "redux": "^4.2.1"
60
60
  },
61
- "gitHead": "a158fff895557150c79a1cdec05a29d4587f5577"
61
+ "gitHead": "cd84b0179161212d65a695d8b61e91f154b2ecaa"
62
62
  }
@@ -0,0 +1,25 @@
1
+ const resultFunction = (walletAccounts, getAssetBalances) =>
2
+ walletAccounts.reduce((all, walletAccount) => {
3
+ for (const [assetName, balance] of Object.entries(getAssetBalances(walletAccount))) {
4
+ if (!all[assetName]) {
5
+ all[assetName] = balance
6
+ continue
7
+ }
8
+
9
+ all[assetName] = all[assetName].add(balance)
10
+ }
11
+
12
+ return all
13
+ }, {})
14
+
15
+ const byAssetSelector = {
16
+ id: 'byAsset',
17
+ resultFunction,
18
+ dependencies: [
19
+ //
20
+ { module: 'walletAccounts', selector: 'enabled' },
21
+ { selector: 'getAccountAssetsBalanceSelector' },
22
+ ],
23
+ }
24
+
25
+ export default byAssetSelector
@@ -1,4 +1,9 @@
1
+ import byAssetSelectorDefinition from './by-asset'
1
2
  import createUnconfirmedBalanceSelectorDefinition from './create-unconfirmed-balance'
2
3
  import getUnconfirmedBalanceSelectorDefinition from './get-unconfirmed-balance'
3
4
 
4
- export default [createUnconfirmedBalanceSelectorDefinition, getUnconfirmedBalanceSelectorDefinition]
5
+ export default [
6
+ byAssetSelectorDefinition,
7
+ createUnconfirmedBalanceSelectorDefinition,
8
+ getUnconfirmedBalanceSelectorDefinition,
9
+ ]