@exodus/assets-feature 7.2.1 → 7.3.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,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
+ ## [7.3.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@7.2.2...@exodus/assets-feature@7.3.0) (2025-04-16)
7
+
8
+ ### Features
9
+
10
+ - feat: support updating combined asset members (#12019)
11
+
12
+ ## [7.2.2](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@7.2.1...@exodus/assets-feature@7.2.2) (2025-04-14)
13
+
14
+ ### Bug Fixes
15
+
16
+ - fix: provide pageNumber and pageSize to searchTokens (#12006)
17
+
6
18
  ## [7.2.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@7.2.0...@exodus/assets-feature@7.2.1) (2025-04-02)
7
19
 
8
20
  ### Bug Fixes
package/api/index.d.ts CHANGED
@@ -26,6 +26,8 @@ declare const assetsApiDefinition: {
26
26
  lifecycleStatus?: TokenStatus[]
27
27
  query?: string
28
28
  excludeTags?: string[]
29
+ pageNumber?: number
30
+ pageSize?: number
29
31
  })
30
32
  updateTokens(): Promise<void>
31
33
  addTokens(params: {
@@ -1,10 +1,11 @@
1
+ /* eslint-disable @exodus/mutable/no-param-reassign-prop-only */
1
2
  import {
2
3
  createAssetRegistry,
3
4
  CT_DEFAULT_SERVER,
4
5
  CT_STATUS as STATUS,
5
6
  CT_UPDATEABLE_PROPERTIES,
6
7
  } from '@exodus/assets'
7
- import { keyBy, mapValues, partition, pick, pickBy } from '@exodus/basic-utils'
8
+ import { keyBy, mapValues, partition, pick, pickBy, difference } from '@exodus/basic-utils'
8
9
  import lodash from 'lodash'
9
10
  import assert from 'minimalistic-assert'
10
11
  import { memoizeLruCache } from '@exodus/asset-lib'
@@ -17,7 +18,7 @@ import {
17
18
  import { getAssetFromAssetId, getFetchErrorMessage, isDisabledCustomToken } from './utils.js'
18
19
  import createFetchival from '@exodus/fetch/create-fetchival'
19
20
 
20
- const { get, isEmpty, once } = lodash
21
+ const { get, isEmpty, once, uniq } = lodash
21
22
 
22
23
  const FILTERED_FIELDS = [
23
24
  'assetId',
@@ -247,13 +248,14 @@ export class AssetsModule {
247
248
 
248
249
  try {
249
250
  const token = await this.fetchToken(assetId, baseAssetName)
250
- const { asset, isAdded } = this.#handleFetchedToken(token)
251
+ const { asset, isAdded, updates } = this.#handleFetchedToken(token)
252
+ const updated = updates.map(this.getAsset)
251
253
 
252
254
  if (isAdded) {
253
255
  await this.#storeCustomTokens([token])
254
- this.#flushChanges({ added: [asset] })
256
+ this.#flushChanges({ added: [asset], updated })
255
257
  } else {
256
- this.#flushChanges({ updated: [asset] })
258
+ this.#flushChanges({ updated: [asset, ...updated] })
257
259
  }
258
260
 
259
261
  return asset
@@ -365,11 +367,20 @@ export class AssetsModule {
365
367
  (token) => _isDisabledCustomToken(token) && !isDisabledCustomToken(this.getAsset(token.name))
366
368
  )
367
369
  const updatedAssets = tokens.map(this.#registry.updateCustomToken)
370
+ const parentNames = uniq(tokens.flatMap(this.#handleCombinedParents))
371
+ updatedAssets.push(...parentNames.map(this.getAsset))
368
372
 
369
373
  this.#flushChanges({ updated: updatedAssets, disabled })
370
374
  }
371
375
 
372
- searchTokens = async ({ baseAssetName, lifecycleStatus, query, excludeTags = ['offensive'] }) => {
376
+ searchTokens = async ({
377
+ baseAssetName,
378
+ lifecycleStatus,
379
+ query,
380
+ excludeTags = ['offensive'],
381
+ pageNumber,
382
+ pageSize,
383
+ }) => {
373
384
  assert(
374
385
  !baseAssetName || typeof baseAssetName === 'string' || Array.isArray(baseAssetName),
375
386
  'searchTokens(): baseAssetName must be a string or an array if supplied'
@@ -388,7 +399,7 @@ export class AssetsModule {
388
399
 
389
400
  const tokens = await this.#fetch(
390
401
  'search',
391
- { baseAssetName: baseAssetNames, lifecycleStatus, query, excludeTags },
402
+ { baseAssetName: baseAssetNames, lifecycleStatus, query, excludeTags, pageNumber, pageSize },
392
403
  'tokens'
393
404
  )
394
405
  const validTokens = tokens.filter(this.#validateCustomToken)
@@ -461,33 +472,70 @@ export class AssetsModule {
461
472
  }
462
473
  }
463
474
 
475
+ #handleCombinedParents = ({ name, parents }) => {
476
+ if (!parents) return []
477
+ assert(Array.isArray(parents), 'Array expected')
478
+
479
+ const currentParents = this.#getAssetNamesBy(
480
+ (asset) => asset.isCombined && asset.combinedAssetNames.includes(name)
481
+ )
482
+ const updatedCombinedAssetNames = []
483
+
484
+ const removedParents = difference(currentParents, parents)
485
+ removedParents.forEach((parent) => {
486
+ this.#registry.updateCombinedAsset(parent, { removeMembers: [name] })
487
+ updatedCombinedAssetNames.push(parent)
488
+ })
489
+
490
+ const addedParents = difference(parents, currentParents)
491
+ addedParents.forEach((parent) => {
492
+ const asset = this.getAsset(parent)
493
+ if (!asset || !asset.isCombined) return
494
+
495
+ this.#registry.updateCombinedAsset(parent, { addMembers: [name] })
496
+ updatedCombinedAssetNames.push(parent)
497
+ })
498
+
499
+ return uniq(updatedCombinedAssetNames)
500
+ }
501
+
464
502
  #handleFetchedToken = (token) => {
465
503
  const asset = this.getAsset(token.name)
466
- if (asset) return { asset, isAdded: false }
504
+ if (asset) return { asset, isAdded: false, updates: [] }
467
505
 
468
506
  const { name } = this.#registry.addCustomToken(token) // add to registry
507
+ const updates = this.#handleCombinedParents(token)
508
+
469
509
  this.#logger.log('Custom token added:', name)
470
- return { asset: this.getAsset(name), isAdded: true }
510
+ return { asset: this.getAsset(name), isAdded: true, updates }
471
511
  }
472
512
 
473
513
  #handleFetchedTokens = (tokens) => {
474
514
  const fetchedAndHandledTokens = []
475
515
  const added = []
476
516
  const updated = []
517
+ const parentNames = []
477
518
  for (const token of tokens) {
478
519
  try {
479
- const { asset, isAdded } = this.#handleFetchedToken(token)
520
+ const { asset, isAdded, updates } = this.#handleFetchedToken(token)
521
+
480
522
  if (isAdded) {
481
523
  added.push(asset)
482
524
  fetchedAndHandledTokens.push(token)
483
525
  } else {
484
526
  updated.push(asset)
485
527
  }
528
+
529
+ if (updates.length > 0) {
530
+ parentNames.push(...updates)
531
+ }
486
532
  } catch (err) {
487
533
  this.#logger.warn('Handle fetched custom tokens error:', err.message)
488
534
  }
489
535
  }
490
536
 
537
+ updated.push(...uniq(parentNames).map(this.getAsset))
538
+
491
539
  return { fetchedAndHandledTokens, added, updated }
492
540
  }
493
541
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/assets-feature",
3
- "version": "7.2.1",
3
+ "version": "7.3.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",
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@exodus/asset-lib": "^5.3.0",
39
- "@exodus/assets": "^11.0.0",
39
+ "@exodus/assets": "^11.3.0",
40
40
  "@exodus/atoms": "^9.0.0",
41
41
  "@exodus/basic-utils": "^4.0.0",
42
42
  "@exodus/fetch": "^1.3.0",
@@ -54,12 +54,13 @@
54
54
  "@exodus/bitcoin-plugin": "^1.29.1",
55
55
  "@exodus/bitcoinregtest-plugin": "^1.11.0",
56
56
  "@exodus/bitcointestnet-plugin": "^1.13.1",
57
- "@exodus/blockchain-metadata": "^15.9.2",
57
+ "@exodus/blockchain-metadata": "^15.10.0",
58
58
  "@exodus/cardano-lib": "^2.2.0",
59
59
  "@exodus/combined-assets-meta": "^3.0.0",
60
60
  "@exodus/cosmos-plugin": "^1.3.3",
61
61
  "@exodus/ethereum-lib": "^5.0.0",
62
62
  "@exodus/ethereum-meta": "^2.0.0",
63
+ "@exodus/ethereum-plugin": "^2.7.4",
63
64
  "@exodus/fusion-local": "^2.1.0",
64
65
  "@exodus/keychain": "^7.3.0",
65
66
  "@exodus/logger": "^1.2.3",
@@ -68,7 +69,7 @@
68
69
  "@exodus/public-key-provider": "^4.1.1",
69
70
  "@exodus/redux-dependency-injection": "^4.1.1",
70
71
  "@exodus/storage-memory": "^2.2.2",
71
- "@exodus/wallet-accounts": "^17.5.0",
72
+ "@exodus/wallet-accounts": "^17.5.1",
72
73
  "@exodus/wild-emitter": "^1.0.0",
73
74
  "bip39": "^3.1.0",
74
75
  "events": "^3.3.0",
@@ -78,5 +79,5 @@
78
79
  "publishConfig": {
79
80
  "access": "public"
80
81
  },
81
- "gitHead": "560e85813d18b278485be99bc9905b6e1e06d507"
82
+ "gitHead": "272804211316a2713c003e48672dc60d8fb919f0"
82
83
  }