@exodus/ethereum-lib 2.0.6 → 2.0.8

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.6",
3
+ "version": "2.0.8",
4
4
  "description": "Ethereum Library",
5
5
  "main": "src/index.js",
6
6
  "author": "Exodus Movement, Inc.",
@@ -16,6 +16,7 @@
16
16
  "base-x": "^3.0.2",
17
17
  "ethereumjs-tx": "^1.3.7",
18
18
  "ethereumjs-util": "^5.2.0",
19
+ "ms": "^2.1.1",
19
20
  "reselect": "~3.0.1"
20
21
  },
21
22
  "peerDependencies": {
@@ -24,5 +25,5 @@
24
25
  "devDependencies": {
25
26
  "@exodus/models": "^8.5.1"
26
27
  },
27
- "gitHead": "38a0f167883abb62d45459bcd747f38a6c5a3b0d"
28
+ "gitHead": "57d3639cc6539825c14e53ef6c299d79920f54d3"
28
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
  }
@@ -72,8 +79,10 @@ export default (
72
79
  const asset = assets[assetName]
73
80
  if (!getIsRbfEnabled(assetName)) return BumpType.NONE
74
81
  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
82
+ if (!tx.pending || !tx.sent || tx.exchange || !tx.data || !tx.data.gasLimit)
83
+ return BumpType.NONE
84
+ const personalNote = getPersonalNoteByTxId(tx.txId)
85
+ if (personalNote && personalNote.dapp) return BumpType.NONE
77
86
  if (isQueuedPendingTx(tx, activeWalletAccount, getTxLog)) return BumpType.NONE
78
87
 
79
88
  const { gasPrice: currentGasPrice } = getFeeData(assetName)