@exodus/assets-feature 1.1.0 → 1.2.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 +6 -0
- package/package.json +13 -4
- package/redux/id.js +1 -0
- package/redux/index.js +30 -0
- package/redux/initial-state.js +7 -0
- package/redux/selectors/index.js +48 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
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
|
+
## [1.2.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@1.1.0...@exodus/assets-feature@1.2.0) (2023-08-21)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- assets redux module ([#3453](https://github.com/ExodusMovement/exodus-hydra/issues/3453)) ([5d6e73c](https://github.com/ExodusMovement/exodus-hydra/commit/5d6e73c667f5f8ce8f830028572efa935994f6cd))
|
|
11
|
+
|
|
6
12
|
## [1.1.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@1.0.0...@exodus/assets-feature@1.1.0) (2023-08-21)
|
|
7
13
|
|
|
8
14
|
### Features
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/assets-feature",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"description": "Assets module, clients and apis",
|
|
6
6
|
"main": "index.js",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"client",
|
|
15
15
|
"module",
|
|
16
16
|
"plugin",
|
|
17
|
+
"redux",
|
|
17
18
|
"README.md",
|
|
18
19
|
"CHANGELOG.md",
|
|
19
20
|
"!**/__tests__/**"
|
|
@@ -29,15 +30,23 @@
|
|
|
29
30
|
"dependencies": {
|
|
30
31
|
"@exodus/basic-utils": "^2.1.0",
|
|
31
32
|
"lodash": "^4.17.21",
|
|
32
|
-
"minimalistic-assert": "^1.0.1"
|
|
33
|
+
"minimalistic-assert": "^1.0.1",
|
|
34
|
+
"reselect": "^3.0.1"
|
|
33
35
|
},
|
|
34
36
|
"devDependencies": {
|
|
37
|
+
"@exodus/assets": "^8.0.94",
|
|
35
38
|
"@exodus/available-assets": "^4.0.0",
|
|
39
|
+
"@exodus/bitcoin-meta": "^1.0.1",
|
|
40
|
+
"@exodus/ethereum-meta": "^1.0.30",
|
|
36
41
|
"@exodus/models": "^9.1.1",
|
|
42
|
+
"@exodus/redux-dependency-injection": "^1.0.2",
|
|
37
43
|
"@exodus/storage-memory": "^2.1.0",
|
|
38
44
|
"@exodus/wallet-accounts": "^12.0.2",
|
|
39
45
|
"@exodus/wild-emitter": "^1.0.0",
|
|
40
|
-
"
|
|
46
|
+
"eslint": "^8.44.0",
|
|
47
|
+
"events": "^3.3.0",
|
|
48
|
+
"jest": "^29.1.2",
|
|
49
|
+
"redux": "^4.0.0"
|
|
41
50
|
},
|
|
42
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "ae415ad730407a51764a46179dd88cc1b1c4c734"
|
|
43
52
|
}
|
package/redux/id.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default 'assets'
|
package/redux/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { keyBy } from '@exodus/basic-utils'
|
|
2
|
+
import id from './id'
|
|
3
|
+
import initialState from './initial-state'
|
|
4
|
+
import selectorDefinitions from './selectors'
|
|
5
|
+
|
|
6
|
+
const mergeAssets = (state, payload) => ({
|
|
7
|
+
...state,
|
|
8
|
+
data: {
|
|
9
|
+
...state.data,
|
|
10
|
+
...keyBy(payload, 'name'),
|
|
11
|
+
},
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
const assetsReduxDefinition = {
|
|
15
|
+
id,
|
|
16
|
+
type: 'redux-module',
|
|
17
|
+
initialState,
|
|
18
|
+
eventReducers: {
|
|
19
|
+
'assets-load': (state, payload) => ({
|
|
20
|
+
error: null,
|
|
21
|
+
loaded: true,
|
|
22
|
+
data: keyBy(payload, 'name'),
|
|
23
|
+
}),
|
|
24
|
+
'assets-add': mergeAssets,
|
|
25
|
+
'assets-update': mergeAssets,
|
|
26
|
+
},
|
|
27
|
+
selectorDefinitions,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default assetsReduxDefinition
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { keyBy } from '@exodus/basic-utils'
|
|
2
|
+
import { createSelector } from 'reselect'
|
|
3
|
+
|
|
4
|
+
import { memoize } from 'lodash'
|
|
5
|
+
|
|
6
|
+
// just a semantic alias for `data`
|
|
7
|
+
const allAssetsSelectorDefinition = {
|
|
8
|
+
id: 'all',
|
|
9
|
+
resultFunction: (data) => data,
|
|
10
|
+
dependencies: [{ selector: 'data' }],
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const allByTickerSelectorDefinition = {
|
|
14
|
+
id: 'allByTicker',
|
|
15
|
+
resultFunction: (assets) => keyBy(Object.values(assets), (asset) => asset.ticker),
|
|
16
|
+
dependencies: [{ selector: 'all' }],
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const createAssetSelectorDefinition = {
|
|
20
|
+
id: 'createAssetSelector',
|
|
21
|
+
selectorFactory: (dataSelector) =>
|
|
22
|
+
memoize((assetName) => createSelector(dataSelector, (data) => data[assetName])),
|
|
23
|
+
dependencies: [{ selector: 'data' }],
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const createBaseAssetSelectorDefinition = {
|
|
27
|
+
id: 'createBaseAssetSelector',
|
|
28
|
+
selectorFactory: (dataSelector) =>
|
|
29
|
+
memoize((assetName) => createSelector(dataSelector, (data) => data[assetName].baseAsset)),
|
|
30
|
+
dependencies: [{ selector: 'data' }],
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const createFeeAssetSelectorDefinition = {
|
|
34
|
+
id: 'createFeeAssetSelector',
|
|
35
|
+
selectorFactory: (dataSelector) =>
|
|
36
|
+
memoize((assetName) => createSelector(dataSelector, (data) => data[assetName].feeAsset)),
|
|
37
|
+
dependencies: [{ selector: 'data' }],
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const assetSelectors = [
|
|
41
|
+
allAssetsSelectorDefinition,
|
|
42
|
+
allByTickerSelectorDefinition,
|
|
43
|
+
createAssetSelectorDefinition,
|
|
44
|
+
createBaseAssetSelectorDefinition,
|
|
45
|
+
createFeeAssetSelectorDefinition,
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
export default assetSelectors
|