@exodus/assets-feature 4.0.0 → 4.0.1

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,10 @@
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.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@4.0.0...@exodus/assets-feature@4.0.1) (2023-12-13)
7
+
8
+ - refactor: cache CTR request failures (https://github.com/ExodusMovement/exodus-hydra/pull/4975)
9
+
6
10
  ## [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
11
 
8
12
  ### ⚠ BREAKING CHANGES
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.1",
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": "^6.0.1",
44
+ "@exodus/atoms": "^7.0.0",
45
45
  "@exodus/available-assets": "^8.0.0",
46
46
  "@exodus/bitcoin-meta": "^1.0.1",
47
47
  "@exodus/bitcoin-plugin": "^1.0.3",
@@ -55,7 +55,7 @@
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.0.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": "8a27fc57a2783ecc728030da8b3d2a10fa8f915c"
67
67
  }