@exodus/ethereum-lib 2.0.7 → 2.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/ethereum-lib",
3
- "version": "2.0.7",
3
+ "version": "2.1.0",
4
4
  "description": "Ethereum Library",
5
5
  "main": "src/index.js",
6
6
  "author": "Exodus Movement, Inc.",
@@ -25,5 +25,5 @@
25
25
  "devDependencies": {
26
26
  "@exodus/models": "^8.5.1"
27
27
  },
28
- "gitHead": "42fbfc6f7d7af50691c871b363150d904d4e59fd"
28
+ "gitHead": "3530b1a7710f3aec0aba47dd761e4911629a96ad"
29
29
  }
@@ -10,17 +10,24 @@ const BumpType = {
10
10
 
11
11
  function isQueuedPendingTx(tx, activeWalletAccount, getTxLog) {
12
12
  const txLog = getTxLog('ethereum', activeWalletAccount)
13
- if (isQueuedPendingTx.minIndex >= 0 && txLog.getAt(isQueuedPendingTx.minIndex)?.pending) {
14
- return tx.data?.nonce > txLog.getAt(isQueuedPendingTx.minIndex).data.nonce
13
+ if (!txLog || txLog.size === 0) return false
14
+
15
+ const txAtMinIndex = txLog.getAt(isQueuedPendingTx.minIndex)
16
+ if (isQueuedPendingTx.minIndex >= 0 && txAtMinIndex && txAtMinIndex.pending) {
17
+ return tx.data && tx.data.nonce > txAtMinIndex.data.nonce
15
18
  }
16
19
  let minPendingNonce = Number.MAX_SAFE_INTEGER
17
20
  for (let index = 0; index < txLog.size; index++) {
18
21
  const _tx = txLog.getAt(index)
19
22
  if (!_tx.pending) continue
23
+
24
+ const nonce = _tx.data && _tx.data.nonce
25
+ if (nonce === undefined) continue
26
+
20
27
  // ignore nonce of a TX that just replaced an another tx
21
- if (_tx.data?.replacedTxId && Date.now() - _tx.date < MINUTE) continue
22
- if (_tx.sent && _tx.data?.nonce < minPendingNonce) {
23
- minPendingNonce = _tx.data.nonce
28
+ if (_tx.data.replacedTxId && Date.now() - _tx.date < MINUTE) continue
29
+ if (_tx.sent && nonce < minPendingNonce) {
30
+ minPendingNonce = nonce
24
31
  isQueuedPendingTx.minIndex = index
25
32
  }
26
33
  }
@@ -49,6 +56,7 @@ export default (
49
56
  getIsRbfEnabledSelector,
50
57
  getIsEnoughBalanceToAccelerateSelector,
51
58
  getTxLogSelector,
59
+ getIsFailedOrderByTxIdSelector,
52
60
  assets
53
61
  ) =>
54
62
  createSelector(
@@ -59,6 +67,7 @@ export default (
59
67
  getIsRbfEnabledSelector,
60
68
  getIsEnoughBalanceToAccelerateSelector,
61
69
  getTxLogSelector,
70
+ getIsFailedOrderByTxIdSelector,
62
71
  (
63
72
  getFeeData,
64
73
  getFee,
@@ -66,14 +75,24 @@ export default (
66
75
  getPersonalNoteByTxId,
67
76
  getIsRbfEnabled,
68
77
  getIsEnoughBalanceToAccelerate,
69
- getTxLog
78
+ getTxLog,
79
+ getIsFailedOrderByTxId
70
80
  ) => (tx) => {
71
81
  const assetName = tx.coinName
72
82
  const asset = assets[assetName]
73
83
  if (!getIsRbfEnabled(assetName)) return BumpType.NONE
74
84
  if (!['ETHEREUM_ERC20', 'ETHEREUM_LIKE'].includes(asset.assetType)) return BumpType.NONE
75
- if (!tx.pending || !tx.sent || tx.exchange || !tx.data?.gasLimit) return BumpType.NONE
76
- if (getPersonalNoteByTxId(tx.txId)?.dapp) return BumpType.NONE
85
+ const isFailedExchangeOrder = getIsFailedOrderByTxId(tx.txId)
86
+ if (
87
+ !tx.pending ||
88
+ !tx.sent ||
89
+ (tx.exchange && !isFailedExchangeOrder) ||
90
+ !tx.data ||
91
+ !tx.data.gasLimit
92
+ )
93
+ return BumpType.NONE
94
+ const personalNote = getPersonalNoteByTxId(tx.txId)
95
+ if (personalNote && personalNote.dapp) return BumpType.NONE
77
96
  if (isQueuedPendingTx(tx, activeWalletAccount, getTxLog)) return BumpType.NONE
78
97
 
79
98
  const { gasPrice: currentGasPrice } = getFeeData(assetName)