@exodus/available-assets 4.0.0 → 5.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 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
+ ## [5.0.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/available-assets@4.1.0...@exodus/available-assets@5.0.0) (2023-08-25)
7
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ - remove store and actions from setup redux (#3575)
11
+
12
+ ### Features
13
+
14
+ - add atom observer in available-assets plugin ([#3553](https://github.com/ExodusMovement/exodus-hydra/issues/3553)) ([26d769c](https://github.com/ExodusMovement/exodus-hydra/commit/26d769c0536d4c0f99b5ea4ca5a7f4123ba16d6f))
15
+
16
+ ### Code Refactoring
17
+
18
+ - remove store and actions from setup redux ([#3575](https://github.com/ExodusMovement/exodus-hydra/issues/3575)) ([64fa4a6](https://github.com/ExodusMovement/exodus-hydra/commit/64fa4a6c2b69409a81ab140adbdf84646f1be73a))
19
+
20
+ ## [4.1.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/available-assets@4.0.0...@exodus/available-assets@4.1.0) (2023-08-22)
21
+
22
+ ### Features
23
+
24
+ - add available-assets redux module ([#3504](https://github.com/ExodusMovement/exodus-hydra/issues/3504)) ([6a2cb36](https://github.com/ExodusMovement/exodus-hydra/commit/6a2cb368f35258c47e61f386bddc3e72e70c1c80))
25
+
6
26
  ## [4.0.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/available-assets@3.0.1...@exodus/available-assets@4.0.0) (2023-08-10)
7
27
 
8
28
  ### ⚠ BREAKING CHANGES
package/index.js CHANGED
@@ -4,6 +4,7 @@ import {
4
4
  } from './atoms'
5
5
  import availableAssetsModuleDefinition from './module'
6
6
  import availableAssetsApiDefinition from './api'
7
+ import availableAssetsPluginDefinition from './plugins'
7
8
 
8
9
  const availableAssets = () => ({
9
10
  id: 'availableAssets',
@@ -15,6 +16,7 @@ const availableAssets = () => ({
15
16
  { definition: availableAssetNamesAtomDefinition },
16
17
  { definition: availableAssetNamesWithoutParentCombinedAtomDefinition },
17
18
  { definition: availableAssetsApiDefinition },
19
+ { definition: availableAssetsPluginDefinition },
18
20
  ],
19
21
  })
20
22
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/available-assets",
3
- "version": "4.0.0",
3
+ "version": "5.0.0",
4
4
  "description": "Tracks supported/available assets, i.e. assets that the user can potentially enable via the UI",
5
5
  "license": "UNLICENSED",
6
6
  "author": "Exodus Movement Inc.",
@@ -14,6 +14,8 @@
14
14
  "module",
15
15
  "atoms",
16
16
  "api",
17
+ "redux",
18
+ "plugins",
17
19
  "README.md",
18
20
  "CHANGELOG.md",
19
21
  "!**/__tests__/**"
@@ -27,18 +29,22 @@
27
29
  "url": "git+https://github.com/ExodusMovement/exodus-hydra.git"
28
30
  },
29
31
  "dependencies": {
30
- "@exodus/atoms": "^5.4.0",
32
+ "@exodus/atoms": "^5.5.0",
31
33
  "@exodus/basic-utils": "^2.0.0",
32
34
  "@exodus/module": "^1.1.0",
33
35
  "lodash": "^4.17.21",
34
- "make-concurrent": "^5.3.0"
36
+ "make-concurrent": "^5.3.0",
37
+ "reselect": "^4.1.8"
35
38
  },
36
39
  "devDependencies": {
37
40
  "@exodus/assets-base": "^8.1.10",
41
+ "@exodus/assets-feature": "^1.3.0",
38
42
  "@exodus/enabled-assets": "^6.0.2",
43
+ "@exodus/redux-dependency-injection": "^2.0.1",
39
44
  "eslint": "^8.44.0",
40
45
  "jest": "^29.1.2",
41
- "jest-when": "^3.6.0"
46
+ "jest-when": "^3.6.0",
47
+ "redux": "^4.2.1"
42
48
  },
43
- "gitHead": "144444103b1290f16a92a6d9931ad0978cdbcc2b"
49
+ "gitHead": "c675747e01ce376e8b590d72b4f6d97c5f8a6c6a"
44
50
  }
@@ -0,0 +1,32 @@
1
+ import { createAtomObserver } from '@exodus/atoms'
2
+
3
+ const createAvailableAssetsPlugin = ({ port, availableAssetNamesAtom }) => {
4
+ const availableAssetNamesAtomObserver = createAtomObserver({
5
+ port,
6
+ atom: availableAssetNamesAtom,
7
+ event: 'availableAssetNames',
8
+ })
9
+ availableAssetNamesAtomObserver.register()
10
+
11
+ const onLoad = () => {
12
+ availableAssetNamesAtomObserver.start()
13
+ }
14
+
15
+ const onStop = () => {
16
+ availableAssetNamesAtomObserver.unregister()
17
+ }
18
+
19
+ return {
20
+ onLoad,
21
+ onStop,
22
+ }
23
+ }
24
+
25
+ const availableAssetsPluginDefinition = {
26
+ id: 'availableAssetsPlugin',
27
+ type: 'plugin',
28
+ factory: createAvailableAssetsPlugin,
29
+ dependencies: ['port', 'availableAssetNamesAtom'],
30
+ }
31
+
32
+ export default availableAssetsPluginDefinition
package/redux/id.js ADDED
@@ -0,0 +1 @@
1
+ export default 'availableAssets'
package/redux/index.js ADDED
@@ -0,0 +1,18 @@
1
+ import id from './id'
2
+ import initialState from './initial-state'
3
+ import selectorDefinitions from './selectors'
4
+
5
+ const availableAssetsReduxDefinition = {
6
+ id,
7
+ type: 'redux-module',
8
+ initialState,
9
+ eventReducers: {
10
+ availableAssetNames: (state, availableAssetNames) => ({
11
+ ...state,
12
+ data: new Set(availableAssetNames),
13
+ }),
14
+ },
15
+ selectorDefinitions,
16
+ }
17
+
18
+ export default availableAssetsReduxDefinition
@@ -0,0 +1,5 @@
1
+ const initialState = {
2
+ data: new Set(),
3
+ }
4
+
5
+ export default initialState
@@ -0,0 +1,18 @@
1
+ import { memoize } from 'lodash'
2
+ import { pickBy } from '@exodus/basic-utils'
3
+
4
+ const resultFunction = (availableAssets) =>
5
+ memoize((baseAssetName) => {
6
+ return pickBy(availableAssets, (asset) => asset.baseAsset.name === baseAssetName)
7
+ })
8
+
9
+ const allForNetworkSelectorDefinition = {
10
+ id: 'allForNetwork',
11
+ resultFunction,
12
+ dependencies: [
13
+ //
14
+ { selector: 'all' },
15
+ ],
16
+ }
17
+
18
+ export default allForNetworkSelectorDefinition
@@ -0,0 +1,29 @@
1
+ import { mapValues, pick } from '@exodus/basic-utils'
2
+
3
+ const resultFunction = (assets, availableAssetNames) => {
4
+ const availableAssets = pick(assets, [...availableAssetNames])
5
+
6
+ return mapValues(availableAssets, (asset) => {
7
+ if (!asset.isCombined) return asset
8
+
9
+ const combinedAssets = asset.combinedAssets.filter((asset) =>
10
+ availableAssetNames.has(asset.name)
11
+ )
12
+
13
+ const combinedAssetNames = combinedAssets.map((asset) => asset.name)
14
+
15
+ return { ...asset, combinedAssets, combinedAssetNames }
16
+ })
17
+ }
18
+
19
+ const allSelectorDefinition = {
20
+ id: 'all',
21
+ resultFunction,
22
+ dependencies: [
23
+ //
24
+ { module: 'assets', selector: 'all' },
25
+ { selector: 'data' },
26
+ ],
27
+ }
28
+
29
+ export default allSelectorDefinition
@@ -0,0 +1,8 @@
1
+ import allSelectorDefinition from './all'
2
+ import allForNetworkSelectorDefinition from './all-for-network'
3
+
4
+ export default [
5
+ //
6
+ allSelectorDefinition,
7
+ allForNetworkSelectorDefinition,
8
+ ]