@exodus/assets-feature 4.0.0 → 4.0.2

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,17 @@
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
+ ## [4.0.2](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@4.0.1...@exodus/assets-feature@4.0.2) (2024-01-11)
7
+
8
+ ### Bug Fixes
9
+
10
+ - don't use monitor for unsupported asset ([#5315](https://github.com/ExodusMovement/exodus-hydra/issues/5315)) ([6432c86](https://github.com/ExodusMovement/exodus-hydra/commit/6432c863e5547ba1a74d730082a9e2e450729d0d))
11
+ - missing dependencies ([#5322](https://github.com/ExodusMovement/exodus-hydra/issues/5322)) ([01efedc](https://github.com/ExodusMovement/exodus-hydra/commit/01efedc7508fb14925277fdcd388afb721ac3dd1))
12
+
13
+ ## [4.0.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@4.0.0...@exodus/assets-feature@4.0.1) (2023-12-13)
14
+
15
+ - refactor: cache CTR request failures (https://github.com/ExodusMovement/exodus-hydra/pull/4975)
16
+
6
17
  ## [4.0.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@3.8.0...@exodus/assets-feature@4.0.0) (2023-11-23)
7
18
 
8
19
  ### ⚠ BREAKING CHANGES
@@ -1,6 +1,7 @@
1
1
  import { pickBy } from '@exodus/basic-utils'
2
2
  import { isEmpty } from 'lodash'
3
3
  import assert from 'minimalistic-assert'
4
+ import { filterAsync } from '@exodus/basic-utils/lib/async'
4
5
 
5
6
  class AssetClientInterface {
6
7
  #availableAssetNamesAtom
@@ -119,7 +120,16 @@ class AssetClientInterface {
119
120
  // In the future, the list of wallets may be different based on the provided assets
120
121
  const asset = this.assetsModule.getAsset(assetName)
121
122
  assert(asset, `${assetName} is not supported`)
122
- return Object.keys(await this.#enabledWalletAccountsAtom.get())
123
+ const enabledWalletAccounts = await this.#enabledWalletAccountsAtom.get()
124
+ return filterAsync(Object.keys(enabledWalletAccounts), async (walletAccount) => {
125
+ try {
126
+ // hardware wallet account may not support coin, to check this get address
127
+ await this.getReceiveAddress({ assetName, walletAccount, useCache: true })
128
+ return true
129
+ } catch {
130
+ return false
131
+ }
132
+ })
123
133
  }
124
134
 
125
135
  // assets interface
package/index.js CHANGED
@@ -33,12 +33,10 @@ const assets = ({ config = {} } = {}) => {
33
33
  {
34
34
  definition: assetModuleDefinition,
35
35
  // storage: { namespace: 'customTokens' },
36
- writesAtoms: ['assetsAtom'],
37
36
  aliases: [{ implementationId: 'customTokensStorage', interfaceId: 'storage' }],
38
37
  },
39
38
  {
40
39
  definition: assetPreferencesDefinition,
41
- writesAtoms: ['multiAddressModeAtom', 'disabledPurposesAtom'],
42
40
  },
43
41
  { definition: customTokensMonitorDefinition },
44
42
  ],
@@ -185,7 +185,7 @@ export class AssetsModule {
185
185
 
186
186
  // tokens may be:
187
187
  // 1. pure custom tokens from the CTR
188
- // 2. built-in tokens previously from the CTR
188
+ // 2. built-in tokens previously from the CTR which may or may not be available
189
189
  // 3. both of the above from a network that has feature flag customTokens === false
190
190
  // It is OK to add all of these to the assets registry
191
191
  const { added, updated } = this.#handleFetchedTokens(Object.values(tokens))
@@ -208,12 +208,27 @@ export class AssetsModule {
208
208
 
209
209
  const key = getFetchCacheKey(baseAssetName, assetId)
210
210
  const cache = this.#getCache(key)
211
+ if (cache?.cachedError) throw cache.cachedError
211
212
  if (cache) return cache
212
213
 
213
- const _token = await this.#fetch(`networks/${baseAssetName}`, { assetId }, 'token')
214
+ const fetchTokenAndCacheError = async () => {
215
+ try {
216
+ return await this.#fetch(`networks/${baseAssetName}`, { assetId }, 'token')
217
+ } catch (err) {
218
+ if (err.message !== 'Too Many Requests') {
219
+ this.#setCache(key, { cachedError: err })
220
+ }
221
+
222
+ throw err
223
+ }
224
+ }
225
+
226
+ const _token = await fetchTokenAndCacheError()
214
227
  if (!this.#validateCustomToken(_token)) {
215
228
  this.#logger.warn('Invalid Custom Token schema')
216
- throw new Error('Token did not pass validation')
229
+ const err = new Error('Token did not pass validation')
230
+ this.#setCache(key, { cachedError: err })
231
+ throw err
217
232
  }
218
233
 
219
234
  const token = normalizeToken(_token)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/assets-feature",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "license": "UNLICENSED",
5
5
  "description": "Assets module, clients and apis",
6
6
  "main": "index.js",
@@ -31,8 +31,11 @@
31
31
  "url": "git+https://github.com/ExodusMovement/exodus-hydra.git"
32
32
  },
33
33
  "dependencies": {
34
+ "@exodus/assets": "^8.0.95",
35
+ "@exodus/atoms": "^7.0.1",
34
36
  "@exodus/basic-utils": "^2.1.0",
35
37
  "@exodus/fetch": "^1.3.0",
38
+ "@exodus/module": "^1.2.2",
36
39
  "@exodus/timer": "^1.0.0",
37
40
  "lodash": "^4.17.21",
38
41
  "minimalistic-assert": "^1.0.1",
@@ -40,8 +43,6 @@
40
43
  "reselect": "^3.0.1"
41
44
  },
42
45
  "devDependencies": {
43
- "@exodus/assets": "^8.0.95",
44
- "@exodus/atoms": "^6.0.1",
45
46
  "@exodus/available-assets": "^8.0.0",
46
47
  "@exodus/bitcoin-meta": "^1.0.1",
47
48
  "@exodus/bitcoin-plugin": "^1.0.3",
@@ -51,11 +52,10 @@
51
52
  "@exodus/cosmos-plugin": "^1.0.0",
52
53
  "@exodus/ethereum-meta": "^1.1.0",
53
54
  "@exodus/models": "^9.1.1",
54
- "@exodus/module": "^1.2.2",
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.2.0",
58
+ "@exodus/wallet-accounts": "^15.1.0",
59
59
  "@exodus/wild-emitter": "^1.0.0",
60
60
  "eslint": "^8.44.0",
61
61
  "events": "^3.3.0",
@@ -63,5 +63,5 @@
63
63
  "msw": "^2.0.0",
64
64
  "redux": "^4.0.0"
65
65
  },
66
- "gitHead": "6fe52cd3aa2ffc3fa76d2334228a0dcd02dc9e2e"
66
+ "gitHead": "20a9f63a04f28b3da5c32c4507ba023ed81394dc"
67
67
  }