@exodus/ethereum-lib 1.1.0 → 1.1.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.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Ethereum Library",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "Exodus Movement, Inc.",
|
|
@@ -15,10 +15,11 @@
|
|
|
15
15
|
"@exodus/solidity-contract": "^0.1.3",
|
|
16
16
|
"base-x": "^3.0.2",
|
|
17
17
|
"ethereumjs-tx": "^1.3.7",
|
|
18
|
-
"ethereumjs-util": "^5.2.0"
|
|
18
|
+
"ethereumjs-util": "^5.2.0",
|
|
19
|
+
"reselect": "~3.0.1"
|
|
19
20
|
},
|
|
20
21
|
"peerDependencies": {
|
|
21
22
|
"@exodus/assets": "8.0.x"
|
|
22
23
|
},
|
|
23
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "f870ea64033c540ae7b1fedfa8ff4755d8b7e7d0"
|
|
24
25
|
}
|
package/src/constants.js
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { createSelector } from 'reselect'
|
|
2
|
+
|
|
3
|
+
const BumpType = {
|
|
4
|
+
NONE: 0,
|
|
5
|
+
CPFP: 1,
|
|
6
|
+
RBF: 2,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default (
|
|
10
|
+
getFeeDataSelector,
|
|
11
|
+
getFeeSelector,
|
|
12
|
+
getWalletAccountBalancesSelector,
|
|
13
|
+
activeWalletAccountSelector,
|
|
14
|
+
getPersonalNoteByTxIdSelector
|
|
15
|
+
) =>
|
|
16
|
+
createSelector(
|
|
17
|
+
getFeeDataSelector,
|
|
18
|
+
getFeeSelector,
|
|
19
|
+
getWalletAccountBalancesSelector,
|
|
20
|
+
activeWalletAccountSelector,
|
|
21
|
+
getPersonalNoteByTxIdSelector,
|
|
22
|
+
(getFeeData, getFee, getWalletAccountBalances, activeWalletAccount, getPersonalNoteByTxId) => (
|
|
23
|
+
tx
|
|
24
|
+
) => {
|
|
25
|
+
if (!['ethereum', 'ethereumclassic'].includes(tx.coinName)) return BumpType.NONE
|
|
26
|
+
if (!tx.pending || !tx.sent || tx.exchange) return BumpType.NONE
|
|
27
|
+
if (getPersonalNoteByTxId(tx.txId)?.dapp) return BumpType.NONE
|
|
28
|
+
|
|
29
|
+
const walletAccountBalances = getWalletAccountBalances(activeWalletAccount)
|
|
30
|
+
const assetName = tx.coinName
|
|
31
|
+
const { gasPrice } = getFeeData(assetName)
|
|
32
|
+
const usedGasPrice = tx.feeAmount.div(tx.meta.gasLimit)
|
|
33
|
+
if (usedGasPrice.gte(gasPrice)) {
|
|
34
|
+
return BumpType.NONE
|
|
35
|
+
}
|
|
36
|
+
const fee = getFee(assetName, { gasLimit: tx.meta.gasLimit })
|
|
37
|
+
.mul(11) // new gas price should be at least 10% higher
|
|
38
|
+
.div(10)
|
|
39
|
+
if (walletAccountBalances[assetName].lt(fee)) return BumpType.NONE
|
|
40
|
+
|
|
41
|
+
return BumpType.RBF
|
|
42
|
+
}
|
|
43
|
+
)
|