@exodus/assets-feature 7.2.2 → 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 +6 -0
- package/module/assets-module.js +49 -8
- package/package.json +5 -4
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.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
|
+
|
|
6
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)
|
|
7
13
|
|
|
8
14
|
### Bug Fixes
|
package/module/assets-module.js
CHANGED
|
@@ -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,6 +367,8 @@ 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
|
}
|
|
@@ -468,33 +472,70 @@ export class AssetsModule {
|
|
|
468
472
|
}
|
|
469
473
|
}
|
|
470
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
|
+
|
|
471
502
|
#handleFetchedToken = (token) => {
|
|
472
503
|
const asset = this.getAsset(token.name)
|
|
473
|
-
if (asset) return { asset, isAdded: false }
|
|
504
|
+
if (asset) return { asset, isAdded: false, updates: [] }
|
|
474
505
|
|
|
475
506
|
const { name } = this.#registry.addCustomToken(token) // add to registry
|
|
507
|
+
const updates = this.#handleCombinedParents(token)
|
|
508
|
+
|
|
476
509
|
this.#logger.log('Custom token added:', name)
|
|
477
|
-
return { asset: this.getAsset(name), isAdded: true }
|
|
510
|
+
return { asset: this.getAsset(name), isAdded: true, updates }
|
|
478
511
|
}
|
|
479
512
|
|
|
480
513
|
#handleFetchedTokens = (tokens) => {
|
|
481
514
|
const fetchedAndHandledTokens = []
|
|
482
515
|
const added = []
|
|
483
516
|
const updated = []
|
|
517
|
+
const parentNames = []
|
|
484
518
|
for (const token of tokens) {
|
|
485
519
|
try {
|
|
486
|
-
const { asset, isAdded } = this.#handleFetchedToken(token)
|
|
520
|
+
const { asset, isAdded, updates } = this.#handleFetchedToken(token)
|
|
521
|
+
|
|
487
522
|
if (isAdded) {
|
|
488
523
|
added.push(asset)
|
|
489
524
|
fetchedAndHandledTokens.push(token)
|
|
490
525
|
} else {
|
|
491
526
|
updated.push(asset)
|
|
492
527
|
}
|
|
528
|
+
|
|
529
|
+
if (updates.length > 0) {
|
|
530
|
+
parentNames.push(...updates)
|
|
531
|
+
}
|
|
493
532
|
} catch (err) {
|
|
494
533
|
this.#logger.warn('Handle fetched custom tokens error:', err.message)
|
|
495
534
|
}
|
|
496
535
|
}
|
|
497
536
|
|
|
537
|
+
updated.push(...uniq(parentNames).map(this.getAsset))
|
|
538
|
+
|
|
498
539
|
return { fetchedAndHandledTokens, added, updated }
|
|
499
540
|
}
|
|
500
541
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/assets-feature",
|
|
3
|
-
"version": "7.
|
|
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.
|
|
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",
|
|
@@ -60,6 +60,7 @@
|
|
|
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.
|
|
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": "
|
|
82
|
+
"gitHead": "272804211316a2713c003e48672dc60d8fb919f0"
|
|
82
83
|
}
|