Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group transactions by nonce #5886

Merged
merged 1 commit into from
Dec 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 27 additions & 9 deletions app/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
},
Expand Down Expand Up @@ -185,6 +188,9 @@
"cancellationGasFee": {
"message": "Cancellation Gas Fee"
},
"cancelled": {
"message": "Cancelled"
},
"cancelN": {
"message": "Cancel all $1 transactions"
},
Expand Down Expand Up @@ -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"
},
Expand Down Expand Up @@ -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"
},
Expand Down Expand Up @@ -1350,9 +1371,6 @@
"unknown": {
"message": "Unknown"
},
"unknownFunction": {
"message": "Unknown Function"
},
"unknownNetwork": {
"message": "Unknown Private Network"
},
Expand Down
3 changes: 3 additions & 0 deletions app/images/icons/cancelled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/images/icons/confirm.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions app/images/icons/error.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/images/icons/new.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions app/images/icons/retry.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/images/icons/submitted.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions app/scripts/controllers/transactions/enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
6 changes: 4 additions & 2 deletions app/scripts/controllers/transactions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 9 additions & 5 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions test/integration/lib/confirm-sig-requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ async function runConfirmSigRequestsTest (assert, done) {

const pendingRequestItem = $.find('.transaction-list-item .transaction-list-item__grid')

if (pendingRequestItem[0]) {
pendingRequestItem[0].click()
if (pendingRequestItem[2]) {
pendingRequestItem[2].click()
}

await timeout(1000)
Expand Down
26 changes: 8 additions & 18 deletions test/integration/lib/tx-list-items.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,25 @@ async function runTxListItemsTest (assert, done) {
metamaskLogo[0].click()

const txListItems = await queryAsync($, '.transaction-list-item')
assert.equal(txListItems.length, 8, 'all tx list items are rendered')
assert.equal(txListItems.length, 7, 'all tx list items are rendered')

const retryTxGrid = await findAsync($(txListItems[2]), '.transaction-list-item__grid')
retryTxGrid[0].click()
const retryTxDetails = await findAsync($, '.transaction-list-item-details')
const headerButtons = await findAsync($(retryTxDetails[0]), '.transaction-list-item-details__header-button')
assert.equal(headerButtons[0].textContent, 'speed up')

const approvedTx = txListItems[2]
const approvedTx = txListItems[0]
const approvedTxRenderedStatus = await findAsync($(approvedTx), '.transaction-list-item__status')
assert.equal(approvedTxRenderedStatus[0].textContent, 'pending', 'approvedTx has correct label')

const unapprovedMsg = txListItems[0]
const unapprovedMsg = txListItems[1]
const unapprovedMsgDescription = await findAsync($(unapprovedMsg), '.transaction-list-item__action')
assert.equal(unapprovedMsgDescription[0].textContent, 'Signature Request', 'unapprovedMsg has correct description')

const failedTx = txListItems[4]
const failedTxRenderedStatus = await findAsync($(failedTx), '.transaction-list-item__status')
assert.equal(failedTxRenderedStatus[0].textContent, 'Failed', 'failedTx has correct label')

const shapeShiftTx = txListItems[5]
const shapeShiftTx = txListItems[4]
const shapeShiftTxStatus = await findAsync($(shapeShiftTx), '.flex-column div:eq(1)')
assert.equal(shapeShiftTxStatus[0].textContent, 'No deposits received', 'shapeShiftTx has correct status')

const rejectedTx = txListItems[5]
const rejectedTxRenderedStatus = await findAsync($(rejectedTx), '.transaction-list-item__status')
assert.equal(rejectedTxRenderedStatus[0].textContent, 'Rejected', 'rejectedTx has correct label')

const confirmedTokenTx = txListItems[6]
const confirmedTokenTxAddress = await findAsync($(confirmedTokenTx), '.transaction-list-item__status')
assert.equal(confirmedTokenTxAddress[0].textContent, 'Confirmed', 'confirmedTokenTx has correct address')

const rejectedTx = txListItems[7]
const rejectedTxRenderedStatus = await findAsync($(rejectedTx), '.transaction-list-item__status')
assert.equal(rejectedTxRenderedStatus[0].textContent, 'Rejected', 'rejectedTx has correct label')
}
Loading