@exodus/assets-feature 5.11.0 → 5.11.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 +12 -0
- package/index.js +1 -1
- package/module/assets-module.js +18 -11
- package/module/utils.js +4 -1
- package/package.json +8 -8
- package/plugin/index.js +3 -3
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
|
+
## [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)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- 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))
|
|
11
|
+
|
|
12
|
+
## [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)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
- conditional customTokensMonitor creation ([#8269](https://github.com/ExodusMovement/exodus-hydra/issues/8269)) ([622bca7](https://github.com/ExodusMovement/exodus-hydra/commit/622bca7ae230ae302e9589ac00f3f7c8d5809a79))
|
|
17
|
+
|
|
6
18
|
## [5.11.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@5.10.1...@exodus/assets-feature@5.11.0) (2024-08-20)
|
|
7
19
|
|
|
8
20
|
### Features
|
package/index.js
CHANGED
|
@@ -34,7 +34,7 @@ const assets = ({ config = {} } = {}) => {
|
|
|
34
34
|
aliases: [{ implementationId: 'customTokensStorage', interfaceId: 'storage' }],
|
|
35
35
|
},
|
|
36
36
|
{ definition: assetPreferencesDefinition },
|
|
37
|
-
{ definition: customTokensMonitorDefinition },
|
|
37
|
+
{ if: { registered: ['customTokensStorage'] }, definition: customTokensMonitorDefinition },
|
|
38
38
|
],
|
|
39
39
|
}
|
|
40
40
|
}
|
package/module/assets-module.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
CT_STATUS as STATUS,
|
|
6
6
|
CT_UPDATEABLE_PROPERTIES,
|
|
7
7
|
} from '@exodus/assets'
|
|
8
|
-
import { mapValues, pick, pickBy } from '@exodus/basic-utils'
|
|
8
|
+
import { keyBy, mapValues, partition, pick, pickBy } from '@exodus/basic-utils'
|
|
9
9
|
// eslint-disable-next-line @exodus/restricted-imports/prefer-basic-utils
|
|
10
10
|
import lodash from 'lodash'
|
|
11
11
|
import assert from 'minimalistic-assert'
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
import { getAssetFromAssetId, getFetchErrorMessage, isDisabledCustomToken } from './utils.js'
|
|
20
20
|
import createFetchival from '@exodus/fetch/create-fetchival'
|
|
21
21
|
|
|
22
|
-
const { get, isEmpty,
|
|
22
|
+
const { get, isEmpty, once } = lodash
|
|
23
23
|
|
|
24
24
|
const FILTERED_FIELDS = [
|
|
25
25
|
'assetId',
|
|
@@ -304,20 +304,27 @@ export class AssetsModule {
|
|
|
304
304
|
this.#assertCustomTokensStorageSupported()
|
|
305
305
|
|
|
306
306
|
const assets = this.getAssets()
|
|
307
|
-
const tokenNamesToFetch =
|
|
307
|
+
const [tokenNamesToUpdate, tokenNamesToFetch] = partition(
|
|
308
|
+
tokenNames,
|
|
309
|
+
(tokenName) => !!assets[tokenName]
|
|
310
|
+
)
|
|
308
311
|
|
|
309
|
-
const
|
|
312
|
+
const fetchedTokens =
|
|
310
313
|
tokenNamesToFetch.length > 0
|
|
311
314
|
? await this.#fetch('tokens', { tokenNames: tokenNamesToFetch }, 'tokens')
|
|
312
315
|
: []
|
|
313
|
-
|
|
314
|
-
|
|
316
|
+
|
|
317
|
+
const validTokens = fetchedTokens.filter(this.#validateCustomToken).map(normalizeToken)
|
|
318
|
+
if (validTokens.length !== fetchedTokens.length)
|
|
315
319
|
this.#logger.warn('Invalid Custom Token schema')
|
|
316
320
|
|
|
317
|
-
const
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
+
const tokens = tokenNamesToUpdate.map((tokenName) => assets[tokenName])
|
|
322
|
+
|
|
323
|
+
validTokens.forEach((token) => {
|
|
324
|
+
// replace fetched CT with existing built-in token if found by assetId
|
|
325
|
+
const asset = token.assetId && this.#getAssetFromAssetId(token.assetId, token.baseAssetName)
|
|
326
|
+
tokens.push(asset ?? token)
|
|
327
|
+
})
|
|
321
328
|
|
|
322
329
|
if (isEmpty(tokens)) return
|
|
323
330
|
|
|
@@ -455,7 +462,7 @@ export class AssetsModule {
|
|
|
455
462
|
const asset = this.getAsset(token.name)
|
|
456
463
|
if (asset) return { asset, isAdded: false }
|
|
457
464
|
|
|
458
|
-
const { name } = this.#registry.addCustomToken(token) // add to
|
|
465
|
+
const { name } = this.#registry.addCustomToken(token) // add to registry
|
|
459
466
|
this.#logger.log('Custom token added:', name)
|
|
460
467
|
return { asset: this.getAsset(name), isAdded: true }
|
|
461
468
|
}
|
package/module/utils.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { CT_STATUS as STATUS } from '@exodus/assets'
|
|
2
2
|
import lodash from 'lodash'
|
|
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.2",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"description": "Assets module, clients and apis",
|
|
6
6
|
"type": "module",
|
|
@@ -45,13 +45,13 @@
|
|
|
45
45
|
"reselect": "^3.0.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@exodus/available-assets": "^8.
|
|
48
|
+
"@exodus/available-assets": "^8.5.0",
|
|
49
49
|
"@exodus/bip44-constants": "^195.0.0",
|
|
50
50
|
"@exodus/bitcoin-meta": "^2.0.0",
|
|
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.4.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",
|
|
@@ -60,16 +60,16 @@
|
|
|
60
60
|
"@exodus/keychain": "^6.9.1",
|
|
61
61
|
"@exodus/models": "^12.0.1",
|
|
62
62
|
"@exodus/osmosis-plugin": "^1.0.0",
|
|
63
|
-
"@exodus/public-key-provider": "^2.
|
|
63
|
+
"@exodus/public-key-provider": "^2.5.0",
|
|
64
64
|
"@exodus/public-key-store": "^1.2.2",
|
|
65
|
-
"@exodus/redux-dependency-injection": "^4.0.
|
|
66
|
-
"@exodus/storage-memory": "^2.
|
|
67
|
-
"@exodus/wallet-accounts": "^16.
|
|
65
|
+
"@exodus/redux-dependency-injection": "^4.0.2",
|
|
66
|
+
"@exodus/storage-memory": "^2.2.0",
|
|
67
|
+
"@exodus/wallet-accounts": "^16.10.1",
|
|
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": "a758fd2522b6a4b638f10a340cf87a6d64c814de"
|
|
75
75
|
}
|
package/plugin/index.js
CHANGED
|
@@ -60,11 +60,11 @@ const createAssetsPlugin = ({
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
const onUnlock = () => {
|
|
63
|
-
customTokensMonitor
|
|
63
|
+
customTokensMonitor?.start()
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
const onLock = () => {
|
|
67
|
-
customTokensMonitor
|
|
67
|
+
customTokensMonitor?.stop()
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
const onStop = () => {
|
|
@@ -87,7 +87,7 @@ const assetsPluginDefinition = {
|
|
|
87
87
|
'port',
|
|
88
88
|
'assetsModule',
|
|
89
89
|
'assetsAtom',
|
|
90
|
-
'customTokensMonitor',
|
|
90
|
+
'customTokensMonitor?',
|
|
91
91
|
'disabledPurposesAtom',
|
|
92
92
|
'multiAddressModeAtom',
|
|
93
93
|
],
|