@exodus/assets-feature 5.14.0 → 6.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 +22 -0
- package/LICENSE +7 -0
- package/README.md +43 -30
- package/atoms/disabled-purposes.js +1 -1
- package/atoms/multi-address-mode.js +1 -1
- package/constants.js +12 -0
- package/index.js +18 -4
- package/module/asset-preferences.js +10 -4
- package/module/utils.js +1 -1
- package/package.json +24 -19
- package/redux/selectors/index.js +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
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
|
+
## [6.0.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@5.14.0...@exodus/assets-feature@6.0.0) (2024-12-26)
|
|
7
|
+
|
|
8
|
+
### ⚠ BREAKING CHANGES
|
|
9
|
+
|
|
10
|
+
- **assets-feature:** forward configs from feature (#10825)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- feat(assets-feature)!: forward configs from feature (#10825)
|
|
15
|
+
|
|
16
|
+
- feat: bitcoin as default multiple address mode (#10930)
|
|
17
|
+
|
|
18
|
+
### License
|
|
19
|
+
|
|
20
|
+
- license: re-license under MIT license (#10580)
|
|
21
|
+
|
|
22
|
+
## [5.14.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@5.14.0...@exodus/assets-feature@5.14.1) (2024-11-25)
|
|
23
|
+
|
|
24
|
+
### License
|
|
25
|
+
|
|
26
|
+
- license: re-license under MIT license (#10580)
|
|
27
|
+
|
|
6
28
|
## [5.14.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@5.13.1...@exodus/assets-feature@5.14.0) (2024-10-08)
|
|
7
29
|
|
|
8
30
|
### Features
|
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright (c) 2024 Exodus Movement, Inc.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @exodus/assets-feature
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This Exodus SDK feature provides access to instances of all blockchain asset adapters supported by the wallet, and enables you to search for and add custom tokens at runtime. Added tokens persist across restarts.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -12,34 +12,47 @@ yarn add @exodus/assets-feature
|
|
|
12
12
|
|
|
13
13
|
`@exodus/assets-feature` is bundled with `@exodus/headless`. It injects the `assetsAtom` into the IOC, which you can then reference in your feature's dependencies to get all/any particular assets.
|
|
14
14
|
|
|
15
|
+
Example:
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
const myModule = {
|
|
19
|
+
id: 'myModule',
|
|
20
|
+
type: 'module,
|
|
21
|
+
factory: ({ assetsAtom }) => {
|
|
22
|
+
// get all assets known at this moment
|
|
23
|
+
const { value: assets } = await assetsAtom.get()
|
|
24
|
+
assetsAtom.observe(({ value }) => {
|
|
25
|
+
// do something with updated assets
|
|
26
|
+
})
|
|
27
|
+
},
|
|
28
|
+
dependencies: ['assetsAtom']
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Play with it
|
|
33
|
+
|
|
34
|
+
1. Open the playground https://exodus-hydra.pages.dev/features/assets
|
|
35
|
+
2. Run `await exodus.assets.getAsset('bitcoin')` in the Dev Tools Console.
|
|
36
|
+
3. Run `await exodus.assets.searchTokens({ lifecycleStatus: ['c', 'v'], baseAssetName: 'ethereum' })` in the Dev Tools Console.
|
|
37
|
+
4. Run `await exodus.assets.addTokens({ assetIds: ['0x455e53CBB86018Ac2B8092FdCd39d8444aFFC3F6'], baseAssetName: 'ethereum', allowedStatusList: ['c', 'v'] })` in the Dev Tools Console to add the Polygon Ecosystem Token token on the ethereum chain (not financial advice).
|
|
38
|
+
|
|
39
|
+
See [api/index.d.ts](./api/index.d.ts) for more details on the API and token validation/curation status.
|
|
40
|
+
|
|
41
|
+
### API Side
|
|
42
|
+
|
|
43
|
+
See [using the sdk](../../docs/docs-website/docs/development/using-the-sdk.md#setup-the-api-side) for more details on how features plug into the SDK and the API interface in the [type declaration](./api/index.d.ts).
|
|
44
|
+
|
|
45
|
+
### UI Side
|
|
46
|
+
|
|
47
|
+
See [using the sdk](../../docs/docs-website/docs/development/using-the-sdk.md#events) for more details on basic UI-side setup.
|
|
48
|
+
|
|
15
49
|
```js
|
|
16
|
-
import
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
id: 'tickers',
|
|
25
|
-
type: 'api',
|
|
26
|
-
factory: ({ assetsAtom }) => ({
|
|
27
|
-
tickers: {
|
|
28
|
-
get: async (name) => {
|
|
29
|
-
const { value: assets } = await assetsAtom.get()
|
|
30
|
-
return assets[name].ticker
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
}),
|
|
34
|
-
|
|
35
|
-
// provided by `@exodus/assets-feature`
|
|
36
|
-
dependencies: ['assetsAtom'],
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
container.use(terribleTickersFeatureYouShouldNotUse())
|
|
43
|
-
const exodus = container.resolve()
|
|
44
|
-
exodus.tickers.get('bitcoin').then(console.log) // 'BTC'
|
|
50
|
+
import selectors from '~/ui/flux/selectors'
|
|
51
|
+
|
|
52
|
+
const MyComponent = () => {
|
|
53
|
+
const bitcoin = useSelector(selectors.assets.createAssetByNameSelector('bitcoin'))
|
|
54
|
+
const tx = await bitcoin.api.signTx({
|
|
55
|
+
// ...,
|
|
56
|
+
})
|
|
57
|
+
}
|
|
45
58
|
```
|
|
@@ -3,7 +3,7 @@ import { createStorageAtomFactory } from '@exodus/atoms'
|
|
|
3
3
|
const createDisabledPurposesAtom = ({ storage, logger, config }) => {
|
|
4
4
|
return createStorageAtomFactory({ storage, logger })({
|
|
5
5
|
key: 'disabledPurposes',
|
|
6
|
-
defaultValue: config.defaults
|
|
6
|
+
defaultValue: config.defaults,
|
|
7
7
|
isSoleWriter: true,
|
|
8
8
|
})
|
|
9
9
|
}
|
|
@@ -8,7 +8,7 @@ const { isUndefined } = lodash
|
|
|
8
8
|
const createMultiAddressModeAtom = ({ storage, fusion, logger, config }) => {
|
|
9
9
|
const storageAtom = createStorageAtomFactory({ storage, logger })({
|
|
10
10
|
key: 'multiAddressMode',
|
|
11
|
-
defaultValue: config.defaults
|
|
11
|
+
defaultValue: config.defaults,
|
|
12
12
|
isSoleWriter: true,
|
|
13
13
|
})
|
|
14
14
|
|
package/constants.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const multiAddressModeDefaultConfig = {
|
|
2
|
+
defaults: Object.create(null),
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export const disabledPurposesDefaultConfig = {
|
|
6
|
+
defaults: Object.create(null),
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const defaultConfig = {
|
|
10
|
+
multiAddressMode: multiAddressModeDefaultConfig,
|
|
11
|
+
disabledPurposes: disabledPurposesDefaultConfig,
|
|
12
|
+
}
|
package/index.js
CHANGED
|
@@ -9,17 +9,31 @@ import assetModuleDefinition from './module/index.js'
|
|
|
9
9
|
import customTokensMonitorDefinition from './monitor/index.js'
|
|
10
10
|
import assetPreferencesDefinition from './module/asset-preferences.js'
|
|
11
11
|
import assetsAtomDefinition from './atoms/assets.js'
|
|
12
|
+
import { defaultConfig } from './constants.js'
|
|
13
|
+
|
|
14
|
+
const assets = (config = Object.create(null)) => {
|
|
15
|
+
const {
|
|
16
|
+
multiAddressMode,
|
|
17
|
+
disabledPurposes,
|
|
18
|
+
compatibilityModeGapLimits,
|
|
19
|
+
compatibilityModeMultiAddressMode,
|
|
20
|
+
} = { ...defaultConfig, ...config }
|
|
12
21
|
|
|
13
|
-
const assets = ({ config = {} } = {}) => {
|
|
14
22
|
return {
|
|
15
23
|
id: 'assets',
|
|
16
24
|
definitions: [
|
|
17
|
-
{
|
|
25
|
+
{
|
|
26
|
+
definition: assetsClientInterfaceDefinition,
|
|
27
|
+
config: {
|
|
28
|
+
compatibilityModeGapLimits,
|
|
29
|
+
compatibilityModeMultiAddressMode,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
18
32
|
{ definition: assetsPluginDefinition },
|
|
19
33
|
{
|
|
20
34
|
definition: multiAddressModeAtomDefinition,
|
|
21
35
|
storage: { namespace: 'assetPreferences' },
|
|
22
|
-
config:
|
|
36
|
+
config: multiAddressMode,
|
|
23
37
|
},
|
|
24
38
|
{ definition: legacyAddressModeAtomDefinition },
|
|
25
39
|
{ definition: taprootAddressModeAtomDefinition },
|
|
@@ -27,7 +41,7 @@ const assets = ({ config = {} } = {}) => {
|
|
|
27
41
|
{
|
|
28
42
|
definition: disabledPurposesAtomDefinition,
|
|
29
43
|
storage: { namespace: 'assetPreferences' },
|
|
30
|
-
config:
|
|
44
|
+
config: disabledPurposes,
|
|
31
45
|
},
|
|
32
46
|
{ definition: assetsApiDefinition },
|
|
33
47
|
// TODO: add storage namespace once we remove customTokensStorage
|
|
@@ -25,11 +25,17 @@ class AssetPreferences {
|
|
|
25
25
|
...assetNames.reduce((acc, assetName) => {
|
|
26
26
|
acc[assetName] = true
|
|
27
27
|
return acc
|
|
28
|
-
},
|
|
28
|
+
}, Object.create(null)),
|
|
29
29
|
}))
|
|
30
30
|
|
|
31
31
|
disableMultiAddressMode = ({ assetNames }) =>
|
|
32
|
-
this.#multiAddressModeAtom.set((value) =>
|
|
32
|
+
this.#multiAddressModeAtom.set((value) => ({
|
|
33
|
+
...value,
|
|
34
|
+
...assetNames.reduce((acc, assetName) => {
|
|
35
|
+
acc[assetName] = false
|
|
36
|
+
return acc
|
|
37
|
+
}, Object.create(null)),
|
|
38
|
+
}))
|
|
33
39
|
|
|
34
40
|
enableLegacyAddressMode = async ({ assetNames }) => {
|
|
35
41
|
assert(
|
|
@@ -42,7 +48,7 @@ class AssetPreferences {
|
|
|
42
48
|
...assetNames.reduce((acc, assetName) => {
|
|
43
49
|
acc[assetName] = true
|
|
44
50
|
return acc
|
|
45
|
-
},
|
|
51
|
+
}, Object.create(null)),
|
|
46
52
|
}))
|
|
47
53
|
}
|
|
48
54
|
|
|
@@ -66,7 +72,7 @@ class AssetPreferences {
|
|
|
66
72
|
...assetNames.reduce((acc, assetName) => {
|
|
67
73
|
acc[assetName] = true
|
|
68
74
|
return acc
|
|
69
|
-
},
|
|
75
|
+
}, Object.create(null)),
|
|
70
76
|
}))
|
|
71
77
|
}
|
|
72
78
|
|
package/module/utils.js
CHANGED
|
@@ -4,7 +4,7 @@ import assert from 'minimalistic-assert'
|
|
|
4
4
|
|
|
5
5
|
const { get } = lodash
|
|
6
6
|
|
|
7
|
-
const BLACKLISTED_ERRORS = [/Cannot destructure property 'owner'/]
|
|
7
|
+
const BLACKLISTED_ERRORS = [/Cannot destructure property 'owner'/u]
|
|
8
8
|
|
|
9
9
|
export const getAssetFromAssetId = (assets, assetId, baseAssetName) => {
|
|
10
10
|
assert(assetId, 'getAssetFromAssetId(): assetId is required')
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/assets-feature",
|
|
3
|
-
"version": "
|
|
4
|
-
"license": "
|
|
5
|
-
"description": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "This Exodus SDK feature provides access to instances of all blockchain asset adapters supported by the wallet, and enables you to search for and add custom tokens at runtime.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"author": "Exodus Movement, Inc.",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"monitor",
|
|
20
20
|
"plugin",
|
|
21
21
|
"redux",
|
|
22
|
+
"constants.js",
|
|
22
23
|
"index.d.ts",
|
|
23
24
|
"CHANGELOG.md",
|
|
24
25
|
"README.md",
|
|
@@ -37,7 +38,7 @@
|
|
|
37
38
|
"@exodus/atoms": "^9.0.0",
|
|
38
39
|
"@exodus/basic-utils": "^3.0.1",
|
|
39
40
|
"@exodus/fetch": "^1.3.0",
|
|
40
|
-
"@exodus/fusion-atoms": "^1.
|
|
41
|
+
"@exodus/fusion-atoms": "^1.4.0",
|
|
41
42
|
"@exodus/timer": "^1.1.2",
|
|
42
43
|
"lodash": "^4.17.21",
|
|
43
44
|
"minimalistic-assert": "^1.0.1",
|
|
@@ -45,31 +46,35 @@
|
|
|
45
46
|
"reselect": "^3.0.1"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
|
-
"@exodus/available-assets": "^8.
|
|
49
|
+
"@exodus/available-assets": "^8.7.0",
|
|
49
50
|
"@exodus/bip44-constants": "^195.0.0",
|
|
50
51
|
"@exodus/bitcoin-meta": "^2.0.0",
|
|
51
|
-
"@exodus/bitcoin-plugin": "^1.
|
|
52
|
-
"@exodus/bitcoinregtest-plugin": "^1.0
|
|
53
|
-
"@exodus/bitcointestnet-plugin": "^1.
|
|
54
|
-
"@exodus/blockchain-metadata": "^15.
|
|
52
|
+
"@exodus/bitcoin-plugin": "^1.29.1",
|
|
53
|
+
"@exodus/bitcoinregtest-plugin": "^1.11.0",
|
|
54
|
+
"@exodus/bitcointestnet-plugin": "^1.13.1",
|
|
55
|
+
"@exodus/blockchain-metadata": "^15.7.1",
|
|
55
56
|
"@exodus/cardano-lib": "^2.2.0",
|
|
56
57
|
"@exodus/combined-assets-meta": "^3.0.0",
|
|
57
|
-
"@exodus/cosmos-plugin": "^1.
|
|
58
|
+
"@exodus/cosmos-plugin": "^1.3.3",
|
|
58
59
|
"@exodus/ethereum-lib": "^5.0.0",
|
|
59
60
|
"@exodus/ethereum-meta": "^2.0.0",
|
|
60
|
-
"@exodus/fusion-local": "^2.0
|
|
61
|
-
"@exodus/keychain": "^
|
|
62
|
-
"@exodus/
|
|
63
|
-
"@exodus/
|
|
64
|
-
"@exodus/
|
|
65
|
-
"@exodus/
|
|
66
|
-
"@exodus/
|
|
67
|
-
"@exodus/
|
|
61
|
+
"@exodus/fusion-local": "^2.1.0",
|
|
62
|
+
"@exodus/keychain": "^7.3.0",
|
|
63
|
+
"@exodus/logger": "^1.2.3",
|
|
64
|
+
"@exodus/models": "^12.3.0",
|
|
65
|
+
"@exodus/osmosis-plugin": "^1.3.3",
|
|
66
|
+
"@exodus/public-key-provider": "^4.0.2",
|
|
67
|
+
"@exodus/redux-dependency-injection": "^4.1.1",
|
|
68
|
+
"@exodus/storage-memory": "^2.2.2",
|
|
69
|
+
"@exodus/wallet-accounts": "^17.1.3",
|
|
68
70
|
"@exodus/wild-emitter": "^1.0.0",
|
|
69
71
|
"bip39": "^3.1.0",
|
|
70
72
|
"events": "^3.3.0",
|
|
71
73
|
"msw": "^2.0.0",
|
|
72
74
|
"redux": "^4.0.0"
|
|
73
75
|
},
|
|
74
|
-
"
|
|
76
|
+
"publishConfig": {
|
|
77
|
+
"access": "public"
|
|
78
|
+
},
|
|
79
|
+
"gitHead": "361f9f307a50254391dbf46ccb95e6520c203e29"
|
|
75
80
|
}
|
package/redux/selectors/index.js
CHANGED
|
@@ -61,7 +61,8 @@ const createMultiAddressModeSelectorDefinition = {
|
|
|
61
61
|
memoize((assetName) =>
|
|
62
62
|
createSelector(
|
|
63
63
|
multiAddressModeDataSelector,
|
|
64
|
-
(multiAddressModeData) =>
|
|
64
|
+
(multiAddressModeData) =>
|
|
65
|
+
multiAddressModeData[assetName] ?? multiAddressModeData.bitcoin ?? false
|
|
65
66
|
)
|
|
66
67
|
),
|
|
67
68
|
dependencies: [{ selector: 'multiAddressMode' }],
|