@exodus/assets-feature 5.14.1 → 6.0.1

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
+ ## [6.0.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@6.0.0...@exodus/assets-feature@6.0.1) (2025-01-02)
7
+
8
+ **Note:** Version bump only for package @exodus/assets-feature
9
+
10
+ ## [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)
11
+
12
+ ### ⚠ BREAKING CHANGES
13
+
14
+ - **assets-feature:** forward configs from feature (#10825)
15
+
16
+ ### Features
17
+
18
+ - feat(assets-feature)!: forward configs from feature (#10825)
19
+
20
+ - feat: bitcoin as default multiple address mode (#10930)
21
+
22
+ ### License
23
+
24
+ - license: re-license under MIT license (#10580)
25
+
6
26
  ## [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)
7
27
 
8
28
  ### License
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @exodus/assets-feature
2
2
 
3
- Assets module, clients and apis
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 createExodus from '@exodus/headless'
17
-
18
- const container = createExodus({ adapters, config, port })
19
- const terribleTickersFeatureYouShouldNotUse = () => ({
20
- id: 'tickers',
21
- definitions: [
22
- {
23
- definition: {
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
 
@@ -36,12 +36,9 @@ class AssetClientInterface {
36
36
  this.#transactionSigner = transactionSigner
37
37
  this.#publicKeyProvider = publicKeyProvider
38
38
  this.#config = config
39
- this.#createLogger = createLogger
39
+ this.#createLogger = createLogger || (() => console)
40
40
 
41
- // TODO: remove conditional when clients updated
42
- if (assetsModule.initialize) {
43
- assetsModule.initialize({ assetClientInterface: this })
44
- }
41
+ assetsModule.initialize({ assetClientInterface: this })
45
42
  }
46
43
 
47
44
  createLogger(namespace) {
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
- { definition: assetsClientInterfaceDefinition },
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: config.multiAddressMode || {},
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: config.disabledPurposes || {},
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) => omit(value, assetNames))
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/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@exodus/assets-feature",
3
- "version": "5.14.1",
3
+ "version": "6.0.1",
4
4
  "license": "MIT",
5
- "description": "Assets module, clients and apis",
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",
@@ -48,23 +49,24 @@
48
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.0.3",
52
- "@exodus/bitcoinregtest-plugin": "^1.0.3",
53
- "@exodus/bitcointestnet-plugin": "^1.0.3",
54
- "@exodus/blockchain-metadata": "^15.7.0",
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.0.0",
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.6",
61
+ "@exodus/fusion-local": "^2.1.0",
61
62
  "@exodus/keychain": "^7.3.0",
62
- "@exodus/models": "^12.1.1",
63
- "@exodus/osmosis-plugin": "^1.0.0",
64
- "@exodus/public-key-provider": "^4.0.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",
65
67
  "@exodus/redux-dependency-injection": "^4.1.1",
66
68
  "@exodus/storage-memory": "^2.2.2",
67
- "@exodus/wallet-accounts": "^17.1.1",
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",
@@ -74,5 +76,5 @@
74
76
  "publishConfig": {
75
77
  "access": "public"
76
78
  },
77
- "gitHead": "97156baad5ad86796c5eb3721264ba7b0ebb6332"
79
+ "gitHead": "429302a8ac6da175a05ef21ee6c994161cf3c357"
78
80
  }
@@ -61,7 +61,8 @@ const createMultiAddressModeSelectorDefinition = {
61
61
  memoize((assetName) =>
62
62
  createSelector(
63
63
  multiAddressModeDataSelector,
64
- (multiAddressModeData) => multiAddressModeData[assetName] || false
64
+ (multiAddressModeData) =>
65
+ multiAddressModeData[assetName] ?? multiAddressModeData.bitcoin ?? false
65
66
  )
66
67
  ),
67
68
  dependencies: [{ selector: 'multiAddressMode' }],