@exodus/available-assets 8.5.0 → 8.7.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,22 @@
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.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
+
8
+ ### Features
9
+
10
+ - feat: use atoms v9 (#9651)
11
+
12
+ ### License
13
+
14
+ - license: re-license under MIT license (#10580)
15
+
16
+ ## [8.6.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/available-assets@8.5.0...@exodus/available-assets@8.5.1) (2024-09-30)
17
+
18
+ ### Refactor
19
+
20
+ - migrate network icon selectors to hydra ([9525](https://github.com/ExodusMovement/exodus-hydra/pull/9525))
21
+
6
22
  ## [8.5.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/available-assets@8.4.1...@exodus/available-assets@8.5.0) (2024-08-21)
7
23
 
8
24
  ### Features
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2024 Exodus Movement, Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import availableAssetsApiDefinition from './api/index.js'
1
+ import type availableAssetsApiDefinition from './api/index.js'
2
2
 
3
3
  declare const availableAssets: () => {
4
4
  id: 'availableAssets'
package/module/index.js CHANGED
@@ -1,9 +1,7 @@
1
- import ExodusModule from '@exodus/module' // eslint-disable-line import/no-deprecated
2
1
  import restrictConcurrency from 'make-concurrent'
3
2
 
4
- const MODULE_ID = 'availableAssets'
5
-
6
- class AvailableAssets extends ExodusModule {
3
+ class AvailableAssets {
4
+ #logger
7
5
  #assetsModule
8
6
  #availableAssetsAtom
9
7
  #enabledAndDisabledAssetsAtom
@@ -23,7 +21,7 @@ class AvailableAssets extends ExodusModule {
23
21
  ),
24
22
  logger,
25
23
  }) {
26
- super({ name: MODULE_ID, logger })
24
+ this.#logger = logger
27
25
  this.#defaultAvailableAssetNames = defaultAvailableAssetNames
28
26
  this.#assetsModule = assetsModule
29
27
  this.#assetsAtom = assetsAtom
@@ -73,7 +71,7 @@ class AvailableAssets extends ExodusModule {
73
71
  if (unavailableTokenNames.length > 0) {
74
72
  this.#assetsModule
75
73
  .addRemoteTokens({ tokenNames: unavailableTokenNames })
76
- .catch((err) => this._logger.error(err))
74
+ .catch((err) => this.#logger.error(err))
77
75
  }
78
76
  }
79
77
  })
@@ -94,7 +92,7 @@ class AvailableAssets extends ExodusModule {
94
92
 
95
93
  if (toMakeAvailable.length === 0) return
96
94
 
97
- this._logger.log('making assets available:', toMakeAvailable)
95
+ this.#logger.log('making assets available:', toMakeAvailable)
98
96
  const update = [...availableAssets, ...toMakeAvailable]
99
97
  await this.#availableAssetsAtom.set(update)
100
98
  })
@@ -108,7 +106,7 @@ class AvailableAssets extends ExodusModule {
108
106
  const createAvailableAssetsModule = (opts) => new AvailableAssets(opts)
109
107
 
110
108
  const availableAssetsDefinition = {
111
- id: MODULE_ID,
109
+ id: 'availableAssets',
112
110
  type: 'module',
113
111
  factory: createAvailableAssetsModule,
114
112
  dependencies: [
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@exodus/available-assets",
3
- "version": "8.5.0",
3
+ "version": "8.7.0",
4
4
  "description": "Tracks supported/available assets, i.e. assets that the user can potentially enable via the UI",
5
- "license": "UNLICENSED",
5
+ "license": "MIT",
6
6
  "author": "Exodus Movement, Inc.",
7
7
  "scripts": {
8
8
  "test": "run -T exodus-test --jest",
9
- "lint": "run -T eslint . --ignore-path ../../.gitignore",
9
+ "lint": "run -T eslint . -c ../../eslint.config.mjs",
10
10
  "lint:fix": "yarn lint --fix"
11
11
  },
12
12
  "type": "module",
@@ -31,11 +31,9 @@
31
31
  "url": "git+https://github.com/ExodusMovement/exodus-hydra.git"
32
32
  },
33
33
  "dependencies": {
34
- "@exodus/atoms": "^8.1.0",
34
+ "@exodus/atoms": "^9.0.0",
35
35
  "@exodus/basic-utils": "^3.0.1",
36
36
  "@exodus/core-selectors": "^3.0.0",
37
- "@exodus/module": "^1.3.0",
38
- "@exodus/trezor-meta": "^3.3.6",
39
37
  "lodash": "^4.17.21",
40
38
  "make-concurrent": "^5.3.0",
41
39
  "reselect": "^3.0.1"
@@ -43,13 +41,16 @@
43
41
  "devDependencies": {
44
42
  "@exodus/assets": "^11.0.0",
45
43
  "@exodus/assets-base": "^10.0.0",
46
- "@exodus/assets-feature": "^5.11.0",
44
+ "@exodus/assets-feature": "^5.14.1",
47
45
  "@exodus/combined-assets-meta": "^3.0.0",
48
- "@exodus/enabled-assets": "^10.7.0",
49
- "@exodus/models": "^12.0.1",
50
- "@exodus/redux-dependency-injection": "^4.0.0",
46
+ "@exodus/enabled-assets": "^10.8.0",
47
+ "@exodus/models": "^12.1.1",
48
+ "@exodus/redux-dependency-injection": "^4.1.1",
51
49
  "jest-when": "^3.6.0",
52
50
  "redux": "^4.2.1"
53
51
  },
54
- "gitHead": "f5fba4343968b3e2d93ee9440388a15a858ce2a2"
52
+ "publishConfig": {
53
+ "access": "public"
54
+ },
55
+ "gitHead": "97156baad5ad86796c5eb3721264ba7b0ebb6332"
55
56
  }
@@ -1,7 +1,7 @@
1
- import lodash from 'lodash' // eslint-disable-line @exodus/restricted-imports/prefer-basic-utils -- TODO: fix next time we touch this file
1
+ import lodash from 'lodash'
2
2
  import { pickBy } from '@exodus/basic-utils'
3
3
 
4
- const { memoize } = lodash
4
+ const { memoize } = lodash // eslint-disable-line @exodus/basic-utils/prefer-basic-utils
5
5
 
6
6
  const resultFunction = (availableAssets) =>
7
7
  memoize((baseAssetName) => {
@@ -0,0 +1,44 @@
1
+ import { createSelector } from 'reselect'
2
+
3
+ import {
4
+ createGetHasAssetsOnOtherChainsSelector,
5
+ createGetParentCombinedAssetSelector,
6
+ } from '@exodus/core-selectors/assets/networks/index.js'
7
+ import { memoize } from '@exodus/basic-utils'
8
+
9
+ const isMultiNetworkAsset = (asset) => {
10
+ return asset.assetType === 'MULTI_NETWORK_ASSET'
11
+ }
12
+
13
+ const selectorFactory = (allAssetsSelector) =>
14
+ memoize(
15
+ ({ assetName, hasIcon }) =>
16
+ createSelector(
17
+ allAssetsSelector,
18
+ createGetHasAssetsOnOtherChainsSelector({ allAssetsSelector }),
19
+ createGetParentCombinedAssetSelector({ allAssetsSelector }),
20
+ (allAssets, getHasAssetsOnOtherChainsSelector, getParentCombinedAssetSelector) => {
21
+ const asset = allAssets[assetName]
22
+ const hasAssetsOnOtherChains = getHasAssetsOnOtherChainsSelector(assetName)
23
+ const parentCombined = getParentCombinedAssetSelector(assetName)
24
+
25
+ if (!hasIcon) return false
26
+ if (isMultiNetworkAsset(asset)) return false
27
+ const isToken = asset.baseAssetName && asset.baseAssetName !== assetName
28
+ if (isToken) return true
29
+ if (!hasAssetsOnOtherChains) return false
30
+
31
+ const primaryAssetName = parentCombined.combinedAssetNames[0]
32
+ return primaryAssetName !== assetName
33
+ }
34
+ ),
35
+ ({ assetName, hasIcon }) => `${assetName}-${hasIcon}`
36
+ )
37
+
38
+ const getIsAssetWithNetworkIconSelector = {
39
+ id: 'getIsAssetWithNetworkIcon',
40
+ selectorFactory,
41
+ dependencies: [{ selector: 'all' }],
42
+ }
43
+
44
+ export default getIsAssetWithNetworkIconSelector
@@ -0,0 +1,31 @@
1
+ import { createSelector } from 'reselect'
2
+
3
+ import { createGetHasAssetsOnOtherChainsSelector } from '@exodus/core-selectors/assets/networks/index.js'
4
+ import { memoize } from '@exodus/basic-utils'
5
+
6
+ const selectorFactory = (allAssetsSelector) =>
7
+ memoize((assetName) =>
8
+ createSelector(
9
+ allAssetsSelector,
10
+ createGetHasAssetsOnOtherChainsSelector({ allAssetsSelector }),
11
+ (allAssets, hasAssetsOnOtherChainsSelector) => {
12
+ const asset = allAssets[assetName]
13
+ const hasAssetsOnOtherChains = hasAssetsOnOtherChainsSelector(assetName)
14
+
15
+ return (
16
+ asset.name === asset.baseAsset.name &&
17
+ (Boolean(asset.api?.getTokens) ||
18
+ asset.api?.hasFeature('customTokens') ||
19
+ hasAssetsOnOtherChains)
20
+ )
21
+ }
22
+ )
23
+ )
24
+
25
+ const getIsBaseAssetWithChainIconSelector = {
26
+ id: 'getIsBaseAssetWithChainIcon',
27
+ selectorFactory,
28
+ dependencies: [{ selector: 'all' }],
29
+ }
30
+
31
+ export default getIsBaseAssetWithChainIconSelector
@@ -1,7 +1,7 @@
1
- import lodash from 'lodash' // eslint-disable-line @exodus/restricted-imports/prefer-basic-utils -- TODO: fix next time we touch this file
1
+ import lodash from 'lodash'
2
2
  import { createSelector } from 'reselect'
3
3
 
4
- const { memoize } = lodash
4
+ const { memoize } = lodash // eslint-disable-line @exodus/basic-utils/prefer-basic-utils
5
5
 
6
6
  const selectorFactory = (allAvailableAssetsSelector) =>
7
7
  createSelector(allAvailableAssetsSelector, (allAvailableAssets) =>
@@ -7,6 +7,8 @@ import getCombinedFallbackSelectorDefinition from './get-combined-fallback.js'
7
7
  import getHasAssetsOnOtherChainsSelectorDefinition from './get-has-assets-on-other-chains.js'
8
8
  import getSelectorDefinition from './get.js'
9
9
  import getParentCombinedSelector from './get-parent-combined.js'
10
+ import getIsBaseAssetWithChainIconSelector from './get-is-base-asset-with-chain-icon.js'
11
+ import getIsAssetWithNetworkIconSelector from './get-is-asset-with-network-icon.js'
10
12
 
11
13
  export default [
12
14
  //
@@ -19,4 +21,6 @@ export default [
19
21
  getHasAssetsOnOtherChainsSelectorDefinition,
20
22
  getSelectorDefinition,
21
23
  getParentCombinedSelector,
24
+ getIsBaseAssetWithChainIconSelector,
25
+ getIsAssetWithNetworkIconSelector,
22
26
  ]