@exodus/ethereum-lib 2.0.2 → 2.0.5
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 +5 -2
- package/src/selectors/get-can-accelerate-tx-factory.js +23 -1
- package/yarn-error.log +0 -9309
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/ethereum-lib",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
4
4
|
"description": "Ethereum Library",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "Exodus Movement, Inc.",
|
|
@@ -21,5 +21,8 @@
|
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"@exodus/assets": "8.0.x"
|
|
23
23
|
},
|
|
24
|
-
"
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@exodus/models": "^8.5.1"
|
|
26
|
+
},
|
|
27
|
+
"gitHead": "52af7a402c4716883165bfbd1c9b685fd707b3ea"
|
|
25
28
|
}
|
|
@@ -6,6 +6,24 @@ const BumpType = {
|
|
|
6
6
|
RBF: 2,
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
function isQueuedPendingTx(tx, activeWalletAccount, getTxLog) {
|
|
10
|
+
const txLog = getTxLog('ethereum', activeWalletAccount)
|
|
11
|
+
if (isQueuedPendingTx.minIndex >= 0 && txLog.getAt(isQueuedPendingTx.minIndex)?.pending) {
|
|
12
|
+
return tx.data?.nonce > txLog.getAt(isQueuedPendingTx.minIndex).data.nonce
|
|
13
|
+
}
|
|
14
|
+
let minPendingNonce = Number.MAX_SAFE_INTEGER
|
|
15
|
+
for (let index = 0; index < txLog.size; index++) {
|
|
16
|
+
const _tx = txLog.getAt(index)
|
|
17
|
+
if (!_tx.pending) continue
|
|
18
|
+
if (_tx.sent && _tx.data?.nonce < minPendingNonce) {
|
|
19
|
+
minPendingNonce = _tx.data.nonce
|
|
20
|
+
isQueuedPendingTx.minIndex = index
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return tx.data.nonce > minPendingNonce
|
|
25
|
+
}
|
|
26
|
+
|
|
9
27
|
export const calculateBumpedGasPrice = (tx, currentGasPrice) => {
|
|
10
28
|
const usedGasPrice = tx.feeAmount.div(tx.data.gasLimit)
|
|
11
29
|
const bumpedGasPrice = usedGasPrice.mul(12).div(10)
|
|
@@ -20,6 +38,7 @@ export default (
|
|
|
20
38
|
getPersonalNoteByTxIdSelector,
|
|
21
39
|
getIsRbfEnabledSelector,
|
|
22
40
|
getIsEnoughBalanceToAccelerateSelector,
|
|
41
|
+
getTxLogSelector,
|
|
23
42
|
assets
|
|
24
43
|
) =>
|
|
25
44
|
createSelector(
|
|
@@ -29,13 +48,15 @@ export default (
|
|
|
29
48
|
getPersonalNoteByTxIdSelector,
|
|
30
49
|
getIsRbfEnabledSelector,
|
|
31
50
|
getIsEnoughBalanceToAccelerateSelector,
|
|
51
|
+
getTxLogSelector,
|
|
32
52
|
(
|
|
33
53
|
getFeeData,
|
|
34
54
|
getFee,
|
|
35
55
|
activeWalletAccount,
|
|
36
56
|
getPersonalNoteByTxId,
|
|
37
57
|
getIsRbfEnabled,
|
|
38
|
-
getIsEnoughBalanceToAccelerate
|
|
58
|
+
getIsEnoughBalanceToAccelerate,
|
|
59
|
+
getTxLog
|
|
39
60
|
) => (tx) => {
|
|
40
61
|
const assetName = tx.coinName
|
|
41
62
|
const asset = assets[assetName]
|
|
@@ -43,6 +64,7 @@ export default (
|
|
|
43
64
|
if (!['ETHEREUM_ERC20', 'ETHEREUM_LIKE'].includes(asset.assetType)) return BumpType.NONE
|
|
44
65
|
if (!tx.pending || !tx.sent || tx.exchange || !tx.data?.gasLimit) return BumpType.NONE
|
|
45
66
|
if (getPersonalNoteByTxId(tx.txId)?.dapp) return BumpType.NONE
|
|
67
|
+
if (isQueuedPendingTx(tx, activeWalletAccount, getTxLog)) return BumpType.NONE
|
|
46
68
|
|
|
47
69
|
const { gasPrice: currentGasPrice } = getFeeData(assetName)
|
|
48
70
|
const gasPriceToUse = calculateBumpedGasPrice(tx, currentGasPrice)
|