@exodus/balances 9.0.0 → 9.1.1

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
+ ## [9.1.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/balances@9.1.0...@exodus/balances@9.1.1) (2023-08-28)
7
+
8
+ ### Bug Fixes
9
+
10
+ - don't try to find tokens for tokens ([#3663](https://github.com/ExodusMovement/exodus-hydra/issues/3663)) ([1e9e3cc](https://github.com/ExodusMovement/exodus-hydra/commit/1e9e3ccfe6339160d9a7b01dc96e5b36b6e78e3f))
11
+
12
+ ## [9.1.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/balances@9.0.0...@exodus/balances@9.1.0) (2023-08-25)
13
+
14
+ ### Features
15
+
16
+ - add atom observer in balances plugin ([#3578](https://github.com/ExodusMovement/exodus-hydra/issues/3578)) ([ec01242](https://github.com/ExodusMovement/exodus-hydra/commit/ec012429d0230619fd03caa05c46dff5ec85e559))
17
+
6
18
  ## [9.0.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/balances@8.1.0...@exodus/balances@9.0.0) (2023-08-21)
7
19
 
8
20
  ### ⚠ BREAKING CHANGES
package/module/index.js CHANGED
@@ -241,8 +241,16 @@ class Balances extends ExodusModule {
241
241
  #isSupportedAsset = (assetName) => !this.#getAsset(assetName).isCombined
242
242
  #getSupportedAssetNames = () => Object.keys(this.#getAssets()).filter(this.#isSupportedAsset)
243
243
 
244
- #getRelatedAssetNames = (assetName) =>
245
- [assetName, ...this.#assetsModule.getTokenNames(assetName)].filter(this.#isSupportedAsset)
244
+ #getRelatedAssetNames = (assetName) => {
245
+ const asset = this.#assetsModule.getAsset(assetName)
246
+ if (asset.baseAsset.name === assetName) {
247
+ return [assetName, ...this.#assetsModule.getTokenNames(assetName)].filter(
248
+ this.#isSupportedAsset
249
+ )
250
+ }
251
+
252
+ return [assetName]
253
+ }
246
254
 
247
255
  #loadBlockchainMetadataForBalance = async ({
248
256
  assetName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/balances",
3
- "version": "9.0.0",
3
+ "version": "9.1.1",
4
4
  "description": "Tracks crypto balances across enabled wallet accounts.",
5
5
  "author": "Exodus Movement Inc.",
6
6
  "license": "UNLICENSED",
@@ -49,5 +49,5 @@
49
49
  "events": "^3.3.0",
50
50
  "jest": "^29.1.2"
51
51
  },
52
- "gitHead": "6de4a6859547f6d1bbce9506cc6f32480d9c728b"
52
+ "gitHead": "c165657390b8521de9bb8b87a1ed728055f86630"
53
53
  }
package/plugins/index.js CHANGED
@@ -1,13 +1,32 @@
1
+ import { createAtomObserver } from '@exodus/atoms'
2
+
1
3
  const createBalancesPlugin = ({ balancesAtom, port, balances }) => {
4
+ const balancesAtomObserver = createAtomObserver({
5
+ port,
6
+ atom: balancesAtom,
7
+ event: 'balancesAtom',
8
+ })
9
+ balancesAtomObserver.register()
10
+
11
+ const onLoad = () => {
12
+ balancesAtomObserver.start()
13
+
14
+ balances.load()
15
+ }
16
+
2
17
  const onUnlock = () => {
3
18
  balancesAtom.get().then((value) => port.emit('balancesAtom', value))
4
19
  }
5
20
 
6
- const onLoad = () => {
7
- balances.load()
21
+ const onStop = () => {
22
+ balancesAtomObserver.unregister()
8
23
  }
9
24
 
10
- return { onUnlock, onLoad }
25
+ return {
26
+ onLoad,
27
+ onUnlock,
28
+ onStop,
29
+ }
11
30
  }
12
31
 
13
32
  const balancesPluginDefinition = {