@exodus/assets-feature 3.5.0 → 3.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,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
+ ## [3.7.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@3.6.0...@exodus/assets-feature@3.7.0) (2023-10-25)
7
+
8
+ ### Features
9
+
10
+ - **assets-feature:** start custom tokens monitor on unlock ([#4562](https://github.com/ExodusMovement/exodus-hydra/issues/4562)) ([adcd284](https://github.com/ExodusMovement/exodus-hydra/commit/adcd2849d7ed383ebe494b123a20e60ae4e89d58))
11
+
12
+ ## [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)
13
+
14
+ ### Features
15
+
16
+ - handle builtIn tokens in search ([#4469](https://github.com/ExodusMovement/exodus-hydra/issues/4469)) ([fce5b61](https://github.com/ExodusMovement/exodus-hydra/commit/fce5b615d39e0d612f4b51e43a8fab1fa004e4e7))
17
+
6
18
  ## [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
19
 
8
20
  ### Features
@@ -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(tokens)
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).map(normalizeToken)
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.5.0",
3
+ "version": "3.7.0",
4
4
  "license": "UNLICENSED",
5
5
  "description": "Assets module, clients and apis",
6
6
  "main": "index.js",
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "devDependencies": {
43
43
  "@exodus/assets": "^8.0.95",
44
- "@exodus/atoms": "^5.7.2",
44
+ "@exodus/atoms": "^6.0.0",
45
45
  "@exodus/available-assets": "^7.0.0",
46
46
  "@exodus/bitcoin-meta": "^1.0.1",
47
47
  "@exodus/bitcoin-plugin": "^1.0.3",
@@ -55,12 +55,12 @@
55
55
  "@exodus/osmosis-plugin": "^1.0.0",
56
56
  "@exodus/redux-dependency-injection": "^3.0.0",
57
57
  "@exodus/storage-memory": "^2.1.1",
58
- "@exodus/wallet-accounts": "^14.1.0",
58
+ "@exodus/wallet-accounts": "^14.2.0",
59
59
  "@exodus/wild-emitter": "^1.0.0",
60
60
  "eslint": "^8.44.0",
61
61
  "events": "^3.3.0",
62
62
  "jest": "^29.1.2",
63
63
  "redux": "^4.0.0"
64
64
  },
65
- "gitHead": "28aeb225a8d874b836e19a6c305b9b8543f261c4"
65
+ "gitHead": "c083b9655607e20206217c44bd55bd1b68e3c9b4"
66
66
  }
package/plugin/index.js CHANGED
@@ -1,7 +1,13 @@
1
1
  import { mapValues, pickBy } from '@exodus/basic-utils'
2
2
  import { createAtomObserver } from '@exodus/atoms'
3
3
 
4
- const createAssetsPlugin = ({ port, assetsModule, disabledPurposesAtom, multiAddressModeAtom }) => {
4
+ const createAssetsPlugin = ({
5
+ port,
6
+ assetsModule,
7
+ customTokensMonitor,
8
+ disabledPurposesAtom,
9
+ multiAddressModeAtom,
10
+ }) => {
5
11
  const emitAssetsLoad = () => {
6
12
  const assets = assetsModule.getAssets()
7
13
  port.emit('assets-load', {
@@ -41,6 +47,14 @@ const createAssetsPlugin = ({ port, assetsModule, disabledPurposesAtom, multiAdd
41
47
  emitAssetsLoad()
42
48
  }
43
49
 
50
+ const onUnlock = () => {
51
+ customTokensMonitor.start()
52
+ }
53
+
54
+ const onLock = () => {
55
+ customTokensMonitor.stop()
56
+ }
57
+
44
58
  const onStop = () => {
45
59
  listeners.forEach(([event, callback]) => {
46
60
  assetsModule.removeListener(event, callback)
@@ -53,14 +67,20 @@ const createAssetsPlugin = ({ port, assetsModule, disabledPurposesAtom, multiAdd
53
67
  await assetsModule.clear()
54
68
  }
55
69
 
56
- return { onStart, onLoad, onStop, onClear }
70
+ return { onStart, onLoad, onUnlock, onLock, onStop, onClear }
57
71
  }
58
72
 
59
73
  const assetsPluginDefinition = {
60
74
  id: 'assetsPlugin',
61
75
  type: 'plugin',
62
76
  factory: createAssetsPlugin,
63
- dependencies: ['port', 'assetsModule', 'disabledPurposesAtom', 'multiAddressModeAtom'],
77
+ dependencies: [
78
+ 'port',
79
+ 'assetsModule',
80
+ 'customTokensMonitor',
81
+ 'disabledPurposesAtom',
82
+ 'multiAddressModeAtom',
83
+ ],
64
84
  }
65
85
 
66
86
  export default assetsPluginDefinition