@exodus/ethereum-lib 2.0.1 → 2.0.3
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.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "Ethereum Library",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "Exodus Movement, Inc.",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@exodus/asset-lib": "^3.4.0",
|
|
14
|
-
"@exodus/models": "^8.
|
|
14
|
+
"@exodus/models": "^8.4.0",
|
|
15
15
|
"@exodus/solidity-contract": "^0.1.3",
|
|
16
16
|
"base-x": "^3.0.2",
|
|
17
17
|
"ethereumjs-tx": "^1.3.7",
|
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"@exodus/assets": "8.0.x"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "afe105853a177b31f0652bb9edb8afbd2e898b80"
|
|
25
25
|
}
|
|
@@ -16,26 +16,26 @@ export const calculateBumpedGasPrice = (tx, currentGasPrice) => {
|
|
|
16
16
|
export default (
|
|
17
17
|
getFeeDataSelector,
|
|
18
18
|
getFeeSelector,
|
|
19
|
-
getWalletAccountBalancesSelector,
|
|
20
19
|
activeWalletAccountSelector,
|
|
21
20
|
getPersonalNoteByTxIdSelector,
|
|
22
21
|
getIsRbfEnabledSelector,
|
|
22
|
+
getIsEnoughBalanceToAccelerateSelector,
|
|
23
23
|
assets
|
|
24
24
|
) =>
|
|
25
25
|
createSelector(
|
|
26
26
|
getFeeDataSelector,
|
|
27
27
|
getFeeSelector,
|
|
28
|
-
getWalletAccountBalancesSelector,
|
|
29
28
|
activeWalletAccountSelector,
|
|
30
29
|
getPersonalNoteByTxIdSelector,
|
|
31
30
|
getIsRbfEnabledSelector,
|
|
31
|
+
getIsEnoughBalanceToAccelerateSelector,
|
|
32
32
|
(
|
|
33
33
|
getFeeData,
|
|
34
34
|
getFee,
|
|
35
|
-
getWalletAccountBalances,
|
|
36
35
|
activeWalletAccount,
|
|
37
36
|
getPersonalNoteByTxId,
|
|
38
|
-
getIsRbfEnabled
|
|
37
|
+
getIsRbfEnabled,
|
|
38
|
+
getIsEnoughBalanceToAccelerate
|
|
39
39
|
) => (tx) => {
|
|
40
40
|
const assetName = tx.coinName
|
|
41
41
|
const asset = assets[assetName]
|
|
@@ -44,12 +44,14 @@ export default (
|
|
|
44
44
|
if (!tx.pending || !tx.sent || tx.exchange || !tx.data?.gasLimit) return BumpType.NONE
|
|
45
45
|
if (getPersonalNoteByTxId(tx.txId)?.dapp) return BumpType.NONE
|
|
46
46
|
|
|
47
|
-
const walletAccountBalances = getWalletAccountBalances(activeWalletAccount)
|
|
48
47
|
const { gasPrice: currentGasPrice } = getFeeData(assetName)
|
|
49
48
|
const gasPriceToUse = calculateBumpedGasPrice(tx, currentGasPrice)
|
|
50
49
|
const replacementFee = gasPriceToUse.mul(tx.data.gasLimit)
|
|
51
50
|
const extraEthNeeded = replacementFee.sub(tx.feeAmount)
|
|
52
|
-
if (
|
|
51
|
+
if (
|
|
52
|
+
!getIsEnoughBalanceToAccelerate(activeWalletAccount, asset.baseAsset.name, extraEthNeeded)
|
|
53
|
+
)
|
|
54
|
+
return BumpType.NONE
|
|
53
55
|
|
|
54
56
|
return BumpType.RBF
|
|
55
57
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createSelector } from 'reselect'
|
|
2
|
+
|
|
3
|
+
export default (getWalletAccountBalancesSelector, getUnconfirmedEthereumBalanceSelector) =>
|
|
4
|
+
createSelector(
|
|
5
|
+
getWalletAccountBalancesSelector,
|
|
6
|
+
getUnconfirmedEthereumBalanceSelector,
|
|
7
|
+
(getWalletAccountBalances, getUnconfirmedEthereumBalance) => (
|
|
8
|
+
walletAccount,
|
|
9
|
+
assetName,
|
|
10
|
+
extraEthNeeded
|
|
11
|
+
) => {
|
|
12
|
+
const totalBalance = getWalletAccountBalances(walletAccount)[assetName]
|
|
13
|
+
const unconfirmedBalance = getUnconfirmedEthereumBalance({
|
|
14
|
+
asset: assetName,
|
|
15
|
+
walletAccount,
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
return totalBalance.sub(unconfirmedBalance).gte(extraEthNeeded)
|
|
19
|
+
}
|
|
20
|
+
)
|
package/src/selectors/index.js
CHANGED