diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js index 87ab7a940..73589392b 100644 --- a/app/scripts/controllers/transactions/index.js +++ b/app/scripts/controllers/transactions/index.js @@ -329,38 +329,6 @@ export default class TransactionController extends EventEmitter { return { gasLimit, simulationFails } } - /** - Creates a new txMeta with the same txParams as the original - to allow the user to resign the transaction with a higher gas values - @param {number} originalTxId - the id of the txMeta that - you want to attempt to retry - @param {string} [gasPrice] - Optional gas price to be increased to use as the retry - transaction's gas price - @returns {txMeta} - */ - - async retryTransaction (originalTxId, gasPrice) { - const originalTxMeta = this.txStateManager.getTx(originalTxId) - const { txParams } = originalTxMeta - const lastGasPrice = gasPrice || originalTxMeta.txParams.gasPrice - const lastGasPriceBN = new ethUtil.BN(ethUtil.stripHexPrefix(lastGasPrice), 16) - // essentially lastGasPrice * 1.1 - const lastGasPriceBNBumped = lastGasPriceBN - .mul(new ethUtil.BN(110, 10)) - .div(new ethUtil.BN(100, 10)) - txParams.gasPrice = `0x${lastGasPriceBNBumped.toString(16)}` - - const txMeta = this.txStateManager.generateTxMeta({ - txParams: originalTxMeta.txParams, - lastGasPrice, - loadingDefaults: false, - type: TRANSACTION_TYPE_RETRY, - }) - this.addTx(txMeta) - this.emit('newUnapprovedTx', txMeta) - return txMeta - } - /** * Creates a new approved transaction to attempt to cancel a previously submitted transaction. The * new transaction contains the same nonce as the previous, is a basic ETH transfer of 0x value to diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 7a3aaea93..3e1cbedac 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -520,7 +520,6 @@ export default class MetamaskController extends EventEmitter { cancelTransaction: nodeify(txController.cancelTransaction, txController), updateTransaction: nodeify(txController.updateTransaction, txController), updateAndApproveTransaction: nodeify(txController.updateAndApproveTransaction, txController), - retryTransaction: nodeify(this.retryTransaction, this), createCancelTransaction: nodeify(this.createCancelTransaction, this), createSpeedUpTransaction: nodeify(this.createSpeedUpTransaction, this), getFilteredTxList: nodeify(txController.getFilteredTxList, txController), @@ -1373,18 +1372,6 @@ export default class MetamaskController extends EventEmitter { // END (VAULT / KEYRING RELATED METHODS) //============================================================================= - /** - * Allows a user to try to speed up a transaction by retrying it - * with higher gas. - * - * @param {string} txId - The ID of the transaction to speed up. - */ - async retryTransaction (txId, gasPrice) { - await this.txController.retryTransaction(txId, gasPrice) - const state = await this.getState() - return state - } - /** * Allows a user to attempt to cancel a previously submitted transaction by creating a new * transaction. diff --git a/test/unit/app/controllers/transactions/tx-controller-test.js b/test/unit/app/controllers/transactions/tx-controller-test.js index f6c773b9d..fc0d000e1 100644 --- a/test/unit/app/controllers/transactions/tx-controller-test.js +++ b/test/unit/app/controllers/transactions/tx-controller-test.js @@ -482,29 +482,6 @@ describe('Transaction Controller', function () { }) }) - describe('#retryTransaction', function () { - it('should create a new txMeta with the same txParams as the original one but with a higher gasPrice', async function () { - const txParams = { - gasPrice: '0xee6b2800', - nonce: '0x00', - from: '0xB09d8505E1F4EF1CeA089D47094f5DD3464083d4', - to: '0xB09d8505E1F4EF1CeA089D47094f5DD3464083d4', - data: '0x0', - } - txController.txStateManager._saveTxList([ - { id: 1, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams, history: [{}] }, - ]) - const txMeta = await txController.retryTransaction(1) - assert.equal(txMeta.txParams.gasPrice, '0x10642ac00', 'gasPrice should have a %10 gasPrice bump') - assert.equal(txMeta.txParams.nonce, txParams.nonce, 'nonce should be the same') - assert.equal(txMeta.txParams.from, txParams.from, 'from should be the same') - assert.equal(txMeta.txParams.to, txParams.to, 'to should be the same') - assert.equal(txMeta.txParams.data, txParams.data, 'data should be the same') - assert.ok(('lastGasPrice' in txMeta), 'should have the key `lastGasPrice`') - assert.equal(txController.txStateManager.getTxList().length, 2) - }) - }) - describe('#_markNonceDuplicatesDropped', function () { it('should mark all nonce duplicates as dropped without marking the confirmed transaction as dropped', function () { txController.txStateManager._saveTxList([ diff --git a/ui/app/store/actions.js b/ui/app/store/actions.js index 1bb0d3f9f..10c9a937d 100644 --- a/ui/app/store/actions.js +++ b/ui/app/store/actions.js @@ -1350,29 +1350,6 @@ export function clearPendingTokens () { } } -export function retryTransaction (txId, gasPrice) { - log.debug(`background.retryTransaction`) - let newTxId - - return (dispatch) => { - return new Promise((resolve, reject) => { - background.retryTransaction(txId, gasPrice, (err, newState) => { - if (err) { - dispatch(displayWarning(err.message)) - return reject(err) - } - - const { currentNetworkTxList } = newState - const { id } = currentNetworkTxList[currentNetworkTxList.length - 1] - newTxId = id - resolve(newState) - }) - }) - .then((newState) => dispatch(updateMetamaskState(newState))) - .then(() => newTxId) - } -} - export function createCancelTransaction (txId, customGasPrice) { log.debug('background.cancelTransaction') let newTxId