@exodus/available-assets 8.7.0 → 8.9.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,28 @@
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
+ ## [8.9.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/available-assets@8.8.0...@exodus/available-assets@8.9.0) (2025-12-11)
7
+
8
+ ### Features
9
+
10
+ - feat: bump atoms for importers of observer factory (#14057)
11
+
12
+ ### Bug Fixes
13
+
14
+ - fix: handle invalid token names (#14587)
15
+
16
+ ## [8.8.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/available-assets@8.6.0...@exodus/available-assets@8.8.0) (2025-08-22)
17
+
18
+ ### Features
19
+
20
+ - feat: memoize available asset names atom selector (#10829)
21
+
22
+ - feat: use atoms v9 (#9651)
23
+
24
+ ### License
25
+
26
+ - license: re-license under MIT license (#10580)
27
+
6
28
  ## [8.7.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/available-assets@8.6.0...@exodus/available-assets@8.7.0) (2024-11-25)
7
29
 
8
30
  ### Features
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @exodus/available-assets
2
2
 
3
- Tracks supported/available assets, i.e. assets that the user can potentially enable via the UI.
3
+ This Exodus SDK feature tracks available assets, i.e. assets that the user can potentially enable via the UI.
4
4
 
5
5
  ## Install
6
6
 
@@ -10,27 +10,31 @@ yarn add @exodus/available-assets
10
10
 
11
11
  ## Usage
12
12
 
13
+ This feature is designed to be used together with `@exodus/headless`. See [using the sdk](../../docs/development/using-the-sdk.md).
14
+
15
+ ### Play with it
16
+
17
+ 1. Open the playground https://exodus-hydra.pages.dev/features/available-assets
18
+ 2. Run `exodus.availableAssets.get()` in the Dev Tools Console.
19
+ 3. Run `selectors.availableAssets.all(store.getState())` in the Dev Tools Console.
20
+ 4. Run `selectors.availableAssets.get(store.getState())('bitcoin')` in the Dev Tools Console.
21
+ 5. Try out some other selectors from `selectors.availableAssets`. See example usage in [tests](./redux/__tests__/selectors/).
22
+
23
+ ### API Side
24
+
25
+ See [using the sdk](../../docs/development/using-the-sdk.md#setup-the-api-side) for more details on how features plug into the SDK and the API interface in the [type declaration](./api/index.d.ts).
26
+
27
+ If you're building a feature that requires knowing available assets, add a dependency on the `availableAssetNamesAtom`.
28
+
29
+ ### UI Side
30
+
31
+ See [using the sdk](../../docs/development/using-the-sdk.md#events) for more details on basic UI-side setup.
32
+
13
33
  ```js
14
- // see https://github.com/ExodusMovement/exodus-hydra/blob/c5632b131fd3cd210f658fb45113528c0e227beb/sdks/headless/__tests__/available-assets.test.js#L40
15
- import createExodus from '@exodus/headless'
16
- import availableAssets from '@exodus/available-assets'
17
-
18
- const container = createExodus({
19
- port,
20
- adapters,
21
- config: {
22
- // ...,
23
- // TODO: support configuring via feature config:
24
- // `container.use(availableAssets({ defaultAvailableAssetNames: ['bitcoin', 'ethereum']}))`
25
- availableAssetsAtom: {
26
- defaultAvailableAssetNames: ['bitcoin', 'ethereum'],
27
- },
28
- },
29
- })
30
-
31
- container.use(availableAssets())
32
-
33
- const exodus = container.resolve()
34
-
35
- const availableAssetNames = await exodus.availableAssets.get() // ['bitcoin', 'ethereum']
34
+ import selectors from '~/ui/flux/selectors'
35
+
36
+ const MyComponent = () => {
37
+ const bitcoin = useSelector((state) => selectors.availableAssets.get(state)('bitcoin'))
38
+ if (!bitcoin) return <div>Bitcoin is not supported</div>
39
+ }
36
40
  ```
@@ -0,0 +1,15 @@
1
+ import { compute } from '@exodus/atoms'
2
+ import selector from './selector.js'
3
+ import memoizeOne from 'memoize-one'
4
+ // eslint-disable-next-line no-restricted-imports -- TODO: Fix this the next time the file is edited.
5
+ import lodash from 'lodash'
6
+
7
+ const { isEqual } = lodash
8
+
9
+ const createAvailableAssetNamesAtom = ({ availableAssetsAtom }) =>
10
+ compute({
11
+ atom: availableAssetsAtom,
12
+ selector: memoizeOne(selector, isEqual),
13
+ })
14
+
15
+ export default createAvailableAssetNamesAtom
@@ -0,0 +1,3 @@
1
+ const selector = (availableAssets) => availableAssets.map((a) => a.assetName)
2
+
3
+ export default selector
package/atoms/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import createAvailableAssetNamesWithoutParentCombinedAtom from './available-asset-names-without-parent-combined.js'
2
- import createAvailableAssetNamesAtom from './available-asset-names.js'
2
+ import createAvailableAssetNamesAtom from './available-asset-names/factory.js'
3
3
  import createAvailableAssetAtom from './available-assets.js'
4
4
 
5
5
  export const availableAssetNamesAtomDefinition = {
package/module/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import restrictConcurrency from 'make-concurrent'
2
2
 
3
+ const TOKEN_NAME_RE = /^[^_]+_([^_]+)_([^_]+)$/u
4
+
3
5
  class AvailableAssets {
4
6
  #logger
5
7
  #assetsModule
@@ -60,17 +62,18 @@ class AvailableAssets {
60
62
  if (value?.disabled) {
61
63
  const availableAssetsNamesSet = await this.#getAvailableAssetsSet()
62
64
  const unavailableTokenNames = Object.keys(value.disabled).filter((assetName) => {
63
- const token = this.#assetsModule.getAsset(assetName)
65
+ const { baseAssetName, token } = this.#resolveBaseAssetName(assetName)
64
66
  return (
67
+ baseAssetName &&
68
+ assetName !== baseAssetName &&
69
+ availableAssetsNamesSet.has(baseAssetName) &&
65
70
  !availableAssetsNamesSet.has(assetName) &&
66
- (!token ||
67
- (token.name !== token.baseAsset.name &&
68
- availableAssetsNamesSet.has(token.baseAsset.name)))
71
+ !token
69
72
  )
70
73
  })
71
74
  if (unavailableTokenNames.length > 0) {
72
75
  this.#assetsModule
73
- .addRemoteTokens({ tokenNames: unavailableTokenNames })
76
+ .addRemoteTokens({ tokenNames: unavailableTokenNames, allowedStatusList: ['c', 'v'] })
74
77
  .catch((err) => this.#logger.error(err))
75
78
  }
76
79
  }
@@ -78,6 +81,16 @@ class AvailableAssets {
78
81
  )
79
82
  }
80
83
 
84
+ #resolveBaseAssetName = (assetName) => {
85
+ if (!assetName) return {}
86
+
87
+ const token = this.#assetsModule.getAsset(assetName)
88
+ if (token) return { baseAssetName: token.baseAsset.name, token }
89
+
90
+ const result = TOKEN_NAME_RE.exec(assetName)
91
+ return { baseAssetName: result?.[1] }
92
+ }
93
+
81
94
  #getAvailableAssetsSet = async () => {
82
95
  const availableAssets = await this.#availableAssetsAtom.get()
83
96
  return new Set(availableAssets.map((a) => a.assetName))
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@exodus/available-assets",
3
- "version": "8.7.0",
4
- "description": "Tracks supported/available assets, i.e. assets that the user can potentially enable via the UI",
3
+ "version": "8.9.0",
4
+ "description": "This Exodus SDK feature tracks available assets, i.e. assets that the user can potentially enable via the UI.",
5
5
  "license": "MIT",
6
6
  "author": "Exodus Movement, Inc.",
7
7
  "scripts": {
@@ -31,26 +31,28 @@
31
31
  "url": "git+https://github.com/ExodusMovement/exodus-hydra.git"
32
32
  },
33
33
  "dependencies": {
34
- "@exodus/atoms": "^9.0.0",
34
+ "@exodus/atoms": "^10.0.0",
35
35
  "@exodus/basic-utils": "^3.0.1",
36
- "@exodus/core-selectors": "^3.0.0",
36
+ "@exodus/core-selectors": "^4.0.0",
37
37
  "lodash": "^4.17.21",
38
38
  "make-concurrent": "^5.3.0",
39
+ "memoize-one": "^5.2.1",
39
40
  "reselect": "^3.0.1"
40
41
  },
41
42
  "devDependencies": {
42
43
  "@exodus/assets": "^11.0.0",
43
44
  "@exodus/assets-base": "^10.0.0",
44
- "@exodus/assets-feature": "^5.14.1",
45
+ "@exodus/assets-feature": "^8.7.2",
45
46
  "@exodus/combined-assets-meta": "^3.0.0",
46
- "@exodus/enabled-assets": "^10.8.0",
47
- "@exodus/models": "^12.1.1",
48
- "@exodus/redux-dependency-injection": "^4.1.1",
47
+ "@exodus/enabled-assets": "^10.11.0",
48
+ "@exodus/models": "^12.18.0",
49
+ "@exodus/redux-dependency-injection": "^4.1.2",
49
50
  "jest-when": "^3.6.0",
50
51
  "redux": "^4.2.1"
51
52
  },
52
53
  "publishConfig": {
53
- "access": "public"
54
+ "access": "public",
55
+ "provenance": false
54
56
  },
55
- "gitHead": "97156baad5ad86796c5eb3721264ba7b0ebb6332"
57
+ "gitHead": "d0cf35b3c7cff5f6b5152faa0e05efa336b7d916"
56
58
  }
@@ -1,3 +1,4 @@
1
+ // eslint-disable-next-line no-restricted-imports -- TODO: Fix this the next time the file is edited.
1
2
  import lodash from 'lodash'
2
3
  import { pickBy } from '@exodus/basic-utils'
3
4
 
@@ -1,3 +1,4 @@
1
+ // eslint-disable-next-line no-restricted-imports -- TODO: Fix this the next time the file is edited.
1
2
  import lodash from 'lodash'
2
3
  import { createSelector } from 'reselect'
3
4
 
@@ -1,9 +0,0 @@
1
- import { compute } from '@exodus/atoms'
2
-
3
- const createAvailableAssetNamesAtom = ({ availableAssetsAtom }) =>
4
- compute({
5
- atom: availableAssetsAtom,
6
- selector: (availableAssets) => availableAssets.map((a) => a.assetName),
7
- })
8
-
9
- export default createAvailableAssetNamesAtom