@exodus/assets-feature 3.1.2 → 3.3.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,22 @@
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.3.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@3.2.0...@exodus/assets-feature@3.3.0) (2023-10-05)
7
+
8
+ ### Features
9
+
10
+ - use transaction signer ([#3751](https://github.com/ExodusMovement/exodus-hydra/issues/3751)) ([0e60e89](https://github.com/ExodusMovement/exodus-hydra/commit/0e60e8963a799435c5528f596447813b9e012ead))
11
+
12
+ ## [3.2.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@3.1.2...@exodus/assets-feature@3.2.0) (2023-10-03)
13
+
14
+ ### Features
15
+
16
+ - enhance ACI with features from mobile ([#4299](https://github.com/ExodusMovement/exodus-hydra/issues/4299)) ([dcdf2ea](https://github.com/ExodusMovement/exodus-hydra/commit/dcdf2eadd85104460d31837b9300728a85c1c0b8))
17
+
18
+ ### Bug Fixes
19
+
20
+ - only search supported networks by default ([#4241](https://github.com/ExodusMovement/exodus-hydra/issues/4241)) ([17d2f86](https://github.com/ExodusMovement/exodus-hydra/commit/17d2f8681016c7d260d8905f2d5d8271815486f1))
21
+
6
22
  ## [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
23
 
8
24
  ### Bug Fixes
@@ -6,6 +6,7 @@ class AssetClientInterface {
6
6
  #availableAssetNamesAtom
7
7
  #walletAccountsAtom
8
8
  #enabledWalletAccountsAtom
9
+ #transactionSigner
9
10
 
10
11
  constructor({
11
12
  blockchainMetadata,
@@ -16,6 +17,7 @@ class AssetClientInterface {
16
17
  availableAssetNamesAtom,
17
18
  addressProvider,
18
19
  feeMonitors,
20
+ transactionSigner,
19
21
  }) {
20
22
  this.blockchainMetadata = blockchainMetadata
21
23
  this.wallet = wallet
@@ -25,6 +27,7 @@ class AssetClientInterface {
25
27
  this.addressProvider = addressProvider
26
28
  this.feeMonitors = feeMonitors
27
29
  this.#availableAssetNamesAtom = availableAssetNamesAtom
30
+ this.#transactionSigner = transactionSigner
28
31
 
29
32
  // TODO: remove conditional when clients updated
30
33
  if (assetsModule.initialize) {
@@ -50,9 +53,12 @@ class AssetClientInterface {
50
53
  assetName,
51
54
  walletAccount,
52
55
  txs,
56
+ refresh = false,
53
57
  batch = this.blockchainMetadata.batch(),
54
58
  }) => {
55
- return batch.updateTxs({ assetName, walletAccount, txs })
59
+ return refresh
60
+ ? batch.overwriteTxs({ assetName, walletAccount, txs })
61
+ : batch.updateTxs({ assetName, walletAccount, txs })
56
62
  }
57
63
 
58
64
  removeTxLog = async (params) => {
@@ -74,20 +80,36 @@ class AssetClientInterface {
74
80
  return this.blockchainMetadata.getAccountState({ assetName, walletAccount })
75
81
  }
76
82
 
77
- async updateAccountState(params) {
78
- return this.updateAccountStateBatch(params).commit()
83
+ async updateAccountState({ assetName, walletAccount, ...params }) {
84
+ let { accountState } = params
85
+ if (!accountState) {
86
+ accountState = await this.getAccountState({ assetName, walletAccount })
87
+ }
88
+
89
+ return this.updateAccountStateBatch({
90
+ ...params,
91
+ assetName,
92
+ walletAccount,
93
+ accountState,
94
+ }).commit()
79
95
  }
80
96
 
81
97
  updateAccountStateBatch = ({
82
98
  assetName,
83
99
  walletAccount,
84
100
  newData,
101
+ accountState,
85
102
  batch = this.blockchainMetadata.batch(),
86
103
  }) => {
87
104
  if (!isEmpty(newData)) {
88
105
  return batch.updateAccountState({ assetName, walletAccount, newData })
89
106
  }
90
107
 
108
+ // merge mem to keep the previous accountMem behavior
109
+ if (newData.mem && (!accountState || accountState.mem)) {
110
+ newData = { ...newData, mem: { ...accountState?.mem, ...newData.mem } }
111
+ }
112
+
91
113
  return batch
92
114
  }
93
115
 
@@ -220,11 +242,10 @@ class AssetClientInterface {
220
242
 
221
243
  // wallet interface
222
244
 
223
- signTransaction = async ({ assetName, unsignedTx, walletAccount }) => {
224
- // eslint-disable-next-line unicorn/no-await-expression-member
225
- const accountIndex = (await this.#getWalletAccount(walletAccount)).index
245
+ signTransaction = async ({ assetName, unsignedTx, walletAccount: walletAccountName }) => {
226
246
  const baseAssetName = this.assetsModule.getAsset(assetName).baseAsset.name
227
- return this.wallet.signTransaction({ baseAssetName, unsignedTx, accountIndex })
247
+ const walletAccount = await this.#getWalletAccount(walletAccountName)
248
+ return this.#transactionSigner.signTransaction({ baseAssetName, unsignedTx, walletAccount })
228
249
  }
229
250
  }
230
251
 
package/client/index.js CHANGED
@@ -13,6 +13,7 @@ const assetsClientInterfaceDefinition = {
13
13
  'availableAssetNamesAtom',
14
14
  'addressProvider',
15
15
  'feeMonitors',
16
+ 'transactionSigner',
16
17
  ],
17
18
  }
18
19
 
@@ -330,11 +330,16 @@ export class AssetsModule extends ExodusModule {
330
330
  }
331
331
 
332
332
  searchTokens = async ({ baseAssetName, lifecycleStatus, query, excludeTags = ['offensive'] }) => {
333
+ assert(
334
+ !baseAssetName || typeof baseAssetName === 'string',
335
+ 'searchTokens(): baseAssetName must be a string if supplied'
336
+ )
333
337
  baseAssetName && this.#assertSupportsCustomTokens(baseAssetName)
334
338
 
339
+ const baseAssetNames = baseAssetName ? [baseAssetName] : this.#getCustomTokensNetworkNames()
335
340
  const tokens = await this.#fetch(
336
341
  'search',
337
- { baseAssetName, lifecycleStatus, query, excludeTags },
342
+ { baseAssetName: baseAssetNames, lifecycleStatus, query, excludeTags },
338
343
  'tokens'
339
344
  )
340
345
  const validTokens = tokens.filter(this.#validateCustomToken).map(normalizeToken)
@@ -344,6 +349,11 @@ export class AssetsModule extends ExodusModule {
344
349
  return validTokens
345
350
  }
346
351
 
352
+ #getCustomTokensNetworkNames = () =>
353
+ this.getBaseAssetNames().filter((assetName) =>
354
+ this.getAsset(assetName).api?.hasFeature?.('customTokens')
355
+ )
356
+
347
357
  #fetchUpdates = async (assetVersions) => {
348
358
  const updatedTokens = await this.#fetch('updates', assetVersions, 'tokens')
349
359
  const validatedTokens = updatedTokens.filter(this.#validateCustomToken).map(normalizeToken)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/assets-feature",
3
- "version": "3.1.2",
3
+ "version": "3.3.0",
4
4
  "license": "UNLICENSED",
5
5
  "description": "Assets module, clients and apis",
6
6
  "main": "index.js",
@@ -62,5 +62,5 @@
62
62
  "jest": "^29.1.2",
63
63
  "redux": "^4.0.0"
64
64
  },
65
- "gitHead": "ce4e99ff4dba391f43f279d90e5514f727a62063"
65
+ "gitHead": "791e546a70c1e544e7bb0e64502e431670b9bb86"
66
66
  }