@exodus/assets-feature 3.1.0 → 3.1.2
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 +12 -0
- package/client/asset-client-interface.js +38 -21
- package/module/assets-module.js +2 -1
- package/module/index.js +1 -17
- package/package.json +5 -5
- package/plugin/index.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
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
|
+
## [3.1.2](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@3.1.1...@exodus/assets-feature@3.1.2) (2023-09-28)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- factory does not pass all parameters to module ([#4264](https://github.com/ExodusMovement/exodus-hydra/issues/4264)) ([9267fdd](https://github.com/ExodusMovement/exodus-hydra/commit/9267fddeb6e0e53ba519273c6c7d48fb2d574305))
|
|
11
|
+
|
|
12
|
+
## [3.1.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@3.1.0...@exodus/assets-feature@3.1.1) (2023-09-20)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
- not all assets have api.hasFeature ([#4161](https://github.com/ExodusMovement/exodus-hydra/issues/4161)) ([1b60147](https://github.com/ExodusMovement/exodus-hydra/commit/1b601478423b7d288593809f1046649dd3b265c6))
|
|
17
|
+
|
|
6
18
|
## [3.1.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@3.0.0...@exodus/assets-feature@3.1.0) (2023-09-20)
|
|
7
19
|
|
|
8
20
|
### Features
|
|
@@ -32,6 +32,8 @@ class AssetClientInterface {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
// txHistory interface
|
|
36
|
+
|
|
35
37
|
getTxHistory = async ({ assetName, walletAccount }) => {
|
|
36
38
|
return this.blockchainMetadata.getTxLog({ assetName, walletAccount })
|
|
37
39
|
}
|
|
@@ -53,6 +55,21 @@ class AssetClientInterface {
|
|
|
53
55
|
return batch.updateTxs({ assetName, walletAccount, txs })
|
|
54
56
|
}
|
|
55
57
|
|
|
58
|
+
removeTxLog = async (params) => {
|
|
59
|
+
return this.removeTxLogBatch(params).commit()
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
removeTxLogBatch = ({
|
|
63
|
+
assetName,
|
|
64
|
+
walletAccount,
|
|
65
|
+
txs,
|
|
66
|
+
batch = this.blockchainMetadata.batch(),
|
|
67
|
+
}) => {
|
|
68
|
+
return batch.removeTxs({ assetName, walletAccount, txs })
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// accountState interface
|
|
72
|
+
|
|
56
73
|
async getAccountState({ assetName, walletAccount }) {
|
|
57
74
|
return this.blockchainMetadata.getAccountState({ assetName, walletAccount })
|
|
58
75
|
}
|
|
@@ -74,18 +91,7 @@ class AssetClientInterface {
|
|
|
74
91
|
return batch
|
|
75
92
|
}
|
|
76
93
|
|
|
77
|
-
|
|
78
|
-
return this.removeTxLogBatch(params).commit()
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
removeTxLogBatch = ({
|
|
82
|
-
assetName,
|
|
83
|
-
walletAccount,
|
|
84
|
-
txs,
|
|
85
|
-
batch = this.blockchainMetadata.batch(),
|
|
86
|
-
}) => {
|
|
87
|
-
return batch.removeTxs({ assetName, walletAccount, txs })
|
|
88
|
-
}
|
|
94
|
+
// walletAccounts interface
|
|
89
95
|
|
|
90
96
|
async getWalletAccounts({ assetName }) {
|
|
91
97
|
// In the future, the list of wallets may be different based on the provided assets
|
|
@@ -94,6 +100,8 @@ class AssetClientInterface {
|
|
|
94
100
|
return Object.keys(await this.#enabledWalletAccountsAtom.get())
|
|
95
101
|
}
|
|
96
102
|
|
|
103
|
+
// assets interface
|
|
104
|
+
|
|
97
105
|
async getAssetsForNetwork({ baseAssetName }) {
|
|
98
106
|
const availableAssetNames = new Set(await this.#availableAssetNamesAtom.get())
|
|
99
107
|
return pickBy(
|
|
@@ -102,6 +110,8 @@ class AssetClientInterface {
|
|
|
102
110
|
)
|
|
103
111
|
}
|
|
104
112
|
|
|
113
|
+
// configParams interface
|
|
114
|
+
|
|
105
115
|
async getConfirmationsNumber({ assetName }) {
|
|
106
116
|
const baseAsset = this.assetsModule.getAsset(assetName).baseAsset
|
|
107
117
|
return baseAsset.api?.getConfirmationsNumber ? baseAsset.api.getConfirmationsNumber() : 1
|
|
@@ -116,12 +126,20 @@ class AssetClientInterface {
|
|
|
116
126
|
return this.feeMonitors.getFeeData({ assetName: baseAssetName })
|
|
117
127
|
}
|
|
118
128
|
|
|
129
|
+
getFeeConfig = async ({ assetName }) => {
|
|
130
|
+
return this.feeMonitors.getFeeData({ assetName })
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// batch interface
|
|
134
|
+
|
|
119
135
|
// The interface consumer does not need to know the structure of the returned batch object, just
|
|
120
136
|
// that it needs to be passed along wherever operations need to be batched.
|
|
121
137
|
createOperationsBatch = () => this.blockchainMetadata.batch()
|
|
122
138
|
|
|
123
139
|
executeOperationsBatch = async (batch) => batch.commit()
|
|
124
140
|
|
|
141
|
+
// addresses interface
|
|
142
|
+
|
|
125
143
|
getPublicKey = async ({ assetName, walletAccount, addressIndex = 0, chainIndex = 0 }) => {
|
|
126
144
|
const walletAccountInstance = await this.#getWalletAccount(walletAccount)
|
|
127
145
|
return this.wallet.getPublicKey({
|
|
@@ -159,6 +177,7 @@ class AssetClientInterface {
|
|
|
159
177
|
|
|
160
178
|
return [...addresses].map((address) => address.toString())
|
|
161
179
|
}
|
|
180
|
+
|
|
162
181
|
getChangeAddresses = async (opts) => {
|
|
163
182
|
const addresses = await this.addressProvider.getChangeAddresses({
|
|
164
183
|
...opts,
|
|
@@ -191,13 +210,6 @@ class AssetClientInterface {
|
|
|
191
210
|
// no op!! getUnusedAddressIndexes loads from tx log, not from storage
|
|
192
211
|
}
|
|
193
212
|
|
|
194
|
-
signTransaction = async ({ assetName, unsignedTx, walletAccount }) => {
|
|
195
|
-
// eslint-disable-next-line unicorn/no-await-expression-member
|
|
196
|
-
const accountIndex = (await this.#getWalletAccount(walletAccount)).index
|
|
197
|
-
const baseAssetName = this.assetsModule.getAsset(assetName).baseAsset.name
|
|
198
|
-
return this.wallet.signTransaction({ baseAssetName, unsignedTx, accountIndex })
|
|
199
|
-
}
|
|
200
|
-
|
|
201
213
|
getNextChangeAddress = async ({ assetName, walletAccount }) => {
|
|
202
214
|
return this.addressProvider.getUnusedAddress({
|
|
203
215
|
assetName,
|
|
@@ -206,8 +218,13 @@ class AssetClientInterface {
|
|
|
206
218
|
})
|
|
207
219
|
}
|
|
208
220
|
|
|
209
|
-
|
|
210
|
-
|
|
221
|
+
// wallet interface
|
|
222
|
+
|
|
223
|
+
signTransaction = async ({ assetName, unsignedTx, walletAccount }) => {
|
|
224
|
+
// eslint-disable-next-line unicorn/no-await-expression-member
|
|
225
|
+
const accountIndex = (await this.#getWalletAccount(walletAccount)).index
|
|
226
|
+
const baseAssetName = this.assetsModule.getAsset(assetName).baseAsset.name
|
|
227
|
+
return this.wallet.signTransaction({ baseAssetName, unsignedTx, accountIndex })
|
|
211
228
|
}
|
|
212
229
|
}
|
|
213
230
|
|
package/module/assets-module.js
CHANGED
|
@@ -74,12 +74,13 @@ export class AssetsModule extends ExodusModule {
|
|
|
74
74
|
iconsStorage,
|
|
75
75
|
assetRegistry, // temporary
|
|
76
76
|
assetPlugins,
|
|
77
|
-
combinedAssetsList,
|
|
77
|
+
combinedAssetsList = [],
|
|
78
78
|
globalAssetRegistry, // temporary
|
|
79
79
|
validateCustomToken = () => true,
|
|
80
80
|
config = {},
|
|
81
81
|
}) {
|
|
82
82
|
super({ name: 'AssetsModule' })
|
|
83
|
+
|
|
83
84
|
this.#storage = storage
|
|
84
85
|
this.#isExternalRegistry = !!assetRegistry
|
|
85
86
|
this.#registry = this.#isExternalRegistry ? assetRegistry : initialAssetRegistry
|
package/module/index.js
CHANGED
|
@@ -2,23 +2,7 @@
|
|
|
2
2
|
import globalAssetRegistry from '@exodus/assets' // this is deprecated, do not use for any other purpose. Remove when we have @exodus/models v10.
|
|
3
3
|
import AssetsModule from './assets-module'
|
|
4
4
|
|
|
5
|
-
const createAssetsModule = ({
|
|
6
|
-
storage,
|
|
7
|
-
iconsStorage,
|
|
8
|
-
assetPlugins,
|
|
9
|
-
combinedAssetsList = [],
|
|
10
|
-
validateCustomToken,
|
|
11
|
-
config,
|
|
12
|
-
}) =>
|
|
13
|
-
new AssetsModule({
|
|
14
|
-
storage,
|
|
15
|
-
iconsStorage,
|
|
16
|
-
globalAssetRegistry,
|
|
17
|
-
assetPlugins,
|
|
18
|
-
combinedAssetsList,
|
|
19
|
-
validateCustomToken,
|
|
20
|
-
config,
|
|
21
|
-
})
|
|
5
|
+
const createAssetsModule = (props) => new AssetsModule({ ...props, globalAssetRegistry })
|
|
22
6
|
|
|
23
7
|
const assetsModuleDefinition = {
|
|
24
8
|
id: 'assetsModule',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/assets-feature",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"description": "Assets module, clients and apis",
|
|
6
6
|
"main": "index.js",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@exodus/assets": "^8.0.95",
|
|
44
|
-
"@exodus/atoms": "^5.7.
|
|
45
|
-
"@exodus/available-assets": "^
|
|
44
|
+
"@exodus/atoms": "^5.7.1",
|
|
45
|
+
"@exodus/available-assets": "^6.0.0",
|
|
46
46
|
"@exodus/bitcoin-meta": "^1.0.1",
|
|
47
47
|
"@exodus/bitcoin-plugin": "^1.0.3",
|
|
48
48
|
"@exodus/bitcoinregtest-plugin": "^1.0.3",
|
|
@@ -55,12 +55,12 @@
|
|
|
55
55
|
"@exodus/osmosis-plugin": "^1.0.0",
|
|
56
56
|
"@exodus/redux-dependency-injection": "^3.0.0",
|
|
57
57
|
"@exodus/storage-memory": "^2.1.1",
|
|
58
|
-
"@exodus/wallet-accounts": "^14.
|
|
58
|
+
"@exodus/wallet-accounts": "^14.1.0",
|
|
59
59
|
"@exodus/wild-emitter": "^1.0.0",
|
|
60
60
|
"eslint": "^8.44.0",
|
|
61
61
|
"events": "^3.3.0",
|
|
62
62
|
"jest": "^29.1.2",
|
|
63
63
|
"redux": "^4.0.0"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "ce4e99ff4dba391f43f279d90e5514f727a62063"
|
|
66
66
|
}
|
package/plugin/index.js
CHANGED
|
@@ -7,8 +7,8 @@ const createAssetsPlugin = ({ port, assetsModule, disabledPurposesAtom, multiAdd
|
|
|
7
7
|
port.emit('assets-load', {
|
|
8
8
|
assets,
|
|
9
9
|
defaultAccountStates: mapValues(
|
|
10
|
-
pickBy(assets, (asset) => asset.api
|
|
11
|
-
(asset) => asset
|
|
10
|
+
pickBy(assets, (asset) => asset.api?.hasFeature?.('accountState')),
|
|
11
|
+
(asset) => asset.api.createAccountState().create()
|
|
12
12
|
),
|
|
13
13
|
})
|
|
14
14
|
}
|