@exodus/assets-feature 2.0.1 → 3.0.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 +20 -0
- package/client/asset-client-interface.js +1 -0
- package/module/assets-module.js +15 -6
- package/module/constants.js +1 -0
- package/package.json +2 -2
- package/plugin/index.js +12 -1
- package/redux/index.js +2 -2
- package/redux/selectors/index.js +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,26 @@
|
|
|
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.0.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@2.0.2...@exodus/assets-feature@3.0.0) (2023-09-19)
|
|
7
|
+
|
|
8
|
+
### ⚠ BREAKING CHANGES
|
|
9
|
+
|
|
10
|
+
- emit defaultAccountStates from assets-load (#4072)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- emit defaultAccountStates from assets-load ([#4072](https://github.com/ExodusMovement/exodus-hydra/issues/4072)) ([1b3887a](https://github.com/ExodusMovement/exodus-hydra/commit/1b3887ab0d10c14ee90622121bf2fa6847f53b17))
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
- update assets module ([#4123](https://github.com/ExodusMovement/exodus-hydra/issues/4123)) ([8f1cd56](https://github.com/ExodusMovement/exodus-hydra/commit/8f1cd56d774336e389cf932944755c4670356dcc))
|
|
19
|
+
|
|
20
|
+
## [2.0.2](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@2.0.1...@exodus/assets-feature@2.0.2) (2023-09-14)
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
- multi account getAsset tolerance ([#4055](https://github.com/ExodusMovement/exodus-hydra/issues/4055)) ([39aa8d6](https://github.com/ExodusMovement/exodus-hydra/commit/39aa8d66f0e373ae710d41b3735a1395b5d8a793))
|
|
25
|
+
|
|
6
26
|
## [2.0.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@2.0.0...@exodus/assets-feature@2.0.1) (2023-09-14)
|
|
7
27
|
|
|
8
28
|
### Bug Fixes
|
|
@@ -192,6 +192,7 @@ class AssetClientInterface {
|
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
signTransaction = async ({ assetName, unsignedTx, walletAccount }) => {
|
|
195
|
+
// eslint-disable-next-line unicorn/no-await-expression-member
|
|
195
196
|
const accountIndex = (await this.#getWalletAccount(walletAccount)).index
|
|
196
197
|
const baseAssetName = this.assetsModule.getAsset(assetName).baseAsset.name
|
|
197
198
|
return this.wallet.signTransaction({ baseAssetName, unsignedTx, accountIndex })
|
package/module/assets-module.js
CHANGED
|
@@ -12,9 +12,13 @@ import ExodusModule from '@exodus/module'
|
|
|
12
12
|
// eslint-disable-next-line @exodus/restricted-imports/prefer-basic-utils
|
|
13
13
|
import { get, isEmpty, keyBy, once } from 'lodash'
|
|
14
14
|
import assert from 'minimalistic-assert'
|
|
15
|
-
import ms from 'ms'
|
|
16
15
|
|
|
17
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
CT_DATA_KEY,
|
|
18
|
+
CT_FETCH_CACHE_EXPIRY,
|
|
19
|
+
CT_TIMESTAMP_KEY,
|
|
20
|
+
CT_UPDATE_INTERVAL,
|
|
21
|
+
} from './constants'
|
|
18
22
|
import { getAssetFromAssetId, getFetchErrorMessage, isDisabledCustomToken } from './utils'
|
|
19
23
|
|
|
20
24
|
const getFetchCacheKey = (baseAssetName, assetId) => `${assetId}-${baseAssetName}`
|
|
@@ -37,6 +41,7 @@ export class AssetsModule extends ExodusModule {
|
|
|
37
41
|
#storageDataKey
|
|
38
42
|
#storageTimestampKey
|
|
39
43
|
#customTokenUpdateInterval
|
|
44
|
+
#fetchCacheExpiry
|
|
40
45
|
#globalAssetRegistry // temporary
|
|
41
46
|
|
|
42
47
|
constructor({
|
|
@@ -79,6 +84,7 @@ export class AssetsModule extends ExodusModule {
|
|
|
79
84
|
this.#storageDataKey = config.storageDataKey || CT_DATA_KEY
|
|
80
85
|
this.#storageTimestampKey = config.storageTimestampKey || CT_TIMESTAMP_KEY
|
|
81
86
|
this.#customTokenUpdateInterval = config.customTokenUpdateInterval || CT_UPDATE_INTERVAL
|
|
87
|
+
this.#fetchCacheExpiry = config.fetchCacheExpiry ?? CT_FETCH_CACHE_EXPIRY
|
|
82
88
|
this.#globalAssetRegistry = globalAssetRegistry // temporary
|
|
83
89
|
}
|
|
84
90
|
|
|
@@ -159,6 +165,7 @@ export class AssetsModule extends ExodusModule {
|
|
|
159
165
|
'icon', // there is no icon field in built in assets, but there may be for custom tokens (TODO?)
|
|
160
166
|
'isBuiltIn',
|
|
161
167
|
'isCustomToken',
|
|
168
|
+
'lifecycleStatus',
|
|
162
169
|
'name',
|
|
163
170
|
'primaryColor',
|
|
164
171
|
'properName',
|
|
@@ -254,9 +261,11 @@ export class AssetsModule extends ExodusModule {
|
|
|
254
261
|
addRemoteTokens = async ({ tokenNames }) => {
|
|
255
262
|
const assets = this.getAssets()
|
|
256
263
|
const tokenNamesToFetch = tokenNames.filter((tokenName) => !assets[tokenName])
|
|
257
|
-
if (tokenNamesToFetch.length === 0) return
|
|
258
264
|
|
|
259
|
-
const tokensToAdd =
|
|
265
|
+
const tokensToAdd =
|
|
266
|
+
tokenNamesToFetch.length > 0
|
|
267
|
+
? await this.#fetch('tokens', { tokenNames: tokenNamesToFetch }, 'tokens')
|
|
268
|
+
: []
|
|
260
269
|
const tokensToUpdate = tokenNames
|
|
261
270
|
.map((tokenName) => assets[tokenName])
|
|
262
271
|
.filter((token) => !!token)
|
|
@@ -337,8 +346,8 @@ export class AssetsModule extends ExodusModule {
|
|
|
337
346
|
#getAssetNamesBy = (filter) =>
|
|
338
347
|
Object.keys(this.getAssets()).filter((assetName) => filter(this.getAsset(assetName)))
|
|
339
348
|
|
|
340
|
-
#setCache = (key, value
|
|
341
|
-
this.#fetchCache[key] = { value, expiry: Date.now() +
|
|
349
|
+
#setCache = (key, value) => {
|
|
350
|
+
this.#fetchCache[key] = { value, expiry: Date.now() + this.#fetchCacheExpiry }
|
|
342
351
|
}
|
|
343
352
|
|
|
344
353
|
#getCache = (key) => {
|
package/module/constants.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/assets-feature",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"description": "Assets module, clients and apis",
|
|
6
6
|
"main": "index.js",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"jest": "^29.1.2",
|
|
61
61
|
"redux": "^4.0.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "c69b2cf286e6134084a53e82b81e054c4fd9f38a"
|
|
64
64
|
}
|
package/plugin/index.js
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
+
import { mapValues, pickBy } from '@exodus/basic-utils'
|
|
1
2
|
import { createAtomObserver } from '@exodus/atoms'
|
|
2
3
|
|
|
3
4
|
const createAssetsPlugin = ({ port, assetsModule, disabledPurposesAtom, multiAddressModeAtom }) => {
|
|
4
|
-
const emitAssetsLoad = () =>
|
|
5
|
+
const emitAssetsLoad = () => {
|
|
6
|
+
const assets = assetsModule.getAssets()
|
|
7
|
+
port.emit('assets-load', {
|
|
8
|
+
assets,
|
|
9
|
+
defaultAccountStates: mapValues(
|
|
10
|
+
pickBy(assets, (asset) => asset.api.hasFeature('accountState')),
|
|
11
|
+
(asset) => asset?.api?.createAccountState?.()?.create?.()
|
|
12
|
+
),
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
|
|
5
16
|
const listeners = [
|
|
6
17
|
['assets-add', (data) => port.emit('assets-add', data)],
|
|
7
18
|
['assets-update', (data) => port.emit('assets-update', data)],
|
package/redux/index.js
CHANGED
|
@@ -16,11 +16,11 @@ const assetsReduxDefinition = {
|
|
|
16
16
|
type: 'redux-module',
|
|
17
17
|
initialState,
|
|
18
18
|
eventReducers: {
|
|
19
|
-
'assets-load': (state,
|
|
19
|
+
'assets-load': (state, { assets }) => ({
|
|
20
20
|
...state,
|
|
21
21
|
error: null,
|
|
22
22
|
loaded: true,
|
|
23
|
-
data:
|
|
23
|
+
data: assets,
|
|
24
24
|
}),
|
|
25
25
|
'assets-add': mergeAssets,
|
|
26
26
|
'assets-update': mergeAssets,
|
package/redux/selectors/index.js
CHANGED
|
@@ -39,7 +39,11 @@ const createFeeAssetSelectorDefinition = {
|
|
|
39
39
|
|
|
40
40
|
const getAssetSelectorDefinition = {
|
|
41
41
|
id: 'getAsset',
|
|
42
|
-
resultFunction: (assets) =>
|
|
42
|
+
resultFunction: (assets) =>
|
|
43
|
+
memoize((assetName) => {
|
|
44
|
+
if (!assetName) throw new Error('expected assetName')
|
|
45
|
+
return assets[assetName]
|
|
46
|
+
}),
|
|
43
47
|
dependencies: [{ selector: 'all' }],
|
|
44
48
|
}
|
|
45
49
|
|