@exodus/balances 8.1.0 → 9.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 +10 -0
- package/module/index.js +17 -9
- package/package.json +3 -3
- package/plugins/index.js +7 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
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
|
+
## [9.0.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/balances@8.1.0...@exodus/balances@9.0.0) (2023-08-21)
|
|
7
|
+
|
|
8
|
+
### ⚠ BREAKING CHANGES
|
|
9
|
+
|
|
10
|
+
- balances.load (#3383)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- balances.load ([#3383](https://github.com/ExodusMovement/exodus-hydra/issues/3383)) ([754179f](https://github.com/ExodusMovement/exodus-hydra/commit/754179f65713afc19490240702aa0fee18047073))
|
|
15
|
+
|
|
6
16
|
## [8.1.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/balances@8.0.0...@exodus/balances@8.1.0) (2023-08-11)
|
|
7
17
|
|
|
8
18
|
### Features
|
package/module/index.js
CHANGED
|
@@ -29,6 +29,10 @@ class Balances extends ExodusModule {
|
|
|
29
29
|
#oldBalances = Object.create(null)
|
|
30
30
|
#balances = Object.create(null)
|
|
31
31
|
#balancesAtom
|
|
32
|
+
#accountStatesAtom
|
|
33
|
+
#txLogsAtom
|
|
34
|
+
#enabledWalletAccountsAtom
|
|
35
|
+
#loaded = false
|
|
32
36
|
|
|
33
37
|
constructor({
|
|
34
38
|
assetsModule,
|
|
@@ -46,6 +50,9 @@ class Balances extends ExodusModule {
|
|
|
46
50
|
this.#blockchainMetadata = blockchainMetadata
|
|
47
51
|
this.#balanceFields = balanceFields
|
|
48
52
|
this.#balancesAtom = balancesAtom
|
|
53
|
+
this.#accountStatesAtom = accountStatesAtom
|
|
54
|
+
this.#txLogsAtom = txLogsAtom
|
|
55
|
+
this.#enabledWalletAccountsAtom = enabledWalletAccountsAtom
|
|
49
56
|
|
|
50
57
|
const shareQueue =
|
|
51
58
|
(fn) =>
|
|
@@ -83,27 +90,28 @@ class Balances extends ExodusModule {
|
|
|
83
90
|
name: 'setWalletAccounts',
|
|
84
91
|
sanitizeArgs: (walletAccounts) => walletAccounts,
|
|
85
92
|
})
|
|
93
|
+
}
|
|
86
94
|
|
|
87
|
-
|
|
88
|
-
|
|
95
|
+
load = () => {
|
|
96
|
+
if (this.#loaded) return
|
|
97
|
+
this.#loaded = true
|
|
98
|
+
this.#enabledWalletAccountsAtom.observe((payload) => {
|
|
89
99
|
this.#setWalletAccounts(Object.keys(payload))
|
|
90
100
|
})
|
|
91
101
|
|
|
92
|
-
|
|
93
|
-
accountStatesAtom.observe(({ changes }) =>
|
|
102
|
+
this.#accountStatesAtom.observe(({ changes }) =>
|
|
94
103
|
flattenToPaths(changes).forEach(([walletAccount, assetName, accountState]) =>
|
|
95
104
|
this.#handleAccountStateUpdate({ walletAccount, assetName, accountState })
|
|
96
105
|
)
|
|
97
106
|
)
|
|
98
107
|
|
|
99
|
-
|
|
100
|
-
txLogsAtom.observe(({ changes }) =>
|
|
108
|
+
this.#txLogsAtom.observe(({ changes }) =>
|
|
101
109
|
flattenToPaths(changes).forEach(([walletAccount, assetName, txLog]) =>
|
|
102
110
|
this.#handleTxLogUpdate({ walletAccount, assetName, txLog })
|
|
103
111
|
)
|
|
104
112
|
)
|
|
105
113
|
|
|
106
|
-
assetsModule.on('assets-add', this.#onAssetsChanged)
|
|
114
|
+
this.#assetsModule.on('assets-add', this.#onAssetsChanged)
|
|
107
115
|
}
|
|
108
116
|
|
|
109
117
|
#getAsset = (assetName) => this.#assetsModule.getAsset(assetName)
|
|
@@ -112,7 +120,7 @@ class Balances extends ExodusModule {
|
|
|
112
120
|
|
|
113
121
|
#handleAccountStateUpdate = async (opts) => {
|
|
114
122
|
if (!this.#ready) {
|
|
115
|
-
this._logger.log(
|
|
123
|
+
this._logger.log('ignore update from account-state event.', {
|
|
116
124
|
isReady: this.#ready,
|
|
117
125
|
})
|
|
118
126
|
return
|
|
@@ -123,7 +131,7 @@ class Balances extends ExodusModule {
|
|
|
123
131
|
|
|
124
132
|
#handleTxLogUpdate = (opts) => {
|
|
125
133
|
if (!this.#ready) {
|
|
126
|
-
this._logger.log(
|
|
134
|
+
this._logger.log('ignore update from tx-log event.', {
|
|
127
135
|
isReady: this.#ready,
|
|
128
136
|
})
|
|
129
137
|
return
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/balances",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "Tracks crypto balances across enabled wallet accounts.",
|
|
5
5
|
"author": "Exodus Movement Inc.",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"url": "https://github.com/ExodusMovement/exodus-hydra/issues?q=is%3Aissue+is%3Aopen+label%3Abalances"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@exodus/atoms": "^5.
|
|
31
|
+
"@exodus/atoms": "^5.5.0",
|
|
32
32
|
"@exodus/basic-utils": "^2.1.0",
|
|
33
33
|
"@exodus/currency": "^2.1.2",
|
|
34
34
|
"@exodus/module": "^1.1.0",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"events": "^3.3.0",
|
|
50
50
|
"jest": "^29.1.2"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "6de4a6859547f6d1bbce9506cc6f32480d9c728b"
|
|
53
53
|
}
|
package/plugins/index.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
const createBalancesPlugin = ({ balancesAtom, port }) => {
|
|
1
|
+
const createBalancesPlugin = ({ balancesAtom, port, balances }) => {
|
|
2
2
|
const onUnlock = () => {
|
|
3
3
|
balancesAtom.get().then((value) => port.emit('balancesAtom', value))
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const onLoad = () => {
|
|
7
|
+
balances.load()
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return { onUnlock, onLoad }
|
|
7
11
|
}
|
|
8
12
|
|
|
9
13
|
const balancesPluginDefinition = {
|
|
10
14
|
id: 'balancesPlugin',
|
|
11
15
|
type: 'plugin',
|
|
12
16
|
factory: createBalancesPlugin,
|
|
13
|
-
dependencies: ['balancesAtom', 'port'],
|
|
17
|
+
dependencies: ['balancesAtom', 'port', 'balances'],
|
|
14
18
|
}
|
|
15
19
|
|
|
16
20
|
export default balancesPluginDefinition
|