@exodus/assets-feature 3.5.0 → 3.6.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 +27 -23
- package/package.json +2 -2
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
|
+
## [3.6.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@3.5.0...@exodus/assets-feature@3.6.0) (2023-10-20)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- handle builtIn tokens in search ([#4469](https://github.com/ExodusMovement/exodus-hydra/issues/4469)) ([fce5b61](https://github.com/ExodusMovement/exodus-hydra/commit/fce5b615d39e0d612f4b51e43a8fab1fa004e4e7))
|
|
11
|
+
|
|
6
12
|
## [3.5.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@3.4.0...@exodus/assets-feature@3.5.0) (2023-10-17)
|
|
7
13
|
|
|
8
14
|
### Features
|
package/module/assets-module.js
CHANGED
|
@@ -21,6 +21,26 @@ import {
|
|
|
21
21
|
} from './constants'
|
|
22
22
|
import { getAssetFromAssetId, getFetchErrorMessage, isDisabledCustomToken } from './utils'
|
|
23
23
|
|
|
24
|
+
const FILTERED_FIELDS = [
|
|
25
|
+
'assetId',
|
|
26
|
+
'baseAssetName',
|
|
27
|
+
'displayName',
|
|
28
|
+
'displayTicker',
|
|
29
|
+
'gradientColors',
|
|
30
|
+
'gradientCoords',
|
|
31
|
+
'icon', // there is no icon field in built in assets, but there may be for custom tokens (TODO?)
|
|
32
|
+
'isBuiltIn',
|
|
33
|
+
'isCustomToken',
|
|
34
|
+
'lifecycleStatus',
|
|
35
|
+
'name',
|
|
36
|
+
'primaryColor',
|
|
37
|
+
'properName',
|
|
38
|
+
'properTicker',
|
|
39
|
+
'ticker',
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
const filterBuiltInProps = (asset) => ({ ...pick(asset, FILTERED_FIELDS), assetName: asset.name })
|
|
43
|
+
|
|
24
44
|
const getFetchCacheKey = (baseAssetName, assetId) => `${assetId}-${baseAssetName}`
|
|
25
45
|
|
|
26
46
|
const _isDisabledCustomToken = (token) => token.lifecycleStatus === STATUS.DISABLED
|
|
@@ -169,26 +189,7 @@ export class AssetsModule extends ExodusModule {
|
|
|
169
189
|
const asset = this.#getAssetFromAssetId(assetId, baseAssetName)
|
|
170
190
|
if (asset) {
|
|
171
191
|
// either built-in asset (isBuiltIn === true) or previously added custom token (isCustomToken === true)
|
|
172
|
-
return
|
|
173
|
-
...pick(asset, [
|
|
174
|
-
'assetId',
|
|
175
|
-
'baseAssetName',
|
|
176
|
-
'displayName',
|
|
177
|
-
'displayTicker',
|
|
178
|
-
'gradientColors',
|
|
179
|
-
'gradientCoords',
|
|
180
|
-
'icon', // there is no icon field in built in assets, but there may be for custom tokens (TODO?)
|
|
181
|
-
'isBuiltIn',
|
|
182
|
-
'isCustomToken',
|
|
183
|
-
'lifecycleStatus',
|
|
184
|
-
'name',
|
|
185
|
-
'primaryColor',
|
|
186
|
-
'properName',
|
|
187
|
-
'properTicker',
|
|
188
|
-
'ticker',
|
|
189
|
-
]),
|
|
190
|
-
assetName: asset.name,
|
|
191
|
-
}
|
|
192
|
+
return filterBuiltInProps(asset)
|
|
192
193
|
}
|
|
193
194
|
|
|
194
195
|
const key = getFetchCacheKey(baseAssetName, assetId)
|
|
@@ -291,7 +292,7 @@ export class AssetsModule extends ExodusModule {
|
|
|
291
292
|
const validTokens = tokensToAdd.filter(this.#validateCustomToken).map(normalizeToken)
|
|
292
293
|
if (validTokens.length !== tokensToAdd.length) this._logger.warn('Invalid Custom Token schema')
|
|
293
294
|
|
|
294
|
-
const { fetchedAndHandledTokens, added, updated } = this.#handleFetchedTokens(
|
|
295
|
+
const { fetchedAndHandledTokens, added, updated } = this.#handleFetchedTokens(validTokens)
|
|
295
296
|
|
|
296
297
|
if (fetchedAndHandledTokens.length > 0) {
|
|
297
298
|
await this.#storeCustomTokens(fetchedAndHandledTokens)
|
|
@@ -351,11 +352,14 @@ export class AssetsModule extends ExodusModule {
|
|
|
351
352
|
{ baseAssetName: baseAssetNames, lifecycleStatus, query, excludeTags },
|
|
352
353
|
'tokens'
|
|
353
354
|
)
|
|
354
|
-
const validTokens = tokens.filter(this.#validateCustomToken)
|
|
355
|
+
const validTokens = tokens.filter(this.#validateCustomToken)
|
|
355
356
|
|
|
356
357
|
if (validTokens.length !== tokens.length) this._logger.warn('Invalid Custom Token schema')
|
|
357
358
|
|
|
358
|
-
return validTokens
|
|
359
|
+
return validTokens.map((token) => {
|
|
360
|
+
const asset = this.#getAssetFromAssetId(token.assetId, token.baseAssetName)
|
|
361
|
+
return asset ? filterBuiltInProps(asset) : normalizeToken(token)
|
|
362
|
+
})
|
|
359
363
|
}
|
|
360
364
|
|
|
361
365
|
#getCustomTokensNetworkNames = () =>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/assets-feature",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"description": "Assets module, clients and apis",
|
|
6
6
|
"main": "index.js",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"jest": "^29.1.2",
|
|
63
63
|
"redux": "^4.0.0"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "583f74d9f24b9978816ac6a0f04a14eb07d619dd"
|
|
66
66
|
}
|