@exodus/balances 6.1.0 → 7.0.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,17 @@
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
+ ## [7.0.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/balances@6.1.0...@exodus/balances@7.0.0) (2023-07-21)
7
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ - balances module (#2756)
11
+
12
+ ### Features
13
+
14
+ - **balances:** has balance atom ([#2761](https://github.com/ExodusMovement/exodus-hydra/issues/2761)) ([1b9e51e](https://github.com/ExodusMovement/exodus-hydra/commit/1b9e51e3074e368840832fedc7da45298d442347))
15
+ - move balances to feature dir ([#2757](https://github.com/ExodusMovement/exodus-hydra/issues/2757)) ([8d0729a](https://github.com/ExodusMovement/exodus-hydra/commit/8d0729a470e9f1329814cca7e1ceb01bbc5db4b6))
16
+
6
17
  ## [6.1.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/balances@6.0.1...@exodus/balances@6.1.0) (2023-07-19)
7
18
 
8
19
  ### Features
@@ -0,0 +1,15 @@
1
+ import { compute } from '@exodus/atoms'
2
+ import { flatMap, map } from 'lodash'
3
+
4
+ // balancesAtom schema: { balances: { [walletAccount]: { [assetName]: { balance: NumberUnit } } } } }
5
+
6
+ const createHasBalanceAtom = ({ balancesAtom }) => {
7
+ const selector = ({ balances } = {}) => {
8
+ const numberUnits = flatMap(balances, (value) => map(value, 'balance'))
9
+ return numberUnits.some((numberUnit) => (numberUnit ? !numberUnit.isZero : false))
10
+ }
11
+
12
+ return compute({ atom: balancesAtom, selector })
13
+ }
14
+
15
+ export default createHasBalanceAtom
package/atoms/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import createBalancesAtom from './balances'
2
+ import createHasBalanceAtom from './has-balance'
2
3
 
3
4
  export const balancesAtomDefinition = {
4
5
  id: 'balancesAtom',
@@ -6,3 +7,10 @@ export const balancesAtomDefinition = {
6
7
  factory: createBalancesAtom,
7
8
  dependencies: [],
8
9
  }
10
+
11
+ export const hasBalanceAtomDefinition = {
12
+ id: 'hasBalanceAtom',
13
+ type: 'atom',
14
+ factory: createHasBalanceAtom,
15
+ dependencies: ['balancesAtom'],
16
+ }
package/index.js ADDED
@@ -0,0 +1,18 @@
1
+ import balancesDefinition from './module'
2
+ import { balancesAtomDefinition, hasBalanceAtomDefinition } from './atoms'
3
+
4
+ const balances = () => {
5
+ return {
6
+ id: 'balances',
7
+ definitions: [
8
+ {
9
+ definition: balancesDefinition,
10
+ writesAtoms: ['balancesAtom'],
11
+ },
12
+ { definition: balancesAtomDefinition },
13
+ { definition: hasBalanceAtomDefinition },
14
+ ],
15
+ }
16
+ }
17
+
18
+ export default balances
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/balances",
3
- "version": "6.1.0",
3
+ "version": "7.0.0",
4
4
  "description": "Tracks crypto balances across enabled wallet accounts.",
5
5
  "author": "Exodus Movement Inc.",
6
6
  "license": "UNLICENSED",
@@ -9,7 +9,9 @@
9
9
  "lint": "eslint . --ignore-path ../../.gitignore",
10
10
  "lint:fix": "yarn lint --fix"
11
11
  },
12
+ "main": "index.js",
12
13
  "files": [
14
+ "index.js",
13
15
  "module",
14
16
  "atoms",
15
17
  "README.md",
@@ -20,7 +22,7 @@
20
22
  "type": "git",
21
23
  "url": "git+https://github.com/ExodusMovement/exodus-hydra.git"
22
24
  },
23
- "homepage": "https://github.com/ExodusMovement/exodus-hydra/tree/master/modules/balances",
25
+ "homepage": "https://github.com/ExodusMovement/exodus-hydra/tree/master/features/balances",
24
26
  "bugs": {
25
27
  "url": "https://github.com/ExodusMovement/exodus-hydra/issues?q=is%3Aissue+is%3Aopen+label%3Abalances"
26
28
  },
@@ -44,5 +46,5 @@
44
46
  "events": "^3.3.0",
45
47
  "jest": "^29.1.2"
46
48
  },
47
- "gitHead": "4d8041f79655449cca977603e87d647c2a3e8df8"
49
+ "gitHead": "c85a6f44669c8d173606c3eb89fceaf650365df7"
48
50
  }