@exodus/ethereum-lib 1.2.1 → 1.2.2
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": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Ethereum Library",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "Exodus Movement, Inc.",
|
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"@exodus/assets": "8.0.x"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "0c3b4952a99f9157becc9a3754a34e289a0a1095"
|
|
25
25
|
}
|
|
@@ -6,6 +6,13 @@ const BumpType = {
|
|
|
6
6
|
RBF: 2,
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
export const calculateBumpedGasPrice = (tx, currentGasPrice) => {
|
|
10
|
+
const usedGasPrice = tx.feeAmount.div(tx.data.gasLimit)
|
|
11
|
+
const bumpedGasPrice = usedGasPrice.mul(12).div(10)
|
|
12
|
+
|
|
13
|
+
return currentGasPrice.gt(bumpedGasPrice) ? currentGasPrice : bumpedGasPrice
|
|
14
|
+
}
|
|
15
|
+
|
|
9
16
|
export default (
|
|
10
17
|
getFeeDataSelector,
|
|
11
18
|
getFeeSelector,
|
|
@@ -31,10 +38,7 @@ export default (
|
|
|
31
38
|
|
|
32
39
|
const walletAccountBalances = getWalletAccountBalances(activeWalletAccount)
|
|
33
40
|
const { gasPrice: currentGasPrice } = getFeeData(assetName)
|
|
34
|
-
const
|
|
35
|
-
// new gas price should be at least 20% higher and not less than the current gas price
|
|
36
|
-
const bumpedGasPrice = usedGasPrice.mul(12).div(10)
|
|
37
|
-
const gasPriceToUse = currentGasPrice.gt(bumpedGasPrice) ? currentGasPrice : bumpedGasPrice
|
|
41
|
+
const gasPriceToUse = calculateBumpedGasPrice(tx, currentGasPrice)
|
|
38
42
|
const replacementFee = gasPriceToUse.mul(tx.data.gasLimit)
|
|
39
43
|
const extraEthNeeded = replacementFee.sub(tx.feeAmount)
|
|
40
44
|
if (walletAccountBalances[asset.baseAsset.name].lt(extraEthNeeded)) return BumpType.NONE
|
package/src/selectors/index.js
CHANGED