From 8198ec9ae1020d7dc43bd17180351e37b48847e0 Mon Sep 17 00:00:00 2001 From: Frankie Date: Mon, 26 Nov 2018 09:29:14 -1000 Subject: 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 --- app/scripts/controllers/transactions/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'app') 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, -- cgit v1.2.3