From d8ab9cc002c10757b7382a174dafff7a0247e307 Mon Sep 17 00:00:00 2001 From: Alexander Tseung Date: Sun, 9 Dec 2018 12:48:06 -0800 Subject: Group transactions by nonce (#5886) --- app/_locales/en/messages.json | 36 ++++++++++++++++++++------- app/images/icons/cancelled.svg | 3 +++ app/images/icons/confirm.svg | 3 +++ app/images/icons/error.svg | 4 +++ app/images/icons/new.svg | 3 +++ app/images/icons/retry.svg | 7 ++++++ app/images/icons/submitted.svg | 3 +++ app/scripts/controllers/transactions/enums.js | 2 ++ app/scripts/controllers/transactions/index.js | 6 +++-- app/scripts/metamask-controller.js | 14 +++++++---- 10 files changed, 65 insertions(+), 16 deletions(-) create mode 100755 app/images/icons/cancelled.svg create mode 100644 app/images/icons/confirm.svg create mode 100644 app/images/icons/error.svg create mode 100755 app/images/icons/new.svg create mode 100755 app/images/icons/retry.svg create mode 100755 app/images/icons/submitted.svg (limited to 'app') diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index d23de5fa0..400633c8c 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -17,6 +17,9 @@ "confirmClear": { "message": "Are you sure you want to clear approved websites?" }, + "contractInteraction": { + "message": "Contract Interaction" + }, "clearApprovalDataSuccess": { "message": "Approved website data cleared successfully." }, @@ -185,6 +188,9 @@ "cancellationGasFee": { "message": "Cancellation Gas Fee" }, + "cancelled": { + "message": "Cancelled" + }, "cancelN": { "message": "Cancel all $1 transactions" }, @@ -1177,6 +1183,12 @@ "speedUpSubtitle": { "message": "Increase your gas price to attempt to overwrite and speed up your transaction" }, + "speedUpCancellation": { + "message": "Speed up this cancellation" + }, + "speedUpTransaction": { + "message": "Speed up this transaction" + }, "status": { "message": "Status" }, @@ -1263,29 +1275,38 @@ "message": "transaction" }, "transactionConfirmed": { - "message": "Transaction confirmed on $2." + "message": "Transaction confirmed at $2." }, "transactionCreated": { - "message": "Transaction created with a value of $1 on $2." + "message": "Transaction created with a value of $1 at $2." }, "transactionWithNonce": { "message": "Transaction $1" }, "transactionDropped": { - "message": "Transaction dropped on $2." + "message": "Transaction dropped at $2." }, "transactionSubmitted": { - "message": "Transaction submitted on $2." + "message": "Transaction submitted with gas fee of $1 at $2." + }, + "transactionResubmitted": { + "message": "Transaction resubmitted with gas fee increased to $1 at $2" }, "transactionUpdated": { - "message": "Transaction updated on $2." + "message": "Transaction updated at $2." }, "transactionUpdatedGas": { - "message": "Transaction updated with a gas price of $1 on $2." + "message": "Transaction updated with a gas fee of $1 at $2." }, "transactionErrored": { "message": "Transaction encountered an error." }, + "transactionCancelAttempted": { + "message": "Transaction cancel attempted with gas fee of $1 at $2" + }, + "transactionCancelSuccess": { + "message": "Transaction successfully cancelled at $2" + }, "transactions": { "message": "transactions" }, @@ -1350,9 +1371,6 @@ "unknown": { "message": "Unknown" }, - "unknownFunction": { - "message": "Unknown Function" - }, "unknownNetwork": { "message": "Unknown Private Network" }, diff --git a/app/images/icons/cancelled.svg b/app/images/icons/cancelled.svg new file mode 100755 index 000000000..ae4846dde --- /dev/null +++ b/app/images/icons/cancelled.svg @@ -0,0 +1,3 @@ + + + diff --git a/app/images/icons/confirm.svg b/app/images/icons/confirm.svg new file mode 100644 index 000000000..3263bf03e --- /dev/null +++ b/app/images/icons/confirm.svg @@ -0,0 +1,3 @@ + + + diff --git a/app/images/icons/error.svg b/app/images/icons/error.svg new file mode 100644 index 000000000..bf5abf946 --- /dev/null +++ b/app/images/icons/error.svg @@ -0,0 +1,4 @@ + + + + diff --git a/app/images/icons/new.svg b/app/images/icons/new.svg new file mode 100755 index 000000000..f56c43e08 --- /dev/null +++ b/app/images/icons/new.svg @@ -0,0 +1,3 @@ + + + diff --git a/app/images/icons/retry.svg b/app/images/icons/retry.svg new file mode 100755 index 000000000..ddaa198ca --- /dev/null +++ b/app/images/icons/retry.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/app/images/icons/submitted.svg b/app/images/icons/submitted.svg new file mode 100755 index 000000000..b5ced8777 --- /dev/null +++ b/app/images/icons/submitted.svg @@ -0,0 +1,3 @@ + + + diff --git a/app/scripts/controllers/transactions/enums.js b/app/scripts/controllers/transactions/enums.js index be6f16e0d..d41400b9f 100644 --- a/app/scripts/controllers/transactions/enums.js +++ b/app/scripts/controllers/transactions/enums.js @@ -3,10 +3,12 @@ const TRANSACTION_TYPE_RETRY = 'retry' const TRANSACTION_TYPE_STANDARD = 'standard' const TRANSACTION_STATUS_APPROVED = 'approved' +const TRANSACTION_STATUS_CONFIRMED = 'confirmed' module.exports = { TRANSACTION_TYPE_CANCEL, TRANSACTION_TYPE_RETRY, TRANSACTION_TYPE_STANDARD, TRANSACTION_STATUS_APPROVED, + TRANSACTION_STATUS_CONFIRMED, } diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js index f530fbd22..2ce736beb 100644 --- a/app/scripts/controllers/transactions/index.js +++ b/app/scripts/controllers/transactions/index.js @@ -230,13 +230,15 @@ class TransactionController extends EventEmitter { to allow the user to resign the transaction with a higher gas values @param originalTxId {number} - the id of the txMeta that you want to attempt to retry + @param gasPrice {string=} - Optional gas price to be increased to use as the retry + transaction's gas price @return {txMeta} */ - async retryTransaction (originalTxId) { + async retryTransaction (originalTxId, gasPrice) { const originalTxMeta = this.txStateManager.getTx(originalTxId) const { txParams } = originalTxMeta - const lastGasPrice = originalTxMeta.txParams.gasPrice + const lastGasPrice = gasPrice || 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 diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index d382b1ad0..c7e9cfcc7 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -1144,8 +1144,8 @@ module.exports = class MetamaskController extends EventEmitter { * @param {string} txId - The ID of the transaction to speed up. * @param {Function} cb - The callback function called with a full state update. */ - async retryTransaction (txId, cb) { - await this.txController.retryTransaction(txId) + async retryTransaction (txId, gasPrice, cb) { + await this.txController.retryTransaction(txId, gasPrice) const state = await this.getState() return state } @@ -1158,9 +1158,13 @@ module.exports = class MetamaskController extends EventEmitter { * @returns {object} MetaMask state */ async createCancelTransaction (originalTxId, customGasPrice, cb) { - await this.txController.createCancelTransaction(originalTxId, customGasPrice) - const state = await this.getState() - return state + try { + await this.txController.createCancelTransaction(originalTxId, customGasPrice) + const state = await this.getState() + return state + } catch (error) { + throw error + } } async createSpeedUpTransaction (originalTxId, customGasPrice, cb) { -- cgit v1.2.3