@exodus/assets-feature 4.1.1 → 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 +17 -0
- package/README.md +36 -0
- package/client/asset-client-interface.js +20 -6
- package/client/index.js +1 -0
- package/module/assets-module.js +4 -4
- package/package.json +10 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,23 @@
|
|
|
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/assets-feature@4.1.2...@exodus/assets-feature@5.0.0) (2024-03-11)
|
|
7
|
+
|
|
8
|
+
### ⚠ BREAKING CHANGES
|
|
9
|
+
|
|
10
|
+
- get public key from `publicKeyProvider` (#5924)
|
|
11
|
+
|
|
12
|
+
### Code Refactoring
|
|
13
|
+
|
|
14
|
+
- get public key from `publicKeyProvider` ([#5924](https://github.com/ExodusMovement/exodus-hydra/issues/5924)) ([5f656cf](https://github.com/ExodusMovement/exodus-hydra/commit/5f656cf41503ff59e98dc0259b0e76b30c94a5e2))
|
|
15
|
+
|
|
16
|
+
## [4.1.2](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@4.1.1...@exodus/assets-feature@4.1.2) (2024-02-20)
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
- make sure the check does not throw ([#5070](https://github.com/ExodusMovement/exodus-hydra/issues/5070)) ([b145ecc](https://github.com/ExodusMovement/exodus-hydra/commit/b145ecce8d5e2720edc9f422b913268e5f5b8364))
|
|
21
|
+
- native tokens auto-disabling when already in registry ([#5736](https://github.com/ExodusMovement/exodus-hydra/issues/5736)) ([feb9e8c](https://github.com/ExodusMovement/exodus-hydra/commit/feb9e8cf79f43f5be3987108bb2bc307c3648365))
|
|
22
|
+
|
|
6
23
|
## [4.1.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@4.1.0...@exodus/assets-feature@4.1.1) (2024-01-19)
|
|
7
24
|
|
|
8
25
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -7,3 +7,39 @@ Assets module, clients and apis
|
|
|
7
7
|
```sh
|
|
8
8
|
yarn add @exodus/assets-feature
|
|
9
9
|
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
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
|
+
|
|
15
|
+
```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'
|
|
45
|
+
```
|
|
@@ -8,10 +8,10 @@ class AssetClientInterface {
|
|
|
8
8
|
#walletAccountsAtom
|
|
9
9
|
#enabledWalletAccountsAtom
|
|
10
10
|
#transactionSigner
|
|
11
|
+
#publicKeyProvider
|
|
11
12
|
|
|
12
13
|
constructor({
|
|
13
14
|
blockchainMetadata,
|
|
14
|
-
wallet,
|
|
15
15
|
walletAccountsAtom,
|
|
16
16
|
enabledWalletAccountsAtom,
|
|
17
17
|
assetsModule,
|
|
@@ -19,9 +19,9 @@ class AssetClientInterface {
|
|
|
19
19
|
addressProvider,
|
|
20
20
|
feeMonitors,
|
|
21
21
|
transactionSigner,
|
|
22
|
+
publicKeyProvider,
|
|
22
23
|
}) {
|
|
23
24
|
this.blockchainMetadata = blockchainMetadata
|
|
24
|
-
this.wallet = wallet
|
|
25
25
|
this.#walletAccountsAtom = walletAccountsAtom
|
|
26
26
|
this.#enabledWalletAccountsAtom = enabledWalletAccountsAtom
|
|
27
27
|
this.assetsModule = assetsModule
|
|
@@ -29,6 +29,7 @@ class AssetClientInterface {
|
|
|
29
29
|
this.feeMonitors = feeMonitors
|
|
30
30
|
this.#availableAssetNamesAtom = availableAssetNamesAtom
|
|
31
31
|
this.#transactionSigner = transactionSigner
|
|
32
|
+
this.#publicKeyProvider = publicKeyProvider
|
|
32
33
|
|
|
33
34
|
// TODO: remove conditional when clients updated
|
|
34
35
|
if (assetsModule.initialize) {
|
|
@@ -172,13 +173,26 @@ class AssetClientInterface {
|
|
|
172
173
|
|
|
173
174
|
// addresses interface
|
|
174
175
|
|
|
175
|
-
getPublicKey = async ({
|
|
176
|
+
getPublicKey = async ({
|
|
177
|
+
assetName,
|
|
178
|
+
walletAccount,
|
|
179
|
+
purpose = 44,
|
|
180
|
+
addressIndex = 0,
|
|
181
|
+
chainIndex = 0,
|
|
182
|
+
}) => {
|
|
176
183
|
const walletAccountInstance = await this.#getWalletAccount(walletAccount)
|
|
177
|
-
|
|
184
|
+
const asset = this.assetsModule.getAsset(assetName)
|
|
185
|
+
|
|
186
|
+
const keyIdentifier = asset.baseAsset.api.getKeyIdentifier({
|
|
187
|
+
purpose,
|
|
178
188
|
accountIndex: walletAccountInstance.index,
|
|
179
|
-
baseAssetName: assetName,
|
|
180
|
-
addressIndex,
|
|
181
189
|
chainIndex,
|
|
190
|
+
addressIndex,
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
return this.#publicKeyProvider.getPublicKey({
|
|
194
|
+
walletAccount: walletAccountInstance,
|
|
195
|
+
keyIdentifier,
|
|
182
196
|
})
|
|
183
197
|
}
|
|
184
198
|
|
package/client/index.js
CHANGED
package/module/assets-module.js
CHANGED
|
@@ -318,8 +318,8 @@ export class AssetsModule {
|
|
|
318
318
|
|
|
319
319
|
if (isEmpty(tokens)) return
|
|
320
320
|
|
|
321
|
-
const validTokens =
|
|
322
|
-
if (validTokens.length !==
|
|
321
|
+
const validTokens = tokens.filter(this.#validateCustomToken).map(normalizeToken)
|
|
322
|
+
if (validTokens.length !== tokens.length) this.#logger.warn('Invalid Custom Token schema')
|
|
323
323
|
|
|
324
324
|
const { fetchedAndHandledTokens, added, updated } = this.#handleFetchedTokens(validTokens)
|
|
325
325
|
|
|
@@ -481,8 +481,8 @@ export class AssetsModule {
|
|
|
481
481
|
|
|
482
482
|
#assertSupportsCustomTokens = (baseAssetName) => {
|
|
483
483
|
const baseAsset = this.getAsset(baseAssetName)
|
|
484
|
-
if (!baseAsset
|
|
485
|
-
const reason = `BUG: network ${baseAsset
|
|
484
|
+
if (!baseAsset?.api?.hasFeature('customTokens')) {
|
|
485
|
+
const reason = `BUG: network ${baseAsset?.name} does not support custom tokens.`
|
|
486
486
|
this.#logger.warn(reason)
|
|
487
487
|
throw new Error(reason)
|
|
488
488
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/assets-feature",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"description": "Assets module, clients and apis",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"author": "Exodus Movement Inc.",
|
|
8
8
|
"scripts": {
|
|
9
|
-
"test": "jest",
|
|
10
|
-
"lint": "eslint . --ignore-path ../../.gitignore",
|
|
9
|
+
"test": "run -T jest",
|
|
10
|
+
"lint": "run -T eslint . --ignore-path ../../.gitignore",
|
|
11
11
|
"lint:fix": "yarn lint --fix"
|
|
12
12
|
},
|
|
13
13
|
"files": [
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@exodus/available-assets": "^8.0.0",
|
|
47
|
+
"@exodus/bip44-constants": "^195.0.0",
|
|
47
48
|
"@exodus/bitcoin-meta": "^1.0.1",
|
|
48
49
|
"@exodus/bitcoin-plugin": "^1.0.3",
|
|
49
50
|
"@exodus/bitcoinregtest-plugin": "^1.0.3",
|
|
@@ -51,18 +52,20 @@
|
|
|
51
52
|
"@exodus/blockchain-metadata": "^15.1.0",
|
|
52
53
|
"@exodus/combined-assets-meta": "^1.2.5",
|
|
53
54
|
"@exodus/cosmos-plugin": "^1.0.0",
|
|
55
|
+
"@exodus/ethereum-lib": "^4.2.7",
|
|
54
56
|
"@exodus/ethereum-meta": "^1.1.0",
|
|
57
|
+
"@exodus/keychain": "^6.1.1",
|
|
55
58
|
"@exodus/models": "^9.1.1",
|
|
56
59
|
"@exodus/osmosis-plugin": "^1.0.0",
|
|
60
|
+
"@exodus/public-key-provider": "^2.0.0",
|
|
57
61
|
"@exodus/redux-dependency-injection": "^3.0.0",
|
|
58
62
|
"@exodus/storage-memory": "^2.1.1",
|
|
59
|
-
"@exodus/wallet-accounts": "^
|
|
63
|
+
"@exodus/wallet-accounts": "^16.2.0",
|
|
60
64
|
"@exodus/wild-emitter": "^1.0.0",
|
|
61
|
-
"
|
|
65
|
+
"bip39": "^3.1.0",
|
|
62
66
|
"events": "^3.3.0",
|
|
63
|
-
"jest": "^29.1.2",
|
|
64
67
|
"msw": "^2.0.0",
|
|
65
68
|
"redux": "^4.0.0"
|
|
66
69
|
},
|
|
67
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "d3a937080fe613b640536d3378eb002b4a1838a6"
|
|
68
71
|
}
|