aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts
diff options
context:
space:
mode:
authorFrankie <frankie.diamond@gmail.com>2018-11-27 03:29:14 +0800
committerGitHub <noreply@github.com>2018-11-27 03:29:14 +0800
commit8198ec9ae1020d7dc43bd17180351e37b48847e0 (patch)
treee0972c87b3a657d79b6ce0f3810115aa48a0aa7d /app/scripts
parent97c1e6bcc145e60d6721ecba50d762791f94dc13 (diff)
downloadtangerine-wallet-browser-8198ec9ae1020d7dc43bd17180351e37b48847e0.tar
tangerine-wallet-browser-8198ec9ae1020d7dc43bd17180351e37b48847e0.tar.gz
tangerine-wallet-browser-8198ec9ae1020d7dc43bd17180351e37b48847e0.tar.bz2
tangerine-wallet-browser-8198ec9ae1020d7dc43bd17180351e37b48847e0.tar.lz
tangerine-wallet-browser-8198ec9ae1020d7dc43bd17180351e37b48847e0.tar.xz
tangerine-wallet-browser-8198ec9ae1020d7dc43bd17180351e37b48847e0.tar.zst
tangerine-wallet-browser-8198ec9ae1020d7dc43bd17180351e37b48847e0.zip
Autofill gasPrice for retry attempts with either the recommended gasprice or a %10 bump (#5786)
* transactions - autofill gasPrice for retry attempts with either the recomened gasprice or a %10 bump * lint
Diffstat (limited to 'app/scripts')
-rw-r--r--app/scripts/controllers/transactions/index.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js
index b44f66f14..1dd410d2c 100644
--- a/app/scripts/controllers/transactions/index.js
+++ b/app/scripts/controllers/transactions/index.js
@@ -229,7 +229,16 @@ class TransactionController extends EventEmitter {
async retryTransaction (originalTxId) {
const originalTxMeta = this.txStateManager.getTx(originalTxId)
+ const { txParams } = originalTxMeta
const lastGasPrice = originalTxMeta.txParams.gasPrice
+ const suggestedGasPriceBN = new ethUtil.BN(ethUtil.stripHexPrefix(this.getGasPrice()), 16)
+ const lastGasPriceBN = new ethUtil.BN(ethUtil.stripHexPrefix(lastGasPrice), 16)
+ // essentially lastGasPrice * 1.1 but
+ // dont trust decimals so a round about way of doing that
+ const lastGasPriceBNBumped = lastGasPriceBN.mul(new ethUtil.BN(110, 10)).div(new ethUtil.BN(100, 10))
+ // transactions that are being retried require a >=%10 bump or the clients will throw an error
+ txParams.gasPrice = suggestedGasPriceBN.gt(lastGasPriceBNBumped) ? `0x${suggestedGasPriceBN.toString(16)}` : `0x${lastGasPriceBNBumped.toString(16)}`
+
const txMeta = this.txStateManager.generateTxMeta({
txParams: originalTxMeta.txParams,
lastGasPrice,