@exodus/assets-feature 7.0.3 → 7.1.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,12 @@
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.1.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@7.0.3...@exodus/assets-feature@7.1.0) (2025-04-01)
7
+
8
+ ### Features
9
+
10
+ - feat: implement assetsModule.getIcon method (#11905)
11
+
6
12
  ## [7.0.3](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@7.0.2...@exodus/assets-feature@7.0.3) (2025-03-28)
7
13
 
8
14
  ### Bug Fixes
package/api/index.js CHANGED
@@ -17,6 +17,7 @@ const createAssetsApi = ({ assetPreferences, assetsModule }) => {
17
17
  addTokens: (...args) => assetsModule.addTokens(...args),
18
18
  getAsset: (assetName) => assetsModule.getAsset(assetName),
19
19
  getAssets: () => assetsModule.getAssets(),
20
+ getIcon: (assetName) => assetsModule.getIcon(assetName),
20
21
  },
21
22
  }
22
23
  }
@@ -7,7 +7,7 @@ import {
7
7
  import { keyBy, mapValues, partition, pick, pickBy } from '@exodus/basic-utils'
8
8
  import lodash from 'lodash'
9
9
  import assert from 'minimalistic-assert'
10
-
10
+ import { memoizeLruCache } from '@exodus/asset-lib'
11
11
  import {
12
12
  CT_DATA_KEY,
13
13
  CT_FETCH_CACHE_EXPIRY,
@@ -90,7 +90,12 @@ export class AssetsModule {
90
90
 
91
91
  constructor({
92
92
  storage,
93
- iconsStorage = { storeIcons: async () => {} },
93
+ iconsStorage = {
94
+ storeIcons: async () => {},
95
+ unzipIcon: (icon) => {
96
+ return icon
97
+ },
98
+ },
94
99
  assetPlugins,
95
100
  assetsAtom,
96
101
  combinedAssetsList = [],
@@ -486,6 +491,35 @@ export class AssetsModule {
486
491
  return { fetchedAndHandledTokens, added, updated }
487
492
  }
488
493
 
494
+ #fetchIcon = memoizeLruCache(
495
+ async (assetName) => {
496
+ const tokenNames = [assetName]
497
+
498
+ const tokens = await this.#fetch('tokens', { tokenNames }, 'tokens')
499
+ const token = tokens[0]
500
+ if (token?.icon) {
501
+ return this.#iconsStorage.unzipIcon(token.icon)
502
+ }
503
+ },
504
+ (assetName) => assetName,
505
+ { max: 100 }
506
+ )
507
+
508
+ getIcon = async (assetName) => {
509
+ assert(assetName, 'assetName is required')
510
+
511
+ const asset = await this.getAsset(assetName)
512
+ if (asset) {
513
+ return this.#iconsStorage.getIcon(assetName)
514
+ }
515
+
516
+ try {
517
+ return await this.#fetchIcon(assetName)
518
+ } catch (e) {
519
+ this.#logger.error(`Cannot load icon for ${assetName} from CTR. ${e.message}`, e)
520
+ }
521
+ }
522
+
489
523
  #assertSupportsCustomTokens = (baseAssetName) => {
490
524
  const baseAsset = this.getAsset(baseAssetName)
491
525
  if (!baseAsset?.api?.hasFeature('customTokens')) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/assets-feature",
3
- "version": "7.0.3",
3
+ "version": "7.1.0",
4
4
  "license": "MIT",
5
5
  "description": "This Exodus SDK feature provides access to instances of all blockchain asset adapters supported by the wallet, and enables you to search for and add custom tokens at runtime.",
6
6
  "type": "module",
@@ -35,6 +35,7 @@
35
35
  "url": "git+https://github.com/ExodusMovement/exodus-hydra.git"
36
36
  },
37
37
  "dependencies": {
38
+ "@exodus/asset-lib": "^5.3.0",
38
39
  "@exodus/assets": "^11.0.0",
39
40
  "@exodus/atoms": "^9.0.0",
40
41
  "@exodus/basic-utils": "^4.0.0",
@@ -77,5 +78,5 @@
77
78
  "publishConfig": {
78
79
  "access": "public"
79
80
  },
80
- "gitHead": "a3b0514b3c42646d18054de770a7631abec0418b"
81
+ "gitHead": "e7d4b34573072ec1e3f329ca6258d949502d34c8"
81
82
  }