@exodus/balances 7.0.0 → 7.2.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 +17 -0
- package/index.js +2 -0
- package/module/index.js +17 -8
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,23 @@
|
|
|
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.2.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/balances@7.1.0...@exodus/balances@7.2.0) (2023-08-01)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- add balances report ([#3059](https://github.com/ExodusMovement/exodus-hydra/issues/3059)) ([a06ae1c](https://github.com/ExodusMovement/exodus-hydra/commit/a06ae1c988fb9abc8899caa0093528495496df1f))
|
|
11
|
+
|
|
12
|
+
## [7.1.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/balances@6.1.0...@exodus/balances@7.1.0) (2023-07-21)
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
- **balances:** has balance atom ([#2761](https://github.com/ExodusMovement/exodus-hydra/issues/2761)) ([1b9e51e](https://github.com/ExodusMovement/exodus-hydra/commit/1b9e51e3074e368840832fedc7da45298d442347))
|
|
17
|
+
- move balances to feature dir ([#2757](https://github.com/ExodusMovement/exodus-hydra/issues/2757)) ([8d0729a](https://github.com/ExodusMovement/exodus-hydra/commit/8d0729a470e9f1329814cca7e1ceb01bbc5db4b6))
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
- don't crash when a single asset fails to get balance ([#2828](https://github.com/ExodusMovement/exodus-hydra/issues/2828)) ([547ddac](https://github.com/ExodusMovement/exodus-hydra/commit/547ddac4b1a7e1e81db1f3a504dacada50e9ae62))
|
|
22
|
+
|
|
6
23
|
## [7.0.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/balances@6.1.0...@exodus/balances@7.0.0) (2023-07-21)
|
|
7
24
|
|
|
8
25
|
### ⚠ BREAKING CHANGES
|
package/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import balancesDefinition from './module'
|
|
2
2
|
import { balancesAtomDefinition, hasBalanceAtomDefinition } from './atoms'
|
|
3
|
+
import balancesReportDefinition from './report'
|
|
3
4
|
|
|
4
5
|
const balances = () => {
|
|
5
6
|
return {
|
|
@@ -11,6 +12,7 @@ const balances = () => {
|
|
|
11
12
|
},
|
|
12
13
|
{ definition: balancesAtomDefinition },
|
|
13
14
|
{ definition: hasBalanceAtomDefinition },
|
|
15
|
+
{ definition: balancesReportDefinition },
|
|
14
16
|
],
|
|
15
17
|
}
|
|
16
18
|
}
|
package/module/index.js
CHANGED
|
@@ -53,13 +53,15 @@ class Balances extends ExodusModule {
|
|
|
53
53
|
this.#pushIntoSharedQueue(() => fn.apply(this, args))
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
// sanitize args in case someone passes something sensitive, e.g. getBalance({ walletAccount, mnemonic })
|
|
57
|
+
// when only `{ walletAccount }` is expected
|
|
56
58
|
const captureErrors =
|
|
57
|
-
(fn, name) =>
|
|
59
|
+
({ fn, name, sanitizeArgs = () => {} }) =>
|
|
58
60
|
async (...args) => {
|
|
59
61
|
try {
|
|
60
62
|
return await fn(...args)
|
|
61
63
|
} catch (error) {
|
|
62
|
-
this.emit('error', { fn: name, error })
|
|
64
|
+
this.emit('error', { fn: name, error, args: sanitizeArgs(...args) })
|
|
63
65
|
throw error
|
|
64
66
|
}
|
|
65
67
|
}
|
|
@@ -68,12 +70,17 @@ class Balances extends ExodusModule {
|
|
|
68
70
|
this.#updateAssetSource = shareQueue(this.#updateAssetSource)
|
|
69
71
|
this.#handleTxLogUpdate = shareQueue(this.#handleTxLogUpdate)
|
|
70
72
|
this.#recompute = shareQueue(this.#recompute)
|
|
71
|
-
this.#getBalancesForAssetSource = captureErrors(
|
|
72
|
-
this.#getBalancesForAssetSource,
|
|
73
|
-
'getBalancesForAssetSource'
|
|
74
|
-
|
|
73
|
+
this.#getBalancesForAssetSource = captureErrors({
|
|
74
|
+
fn: this.#getBalancesForAssetSource,
|
|
75
|
+
name: 'getBalancesForAssetSource',
|
|
76
|
+
sanitizeArgs: ({ walletAccount, assetName }) => ({ walletAccount, assetName }),
|
|
77
|
+
})
|
|
75
78
|
|
|
76
|
-
this.#setWalletAccounts = captureErrors(
|
|
79
|
+
this.#setWalletAccounts = captureErrors({
|
|
80
|
+
fn: this.#setWalletAccounts,
|
|
81
|
+
name: 'setWalletAccounts',
|
|
82
|
+
sanitizeArgs: (walletAccounts) => walletAccounts,
|
|
83
|
+
})
|
|
77
84
|
|
|
78
85
|
blockchainMetadata.once('load-wallet-accounts', () => {
|
|
79
86
|
// eslint-disable-next-line hydra/module-side-effects
|
|
@@ -106,6 +113,7 @@ class Balances extends ExodusModule {
|
|
|
106
113
|
})
|
|
107
114
|
return
|
|
108
115
|
}
|
|
116
|
+
|
|
109
117
|
return this.#updateAssetSource(opts)
|
|
110
118
|
}
|
|
111
119
|
|
|
@@ -177,10 +185,11 @@ class Balances extends ExodusModule {
|
|
|
177
185
|
|
|
178
186
|
#getBalancesForWalletAccount = async ({ walletAccount }) => {
|
|
179
187
|
const assetNames = this.#getSupportedAssetNames()
|
|
180
|
-
const
|
|
188
|
+
const results = await Promise.allSettled(
|
|
181
189
|
assetNames.map((assetName) => this.#getBalancesForAssetSource({ assetName, walletAccount }))
|
|
182
190
|
)
|
|
183
191
|
|
|
192
|
+
const balances = results.map(({ value }) => value).filter(Boolean)
|
|
184
193
|
return merge(Object.create(null), ...balances)
|
|
185
194
|
}
|
|
186
195
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/balances",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.0",
|
|
4
4
|
"description": "Tracks crypto balances across enabled wallet accounts.",
|
|
5
5
|
"author": "Exodus Movement Inc.",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
},
|
|
12
12
|
"main": "index.js",
|
|
13
13
|
"files": [
|
|
14
|
-
"index.js",
|
|
15
14
|
"module",
|
|
16
15
|
"atoms",
|
|
17
16
|
"README.md",
|
|
@@ -27,7 +26,7 @@
|
|
|
27
26
|
"url": "https://github.com/ExodusMovement/exodus-hydra/issues?q=is%3Aissue+is%3Aopen+label%3Abalances"
|
|
28
27
|
},
|
|
29
28
|
"dependencies": {
|
|
30
|
-
"@exodus/atoms": "^5.
|
|
29
|
+
"@exodus/atoms": "^5.4.0",
|
|
31
30
|
"@exodus/basic-utils": "^2.0.0",
|
|
32
31
|
"@exodus/currency": "^2.1.2",
|
|
33
32
|
"@exodus/module": "^1.1.0",
|
|
@@ -38,6 +37,8 @@
|
|
|
38
37
|
"@exodus/blockchain-metadata": "^6.0.0"
|
|
39
38
|
},
|
|
40
39
|
"devDependencies": {
|
|
40
|
+
"@exodus/assets": "^8.0.94",
|
|
41
|
+
"@exodus/assets-base": "^8.1.10",
|
|
41
42
|
"@exodus/blockchain-metadata": "^8.0.0",
|
|
42
43
|
"@exodus/models": "^8.9.0",
|
|
43
44
|
"@exodus/storage-memory": "*",
|
|
@@ -46,5 +47,5 @@
|
|
|
46
47
|
"events": "^3.3.0",
|
|
47
48
|
"jest": "^29.1.2"
|
|
48
49
|
},
|
|
49
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "91e322589102bc3fa4886b7bd254e08d1dd766da"
|
|
50
51
|
}
|