@exodus/assets-feature 5.11.1 → 5.11.3
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 +10 -0
- package/client/asset-client-interface.js +2 -3
- package/module/assets-module.js +20 -15
- package/module/utils.js +5 -2
- package/package.json +7 -7
- package/redux/selectors/index.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
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
|
+
## [5.11.3](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@5.11.2...@exodus/assets-feature@5.11.3) (2024-09-09)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @exodus/assets-feature
|
|
9
|
+
|
|
10
|
+
## [5.11.2](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@5.11.1...@exodus/assets-feature@5.11.2) (2024-09-05)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- addRemoteTokens can add builtIn token as CT ([#8879](https://github.com/ExodusMovement/exodus-hydra/issues/8879)) ([2597011](https://github.com/ExodusMovement/exodus-hydra/commit/2597011ed1cd88755d174953e90afe467ecaa689))
|
|
15
|
+
|
|
6
16
|
## [5.11.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@5.11.0...@exodus/assets-feature@5.11.1) (2024-08-26)
|
|
7
17
|
|
|
8
18
|
### Bug Fixes
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { pickBy } from '@exodus/basic-utils'
|
|
2
|
-
import lodash from 'lodash'
|
|
1
|
+
import { pickBy, filterAsync } from '@exodus/basic-utils'
|
|
2
|
+
import lodash from 'lodash' // eslint-disable-line @exodus/restricted-imports/prefer-basic-utils
|
|
3
3
|
import assert from 'minimalistic-assert'
|
|
4
|
-
import { filterAsync } from '@exodus/basic-utils/src/async.js'
|
|
5
4
|
|
|
6
5
|
const { isEmpty } = lodash
|
|
7
6
|
|
package/module/assets-module.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
/* eslint-disable unicorn/prefer-spread */
|
|
2
1
|
import {
|
|
3
2
|
createAssetRegistry,
|
|
4
3
|
CT_DEFAULT_SERVER,
|
|
5
4
|
CT_STATUS as STATUS,
|
|
6
5
|
CT_UPDATEABLE_PROPERTIES,
|
|
7
6
|
} from '@exodus/assets'
|
|
8
|
-
import { mapValues, pick, pickBy } from '@exodus/basic-utils'
|
|
9
|
-
// eslint-disable-
|
|
10
|
-
import lodash from 'lodash'
|
|
7
|
+
import { keyBy, mapValues, partition, pick, pickBy } from '@exodus/basic-utils'
|
|
8
|
+
import lodash from 'lodash' // eslint-disable-line @exodus/restricted-imports/prefer-basic-utils
|
|
11
9
|
import assert from 'minimalistic-assert'
|
|
12
10
|
|
|
13
11
|
import {
|
|
@@ -19,7 +17,7 @@ import {
|
|
|
19
17
|
import { getAssetFromAssetId, getFetchErrorMessage, isDisabledCustomToken } from './utils.js'
|
|
20
18
|
import createFetchival from '@exodus/fetch/create-fetchival'
|
|
21
19
|
|
|
22
|
-
const { get, isEmpty,
|
|
20
|
+
const { get, isEmpty, once } = lodash
|
|
23
21
|
|
|
24
22
|
const FILTERED_FIELDS = [
|
|
25
23
|
'assetId',
|
|
@@ -297,27 +295,34 @@ export class AssetsModule {
|
|
|
297
295
|
|
|
298
296
|
this.#flushChanges({ added, updated })
|
|
299
297
|
|
|
300
|
-
return added
|
|
298
|
+
return [...added, ...updated]
|
|
301
299
|
}
|
|
302
300
|
|
|
303
301
|
addRemoteTokens = async ({ tokenNames }) => {
|
|
304
302
|
this.#assertCustomTokensStorageSupported()
|
|
305
303
|
|
|
306
304
|
const assets = this.getAssets()
|
|
307
|
-
const tokenNamesToFetch =
|
|
305
|
+
const [tokenNamesToUpdate, tokenNamesToFetch] = partition(
|
|
306
|
+
tokenNames,
|
|
307
|
+
(tokenName) => !!assets[tokenName]
|
|
308
|
+
)
|
|
308
309
|
|
|
309
|
-
const
|
|
310
|
+
const fetchedTokens =
|
|
310
311
|
tokenNamesToFetch.length > 0
|
|
311
312
|
? await this.#fetch('tokens', { tokenNames: tokenNamesToFetch }, 'tokens')
|
|
312
313
|
: []
|
|
313
|
-
|
|
314
|
-
|
|
314
|
+
|
|
315
|
+
const validTokens = fetchedTokens.filter(this.#validateCustomToken).map(normalizeToken)
|
|
316
|
+
if (validTokens.length !== fetchedTokens.length)
|
|
315
317
|
this.#logger.warn('Invalid Custom Token schema')
|
|
316
318
|
|
|
317
|
-
const
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
319
|
+
const tokens = tokenNamesToUpdate.map((tokenName) => assets[tokenName])
|
|
320
|
+
|
|
321
|
+
validTokens.forEach((token) => {
|
|
322
|
+
// replace fetched CT with existing built-in token if found by assetId
|
|
323
|
+
const asset = token.assetId && this.#getAssetFromAssetId(token.assetId, token.baseAssetName)
|
|
324
|
+
tokens.push(asset ?? token)
|
|
325
|
+
})
|
|
321
326
|
|
|
322
327
|
if (isEmpty(tokens)) return
|
|
323
328
|
|
|
@@ -455,7 +460,7 @@ export class AssetsModule {
|
|
|
455
460
|
const asset = this.getAsset(token.name)
|
|
456
461
|
if (asset) return { asset, isAdded: false }
|
|
457
462
|
|
|
458
|
-
const { name } = this.#registry.addCustomToken(token) // add to
|
|
463
|
+
const { name } = this.#registry.addCustomToken(token) // add to registry
|
|
459
464
|
this.#logger.log('Custom token added:', name)
|
|
460
465
|
return { asset: this.getAsset(name), isAdded: true }
|
|
461
466
|
}
|
package/module/utils.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { CT_STATUS as STATUS } from '@exodus/assets'
|
|
2
|
-
import lodash from 'lodash'
|
|
2
|
+
import lodash from 'lodash' // eslint-disable-line @exodus/restricted-imports/prefer-basic-utils
|
|
3
|
+
import assert from 'minimalistic-assert'
|
|
3
4
|
|
|
4
5
|
const { get } = lodash
|
|
5
6
|
|
|
6
7
|
const BLACKLISTED_ERRORS = [/Cannot destructure property 'owner'/]
|
|
7
8
|
|
|
8
9
|
export const getAssetFromAssetId = (assets, assetId, baseAssetName) => {
|
|
10
|
+
assert(assetId, 'getAssetFromAssetId(): assetId is required')
|
|
11
|
+
assert(baseAssetName, 'getAssetFromAssetId(): baseAssetName is required')
|
|
9
12
|
// ignore letter-case for assets that support checksummed addresses
|
|
10
|
-
assetId = assetId
|
|
13
|
+
assetId = assetId.toLowerCase()
|
|
11
14
|
return Object.values(assets).find(
|
|
12
15
|
(asset) => assetId === asset.assetId?.toLowerCase() && baseAssetName === asset.baseAsset.name
|
|
13
16
|
)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/assets-feature",
|
|
3
|
-
"version": "5.11.
|
|
3
|
+
"version": "5.11.3",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"description": "Assets module, clients and apis",
|
|
6
6
|
"type": "module",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"author": "Exodus Movement, Inc.",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"test": "run -T exodus-test --jest --esbuild",
|
|
11
|
-
"lint": "run -T eslint .
|
|
11
|
+
"lint": "run -T eslint .",
|
|
12
12
|
"lint:fix": "yarn lint --fix"
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@exodus/assets": "^11.0.0",
|
|
37
|
-
"@exodus/atoms": "^8.
|
|
37
|
+
"@exodus/atoms": "^8.1.1",
|
|
38
38
|
"@exodus/basic-utils": "^3.0.1",
|
|
39
39
|
"@exodus/fetch": "^1.3.0",
|
|
40
40
|
"@exodus/module": "^1.2.2",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@exodus/bitcoin-plugin": "^1.0.3",
|
|
52
52
|
"@exodus/bitcoinregtest-plugin": "^1.0.3",
|
|
53
53
|
"@exodus/bitcointestnet-plugin": "^1.0.3",
|
|
54
|
-
"@exodus/blockchain-metadata": "^15.
|
|
54
|
+
"@exodus/blockchain-metadata": "^15.5.0",
|
|
55
55
|
"@exodus/cardano-lib": "^2.2.0",
|
|
56
56
|
"@exodus/combined-assets-meta": "^3.0.0",
|
|
57
57
|
"@exodus/cosmos-plugin": "^1.0.0",
|
|
@@ -62,14 +62,14 @@
|
|
|
62
62
|
"@exodus/osmosis-plugin": "^1.0.0",
|
|
63
63
|
"@exodus/public-key-provider": "^2.5.0",
|
|
64
64
|
"@exodus/public-key-store": "^1.2.2",
|
|
65
|
-
"@exodus/redux-dependency-injection": "^4.0.
|
|
65
|
+
"@exodus/redux-dependency-injection": "^4.0.3",
|
|
66
66
|
"@exodus/storage-memory": "^2.2.0",
|
|
67
|
-
"@exodus/wallet-accounts": "^16.10.
|
|
67
|
+
"@exodus/wallet-accounts": "^16.10.2",
|
|
68
68
|
"@exodus/wild-emitter": "^1.0.0",
|
|
69
69
|
"bip39": "^3.1.0",
|
|
70
70
|
"events": "^3.3.0",
|
|
71
71
|
"msw": "^2.0.0",
|
|
72
72
|
"redux": "^4.0.0"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "d64de7579b06afe91fbded3d1f7eb29950f82e5a"
|
|
75
75
|
}
|
package/redux/selectors/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { keyBy } from '@exodus/basic-utils'
|
|
2
2
|
import { createSelector } from 'reselect'
|
|
3
3
|
|
|
4
|
-
import lodash from 'lodash'
|
|
4
|
+
import lodash from 'lodash' // eslint-disable-line @exodus/restricted-imports/prefer-basic-utils
|
|
5
5
|
|
|
6
|
-
const { memoize } = lodash
|
|
6
|
+
const { memoize } = lodash
|
|
7
7
|
|
|
8
8
|
// just a semantic alias for `data`
|
|
9
9
|
const allAssetsSelectorDefinition = {
|