@exodus/assets-feature 3.1.2 → 3.2.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,16 @@
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.2.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/assets-feature@3.1.2...@exodus/assets-feature@3.2.0) (2023-10-03)
7
+
8
+ ### Features
9
+
10
+ - enhance ACI with features from mobile ([#4299](https://github.com/ExodusMovement/exodus-hydra/issues/4299)) ([dcdf2ea](https://github.com/ExodusMovement/exodus-hydra/commit/dcdf2eadd85104460d31837b9300728a85c1c0b8))
11
+
12
+ ### Bug Fixes
13
+
14
+ - only search supported networks by default ([#4241](https://github.com/ExodusMovement/exodus-hydra/issues/4241)) ([17d2f86](https://github.com/ExodusMovement/exodus-hydra/commit/17d2f8681016c7d260d8905f2d5d8271815486f1))
15
+
6
16
  ## [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
17
 
8
18
  ### Bug Fixes
@@ -50,9 +50,12 @@ class AssetClientInterface {
50
50
  assetName,
51
51
  walletAccount,
52
52
  txs,
53
+ refresh = false,
53
54
  batch = this.blockchainMetadata.batch(),
54
55
  }) => {
55
- return batch.updateTxs({ assetName, walletAccount, txs })
56
+ return refresh
57
+ ? batch.overwriteTxs({ assetName, walletAccount, txs })
58
+ : batch.updateTxs({ assetName, walletAccount, txs })
56
59
  }
57
60
 
58
61
  removeTxLog = async (params) => {
@@ -74,20 +77,36 @@ class AssetClientInterface {
74
77
  return this.blockchainMetadata.getAccountState({ assetName, walletAccount })
75
78
  }
76
79
 
77
- async updateAccountState(params) {
78
- return this.updateAccountStateBatch(params).commit()
80
+ async updateAccountState({ assetName, walletAccount, ...params }) {
81
+ let { accountState } = params
82
+ if (!accountState) {
83
+ accountState = await this.getAccountState({ assetName, walletAccount })
84
+ }
85
+
86
+ return this.updateAccountStateBatch({
87
+ ...params,
88
+ assetName,
89
+ walletAccount,
90
+ accountState,
91
+ }).commit()
79
92
  }
80
93
 
81
94
  updateAccountStateBatch = ({
82
95
  assetName,
83
96
  walletAccount,
84
97
  newData,
98
+ accountState,
85
99
  batch = this.blockchainMetadata.batch(),
86
100
  }) => {
87
101
  if (!isEmpty(newData)) {
88
102
  return batch.updateAccountState({ assetName, walletAccount, newData })
89
103
  }
90
104
 
105
+ // merge mem to keep the previous accountMem behavior
106
+ if (newData.mem && (!accountState || accountState.mem)) {
107
+ newData = { ...newData, mem: { ...accountState?.mem, ...newData.mem } }
108
+ }
109
+
91
110
  return batch
92
111
  }
93
112
 
@@ -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.2.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": "423c1e963708c681fe11ad396afe65f9f956336f"
66
66
  }