mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
expand transaction constants coverage (#9790)
* expand transaction constants coverage * touchups * dont import inside of e2e * Update app/scripts/controllers/transactions/tx-state-manager.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Update test/unit/app/controllers/transactions/tx-controller-test.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> Co-authored-by: Mark Stacey <markjstacey@gmail.com>
This commit is contained in:
parent
f30d261e69
commit
a49a4a066c
@ -5,6 +5,10 @@ import createId from '../lib/random-id'
|
|||||||
import { bnToHex } from '../lib/util'
|
import { bnToHex } from '../lib/util'
|
||||||
import fetchWithTimeout from '../lib/fetch-with-timeout'
|
import fetchWithTimeout from '../lib/fetch-with-timeout'
|
||||||
|
|
||||||
|
import {
|
||||||
|
TRANSACTION_CATEGORIES,
|
||||||
|
TRANSACTION_STATUSES,
|
||||||
|
} from '../../../shared/constants/transaction'
|
||||||
import {
|
import {
|
||||||
CHAIN_ID_TO_NETWORK_ID_MAP,
|
CHAIN_ID_TO_NETWORK_ID_MAP,
|
||||||
CHAIN_ID_TO_TYPE_MAP,
|
CHAIN_ID_TO_TYPE_MAP,
|
||||||
@ -275,7 +279,10 @@ export default class IncomingTransactionsController {
|
|||||||
|
|
||||||
_normalizeTxFromEtherscan(txMeta, chainId) {
|
_normalizeTxFromEtherscan(txMeta, chainId) {
|
||||||
const time = parseInt(txMeta.timeStamp, 10) * 1000
|
const time = parseInt(txMeta.timeStamp, 10) * 1000
|
||||||
const status = txMeta.isError === '0' ? 'confirmed' : 'failed'
|
const status =
|
||||||
|
txMeta.isError === '0'
|
||||||
|
? TRANSACTION_STATUSES.CONFIRMED
|
||||||
|
: TRANSACTION_STATUSES.FAILED
|
||||||
return {
|
return {
|
||||||
blockNumber: txMeta.blockNumber,
|
blockNumber: txMeta.blockNumber,
|
||||||
id: createId(),
|
id: createId(),
|
||||||
@ -291,7 +298,7 @@ export default class IncomingTransactionsController {
|
|||||||
value: bnToHex(new BN(txMeta.value)),
|
value: bnToHex(new BN(txMeta.value)),
|
||||||
},
|
},
|
||||||
hash: txMeta.hash,
|
hash: txMeta.hash,
|
||||||
transactionCategory: 'incoming',
|
transactionCategory: TRANSACTION_CATEGORIES.INCOMING,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,9 +183,9 @@ export default class TransactionController extends EventEmitter {
|
|||||||
`${initialTxMeta.id}:finished`,
|
`${initialTxMeta.id}:finished`,
|
||||||
(finishedTxMeta) => {
|
(finishedTxMeta) => {
|
||||||
switch (finishedTxMeta.status) {
|
switch (finishedTxMeta.status) {
|
||||||
case 'submitted':
|
case TRANSACTION_STATUSES.SUBMITTED:
|
||||||
return resolve(finishedTxMeta.hash)
|
return resolve(finishedTxMeta.hash)
|
||||||
case 'rejected':
|
case TRANSACTION_STATUSES.REJECTED:
|
||||||
return reject(
|
return reject(
|
||||||
cleanErrorStack(
|
cleanErrorStack(
|
||||||
ethErrors.provider.userRejectedRequest(
|
ethErrors.provider.userRejectedRequest(
|
||||||
@ -193,7 +193,7 @@ export default class TransactionController extends EventEmitter {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
case 'failed':
|
case TRANSACTION_STATUSES.FAILED:
|
||||||
return reject(
|
return reject(
|
||||||
cleanErrorStack(
|
cleanErrorStack(
|
||||||
ethErrors.rpc.internal(finishedTxMeta.err.message),
|
ethErrors.rpc.internal(finishedTxMeta.err.message),
|
||||||
@ -724,7 +724,7 @@ export default class TransactionController extends EventEmitter {
|
|||||||
_onBootCleanUp() {
|
_onBootCleanUp() {
|
||||||
this.txStateManager
|
this.txStateManager
|
||||||
.getFilteredTxList({
|
.getFilteredTxList({
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
loadingDefaults: true,
|
loadingDefaults: true,
|
||||||
})
|
})
|
||||||
.forEach((tx) => {
|
.forEach((tx) => {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { isValidAddress } from 'ethereumjs-util'
|
import { isValidAddress } from 'ethereumjs-util'
|
||||||
import { addHexPrefix } from '../../../lib/util'
|
import { addHexPrefix } from '../../../lib/util'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../../../shared/constants/transaction'
|
||||||
|
|
||||||
const normalizers = {
|
const normalizers = {
|
||||||
from: (from) => addHexPrefix(from),
|
from: (from) => addHexPrefix(from),
|
||||||
@ -93,9 +94,9 @@ export function validateRecipient(txParams) {
|
|||||||
*/
|
*/
|
||||||
export function getFinalStates() {
|
export function getFinalStates() {
|
||||||
return [
|
return [
|
||||||
'rejected', // the user has responded no!
|
TRANSACTION_STATUSES.REJECTED, // the user has responded no!
|
||||||
'confirmed', // the tx has been included in a block.
|
TRANSACTION_STATUSES.CONFIRMED, // the tx has been included in a block.
|
||||||
'failed', // the tx failed for some reason, included on tx data.
|
TRANSACTION_STATUSES.FAILED, // the tx failed for some reason, included on tx data.
|
||||||
'dropped', // the tx nonce was already used
|
TRANSACTION_STATUSES.DROPPED, // the tx nonce was already used
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import EventEmitter from 'safe-event-emitter'
|
import EventEmitter from 'safe-event-emitter'
|
||||||
import log from 'loglevel'
|
import log from 'loglevel'
|
||||||
import EthQuery from 'ethjs-query'
|
import EthQuery from 'ethjs-query'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../../shared/constants/transaction'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
@ -168,7 +169,7 @@ export default class PendingTransactionTracker extends EventEmitter {
|
|||||||
const txId = txMeta.id
|
const txId = txMeta.id
|
||||||
|
|
||||||
// Only check submitted txs
|
// Only check submitted txs
|
||||||
if (txMeta.status !== 'submitted') {
|
if (txMeta.status !== TRANSACTION_STATUSES.SUBMITTED) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ import EventEmitter from 'safe-event-emitter'
|
|||||||
import ObservableStore from 'obs-store'
|
import ObservableStore from 'obs-store'
|
||||||
import log from 'loglevel'
|
import log from 'loglevel'
|
||||||
import createId from '../../lib/random-id'
|
import createId from '../../lib/random-id'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../../shared/constants/transaction'
|
||||||
import {
|
import {
|
||||||
generateHistoryEntry,
|
generateHistoryEntry,
|
||||||
replayHistory,
|
replayHistory,
|
||||||
@ -10,26 +11,20 @@ import {
|
|||||||
import { getFinalStates, normalizeTxParams } from './lib/util'
|
import { getFinalStates, normalizeTxParams } from './lib/util'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
TransactionStateManager is responsible for the state of a transaction and
|
* TransactionStatuses reimported from the shared transaction constants file
|
||||||
storing the transaction
|
* @typedef {import('../../../../shared/constants/transaction').TransactionStatuses} TransactionStatuses
|
||||||
it also has some convenience methods for finding subsets of transactions
|
*/
|
||||||
*
|
|
||||||
*STATUS METHODS
|
/**
|
||||||
<br>statuses:
|
* TransactionStateManager is responsible for the state of a transaction and
|
||||||
<br> - `'unapproved'` the user has not responded
|
* storing the transaction. It also has some convenience methods for finding
|
||||||
<br> - `'rejected'` the user has responded no!
|
* subsets of transactions.
|
||||||
<br> - `'approved'` the user has approved the tx
|
* @param {Object} opts
|
||||||
<br> - `'signed'` the tx is signed
|
* @param {Object} [opts.initState={ transactions: [] }] initial transactions list with the key transaction {array}
|
||||||
<br> - `'submitted'` the tx is sent to a server
|
* @param {number} [opts.txHistoryLimit] limit for how many finished
|
||||||
<br> - `'confirmed'` the tx has been included in a block.
|
* transactions can hang around in state
|
||||||
<br> - `'failed'` the tx failed for some reason, included on tx data.
|
* @param {function} opts.getNetwork return network number
|
||||||
<br> - `'dropped'` the tx nonce was already used
|
* @class
|
||||||
@param {Object} opts
|
|
||||||
@param {Object} [opts.initState={ transactions: [] }] initial transactions list with the key transaction {array}
|
|
||||||
@param {number} [opts.txHistoryLimit] limit for how many finished
|
|
||||||
transactions can hang around in state
|
|
||||||
@param {function} opts.getNetwork return network number
|
|
||||||
@class
|
|
||||||
*/
|
*/
|
||||||
export default class TransactionStateManager extends EventEmitter {
|
export default class TransactionStateManager extends EventEmitter {
|
||||||
constructor({ initState, txHistoryLimit, getNetwork }) {
|
constructor({ initState, txHistoryLimit, getNetwork }) {
|
||||||
@ -41,8 +36,8 @@ export default class TransactionStateManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param {Object} opts - the object to use when overwriting defaults
|
* @param {Object} opts - the object to use when overwriting defaults
|
||||||
@returns {txMeta} - the default txMeta object
|
* @returns {txMeta} - the default txMeta object
|
||||||
*/
|
*/
|
||||||
generateTxMeta(opts) {
|
generateTxMeta(opts) {
|
||||||
const netId = this.getNetwork()
|
const netId = this.getNetwork()
|
||||||
@ -52,7 +47,7 @@ export default class TransactionStateManager extends EventEmitter {
|
|||||||
return {
|
return {
|
||||||
id: createId(),
|
id: createId(),
|
||||||
time: new Date().getTime(),
|
time: new Date().getTime(),
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: netId,
|
metamaskNetworkId: netId,
|
||||||
loadingDefaults: true,
|
loadingDefaults: true,
|
||||||
...opts,
|
...opts,
|
||||||
@ -96,17 +91,20 @@ export default class TransactionStateManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@returns {array} - of all the txMetas in store
|
* @returns {array} - of all the txMetas in store
|
||||||
*/
|
*/
|
||||||
getFullTxList() {
|
getFullTxList() {
|
||||||
return this.store.getState().transactions
|
return this.store.getState().transactions
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@returns {array} - the tx list whose status is unapproved
|
* @returns {array} - the tx list with unapproved status
|
||||||
*/
|
*/
|
||||||
getUnapprovedTxList() {
|
getUnapprovedTxList() {
|
||||||
const txList = this.getTxsByMetaData('status', 'unapproved')
|
const txList = this.getTxsByMetaData(
|
||||||
|
'status',
|
||||||
|
TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
|
)
|
||||||
return txList.reduce((result, tx) => {
|
return txList.reduce((result, tx) => {
|
||||||
result[tx.id] = tx
|
result[tx.id] = tx
|
||||||
return result
|
return result
|
||||||
@ -114,12 +112,12 @@ export default class TransactionStateManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param [address] {string} - hex prefixed address to sort the txMetas for [optional]
|
* @param [address] {string} - hex prefixed address to sort the txMetas for [optional]
|
||||||
@returns {array} - the tx list whose status is approved if no address is provide
|
* @returns {array} - the tx list with approved status if no address is provide
|
||||||
returns all txMetas who's status is approved for the current network
|
* returns all txMetas with approved statuses for the current network
|
||||||
*/
|
*/
|
||||||
getApprovedTransactions(address) {
|
getApprovedTransactions(address) {
|
||||||
const opts = { status: 'approved' }
|
const opts = { status: TRANSACTION_STATUSES.APPROVED }
|
||||||
if (address) {
|
if (address) {
|
||||||
opts.from = address
|
opts.from = address
|
||||||
}
|
}
|
||||||
@ -127,12 +125,12 @@ export default class TransactionStateManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param [address] {string} - hex prefixed address to sort the txMetas for [optional]
|
* @param [address] {string} - hex prefixed address to sort the txMetas for [optional]
|
||||||
@returns {array} - the tx list whose status is submitted if no address is provide
|
* @returns {array} - the tx list submitted status if no address is provide
|
||||||
returns all txMetas who's status is submitted for the current network
|
* returns all txMetas with submitted statuses for the current network
|
||||||
*/
|
*/
|
||||||
getPendingTransactions(address) {
|
getPendingTransactions(address) {
|
||||||
const opts = { status: 'submitted' }
|
const opts = { status: TRANSACTION_STATUSES.SUBMITTED }
|
||||||
if (address) {
|
if (address) {
|
||||||
opts.from = address
|
opts.from = address
|
||||||
}
|
}
|
||||||
@ -145,7 +143,7 @@ export default class TransactionStateManager extends EventEmitter {
|
|||||||
returns all txMetas who's status is confirmed for the current network
|
returns all txMetas who's status is confirmed for the current network
|
||||||
*/
|
*/
|
||||||
getConfirmedTransactions(address) {
|
getConfirmedTransactions(address) {
|
||||||
const opts = { status: 'confirmed' }
|
const opts = { status: TRANSACTION_STATUSES.CONFIRMED }
|
||||||
if (address) {
|
if (address) {
|
||||||
opts.from = address
|
opts.from = address
|
||||||
}
|
}
|
||||||
@ -153,13 +151,13 @@ export default class TransactionStateManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Adds the txMeta to the list of transactions in the store.
|
* Adds the txMeta to the list of transactions in the store.
|
||||||
if the list is over txHistoryLimit it will remove a transaction that
|
* if the list is over txHistoryLimit it will remove a transaction that
|
||||||
is in its final state
|
* is in its final state.
|
||||||
it will also add the key `history` to the txMeta with the snap shot of the original
|
* it will also add the key `history` to the txMeta with the snap shot of
|
||||||
object
|
* the original object
|
||||||
@param {Object} txMeta
|
* @param {Object} txMeta
|
||||||
@returns {Object} - the txMeta
|
* @returns {Object} - the txMeta
|
||||||
*/
|
*/
|
||||||
addTx(txMeta) {
|
addTx(txMeta) {
|
||||||
// normalize and validate txParams if present
|
// normalize and validate txParams if present
|
||||||
@ -208,9 +206,9 @@ export default class TransactionStateManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param {number} txId
|
* @param {number} txId
|
||||||
@returns {Object} - the txMeta who matches the given id if none found
|
* @returns {Object} - the txMeta who matches the given id if none found
|
||||||
for the network returns undefined
|
* for the network returns undefined
|
||||||
*/
|
*/
|
||||||
getTx(txId) {
|
getTx(txId) {
|
||||||
const txMeta = this.getTxsByMetaData('id', txId)[0]
|
const txMeta = this.getTxsByMetaData('id', txId)[0]
|
||||||
@ -218,9 +216,9 @@ export default class TransactionStateManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
updates the txMeta in the list and adds a history entry
|
* updates the txMeta in the list and adds a history entry
|
||||||
@param {Object} txMeta - the txMeta to update
|
* @param {Object} txMeta - the txMeta to update
|
||||||
@param {string} [note] - a note about the update for history
|
* @param {string} [note] - a note about the update for history
|
||||||
*/
|
*/
|
||||||
updateTx(txMeta, note) {
|
updateTx(txMeta, note) {
|
||||||
// normalize and validate txParams if present
|
// normalize and validate txParams if present
|
||||||
@ -247,10 +245,10 @@ export default class TransactionStateManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
merges txParams obj onto txMeta.txParams
|
* merges txParams obj onto txMeta.txParams use extend to ensure
|
||||||
use extend to ensure that all fields are filled
|
* that all fields are filled
|
||||||
@param {number} txId - the id of the txMeta
|
* @param {number} txId - the id of the txMeta
|
||||||
@param {Object} txParams - the updated txParams
|
* @param {Object} txParams - the updated txParams
|
||||||
*/
|
*/
|
||||||
updateTxParams(txId, txParams) {
|
updateTxParams(txId, txParams) {
|
||||||
const txMeta = this.getTx(txId)
|
const txMeta = this.getTx(txId)
|
||||||
@ -273,8 +271,8 @@ export default class TransactionStateManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
validates txParams members by type
|
* validates txParams members by type
|
||||||
@param {Object} txParams - txParams to validate
|
* @param {Object} txParams - txParams to validate
|
||||||
*/
|
*/
|
||||||
validateTxParams(txParams) {
|
validateTxParams(txParams) {
|
||||||
Object.keys(txParams).forEach((key) => {
|
Object.keys(txParams).forEach((key) => {
|
||||||
@ -336,12 +334,11 @@ export default class TransactionStateManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param {string} key - the key to check
|
||||||
@param {string} key - the key to check
|
* @param value - the value your looking for can also be a function that returns a bool
|
||||||
@param value - the value your looking for can also be a function that returns a bool
|
* @param [txList=this.getTxList()] {array} - the list to search. default is the txList
|
||||||
@param [txList=this.getTxList()] {array} - the list to search. default is the txList
|
* from txStateManager#getTxList
|
||||||
from txStateManager#getTxList
|
* @returns {array} - a list of txMetas who matches the search params
|
||||||
@returns {array} - a list of txMetas who matches the search params
|
|
||||||
*/
|
*/
|
||||||
getTxsByMetaData(key, value, txList = this.getTxList()) {
|
getTxsByMetaData(key, value, txList = this.getTxList()) {
|
||||||
const filter = typeof value === 'function' ? value : (v) => v === value
|
const filter = typeof value === 'function' ? value : (v) => v === value
|
||||||
@ -357,8 +354,8 @@ export default class TransactionStateManager extends EventEmitter {
|
|||||||
// get::set status
|
// get::set status
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param {number} txId - the txMeta Id
|
* @param {number} txId - the txMeta Id
|
||||||
@returns {string} - the status of the tx.
|
* @returns {string} - the status of the tx.
|
||||||
*/
|
*/
|
||||||
getTxStatus(txId) {
|
getTxStatus(txId) {
|
||||||
const txMeta = this.getTx(txId)
|
const txMeta = this.getTx(txId)
|
||||||
@ -366,8 +363,8 @@ export default class TransactionStateManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
should update the status of the tx to 'rejected'.
|
* Update the status of the tx to 'rejected'.
|
||||||
@param {number} txId - the txMeta Id
|
* @param {number} txId - the txMeta Id
|
||||||
*/
|
*/
|
||||||
setTxStatusRejected(txId) {
|
setTxStatusRejected(txId) {
|
||||||
this._setTxStatus(txId, 'rejected')
|
this._setTxStatus(txId, 'rejected')
|
||||||
@ -375,62 +372,61 @@ export default class TransactionStateManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
should update the status of the tx to 'unapproved'.
|
* Update the status of the tx to 'unapproved'.
|
||||||
@param {number} txId - the txMeta Id
|
* @param {number} txId - the txMeta Id
|
||||||
*/
|
*/
|
||||||
setTxStatusUnapproved(txId) {
|
setTxStatusUnapproved(txId) {
|
||||||
this._setTxStatus(txId, 'unapproved')
|
this._setTxStatus(txId, TRANSACTION_STATUSES.UNAPPROVED)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
should update the status of the tx to 'approved'.
|
* Update the status of the tx to 'approved'.
|
||||||
@param {number} txId - the txMeta Id
|
* @param {number} txId - the txMeta Id
|
||||||
*/
|
*/
|
||||||
setTxStatusApproved(txId) {
|
setTxStatusApproved(txId) {
|
||||||
this._setTxStatus(txId, 'approved')
|
this._setTxStatus(txId, TRANSACTION_STATUSES.APPROVED)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
should update the status of the tx to 'signed'.
|
* Update the status of the tx to 'signed'.
|
||||||
@param {number} txId - the txMeta Id
|
* @param {number} txId - the txMeta Id
|
||||||
*/
|
*/
|
||||||
setTxStatusSigned(txId) {
|
setTxStatusSigned(txId) {
|
||||||
this._setTxStatus(txId, 'signed')
|
this._setTxStatus(txId, TRANSACTION_STATUSES.SIGNED)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
should update the status of the tx to 'submitted'.
|
* Update the status of the tx to 'submitted' and add a time stamp
|
||||||
and add a time stamp for when it was called
|
* for when it was called
|
||||||
@param {number} txId - the txMeta Id
|
* @param {number} txId - the txMeta Id
|
||||||
*/
|
*/
|
||||||
setTxStatusSubmitted(txId) {
|
setTxStatusSubmitted(txId) {
|
||||||
const txMeta = this.getTx(txId)
|
const txMeta = this.getTx(txId)
|
||||||
txMeta.submittedTime = new Date().getTime()
|
txMeta.submittedTime = new Date().getTime()
|
||||||
this.updateTx(txMeta, 'txStateManager - add submitted time stamp')
|
this.updateTx(txMeta, 'txStateManager - add submitted time stamp')
|
||||||
this._setTxStatus(txId, 'submitted')
|
this._setTxStatus(txId, TRANSACTION_STATUSES.SUBMITTED)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
should update the status of the tx to 'confirmed'.
|
* Update the status of the tx to 'confirmed'.
|
||||||
@param {number} txId - the txMeta Id
|
* @param {number} txId - the txMeta Id
|
||||||
*/
|
*/
|
||||||
setTxStatusConfirmed(txId) {
|
setTxStatusConfirmed(txId) {
|
||||||
this._setTxStatus(txId, 'confirmed')
|
this._setTxStatus(txId, TRANSACTION_STATUSES.CONFIRMED)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
should update the status of the tx to 'dropped'.
|
* Update the status of the tx to 'dropped'.
|
||||||
@param {number} txId - the txMeta Id
|
* @param {number} txId - the txMeta Id
|
||||||
*/
|
*/
|
||||||
setTxStatusDropped(txId) {
|
setTxStatusDropped(txId) {
|
||||||
this._setTxStatus(txId, 'dropped')
|
this._setTxStatus(txId, TRANSACTION_STATUSES.DROPPED)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
should update the status of the tx to 'failed'.
|
* Updates the status of the tx to 'failed' and put the error on the txMeta
|
||||||
and put the error on the txMeta
|
* @param {number} txId - the txMeta Id
|
||||||
@param {number} txId - the txMeta Id
|
* @param {erroObject} err - error object
|
||||||
@param {erroObject} err - error object
|
|
||||||
*/
|
*/
|
||||||
setTxStatusFailed(txId, err) {
|
setTxStatusFailed(txId, err) {
|
||||||
const error = err || new Error('Internal metamask failure')
|
const error = err || new Error('Internal metamask failure')
|
||||||
@ -442,13 +438,14 @@ export default class TransactionStateManager extends EventEmitter {
|
|||||||
stack: error.stack,
|
stack: error.stack,
|
||||||
}
|
}
|
||||||
this.updateTx(txMeta, 'transactions:tx-state-manager#fail - add error')
|
this.updateTx(txMeta, 'transactions:tx-state-manager#fail - add error')
|
||||||
this._setTxStatus(txId, 'failed')
|
this._setTxStatus(txId, TRANSACTION_STATUSES.FAILED)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Removes transaction from the given address for the current network
|
* Removes transaction from the given address for the current network
|
||||||
from the txList
|
* from the txList
|
||||||
@param {string} address - hex string of the from address on the txParams to remove
|
* @param {string} address - hex string of the from address on the txParams
|
||||||
|
* to remove
|
||||||
*/
|
*/
|
||||||
wipeTransactions(address) {
|
wipeTransactions(address) {
|
||||||
// network only tx
|
// network only tx
|
||||||
@ -467,27 +464,17 @@ export default class TransactionStateManager extends EventEmitter {
|
|||||||
// Update state
|
// Update state
|
||||||
this._saveTxList(otherAccountTxs)
|
this._saveTxList(otherAccountTxs)
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// PRIVATE METHODS
|
// PRIVATE METHODS
|
||||||
//
|
//
|
||||||
|
|
||||||
// STATUS METHODS
|
|
||||||
// statuses:
|
|
||||||
// - `'unapproved'` the user has not responded
|
|
||||||
// - `'rejected'` the user has responded no!
|
|
||||||
// - `'approved'` the user has approved the tx
|
|
||||||
// - `'signed'` the tx is signed
|
|
||||||
// - `'submitted'` the tx is sent to a server
|
|
||||||
// - `'confirmed'` the tx has been included in a block.
|
|
||||||
// - `'failed'` the tx failed for some reason, included on tx data.
|
|
||||||
// - `'dropped'` the tx nonce was already used
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param {number} txId - the txMeta Id
|
* @param {number} txId - the txMeta Id
|
||||||
@param {string} status - the status to set on the txMeta
|
* @param {TransactionStatuses[keyof TransactionStatuses]} status - the status to set on the txMeta
|
||||||
@emits tx:status-update - passes txId and status
|
* @emits tx:status-update - passes txId and status
|
||||||
@emits ${txMeta.id}:finished - if it is a finished state. Passes the txMeta
|
* @emits ${txMeta.id}:finished - if it is a finished state. Passes the txMeta
|
||||||
@emits update:badge
|
* @emits update:badge
|
||||||
*/
|
*/
|
||||||
_setTxStatus(txId, status) {
|
_setTxStatus(txId, status) {
|
||||||
const txMeta = this.getTx(txId)
|
const txMeta = this.getTx(txId)
|
||||||
@ -501,7 +488,13 @@ export default class TransactionStateManager extends EventEmitter {
|
|||||||
this.updateTx(txMeta, `txStateManager: setting status to ${status}`)
|
this.updateTx(txMeta, `txStateManager: setting status to ${status}`)
|
||||||
this.emit(`${txMeta.id}:${status}`, txId)
|
this.emit(`${txMeta.id}:${status}`, txId)
|
||||||
this.emit(`tx:status-update`, txId, status)
|
this.emit(`tx:status-update`, txId, status)
|
||||||
if (['submitted', 'rejected', 'failed'].includes(status)) {
|
if (
|
||||||
|
[
|
||||||
|
TRANSACTION_STATUSES.SUBMITTED,
|
||||||
|
TRANSACTION_STATUSES.REJECTED,
|
||||||
|
TRANSACTION_STATUSES.FAILED,
|
||||||
|
].includes(status)
|
||||||
|
) {
|
||||||
this.emit(`${txMeta.id}:finished`, txMeta)
|
this.emit(`${txMeta.id}:finished`, txMeta)
|
||||||
}
|
}
|
||||||
this.emit('update:badge')
|
this.emit('update:badge')
|
||||||
@ -511,10 +504,9 @@ export default class TransactionStateManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Saves the new/updated txList.
|
* Saves the new/updated txList. Intended only for internal use
|
||||||
@param {array} transactions - the list of transactions to save
|
* @param {array} transactions - the list of transactions to save
|
||||||
*/
|
*/
|
||||||
// Function is intended only for internal use
|
|
||||||
_saveTxList(transactions) {
|
_saveTxList(transactions) {
|
||||||
this.store.updateState({ transactions })
|
this.store.updateState({ transactions })
|
||||||
}
|
}
|
||||||
@ -527,11 +519,10 @@ export default class TransactionStateManager extends EventEmitter {
|
|||||||
/**
|
/**
|
||||||
* Filters out the unapproved transactions
|
* Filters out the unapproved transactions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
clearUnapprovedTxs() {
|
clearUnapprovedTxs() {
|
||||||
const transactions = this.getFullTxList()
|
const transactions = this.getFullTxList()
|
||||||
const nonUnapprovedTxs = transactions.filter(
|
const nonUnapprovedTxs = transactions.filter(
|
||||||
(tx) => tx.status !== 'unapproved',
|
(tx) => tx.status !== TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
)
|
)
|
||||||
this._saveTxList(nonUnapprovedTxs)
|
this._saveTxList(nonUnapprovedTxs)
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import {
|
|||||||
} from '@metamask/controllers'
|
} from '@metamask/controllers'
|
||||||
import { getTrackMetaMetricsEvent } from '../../shared/modules/metametrics'
|
import { getTrackMetaMetricsEvent } from '../../shared/modules/metametrics'
|
||||||
import { getBackgroundMetaMetricState } from '../../ui/app/selectors'
|
import { getBackgroundMetaMetricState } from '../../ui/app/selectors'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../shared/constants/transaction'
|
||||||
import ComposableObservableStore from './lib/ComposableObservableStore'
|
import ComposableObservableStore from './lib/ComposableObservableStore'
|
||||||
import AccountTracker from './lib/account-tracker'
|
import AccountTracker from './lib/account-tracker'
|
||||||
import createLoggerMiddleware from './lib/createLoggerMiddleware'
|
import createLoggerMiddleware from './lib/createLoggerMiddleware'
|
||||||
@ -304,7 +305,10 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
this.txController.on('newUnapprovedTx', () => opts.showUnapprovedTx())
|
this.txController.on('newUnapprovedTx', () => opts.showUnapprovedTx())
|
||||||
|
|
||||||
this.txController.on(`tx:status-update`, async (txId, status) => {
|
this.txController.on(`tx:status-update`, async (txId, status) => {
|
||||||
if (status === 'confirmed' || status === 'failed') {
|
if (
|
||||||
|
status === TRANSACTION_STATUSES.CONFIRMED ||
|
||||||
|
status === TRANSACTION_STATUSES.FAILED
|
||||||
|
) {
|
||||||
const txMeta = this.txController.txStateManager.getTx(txId)
|
const txMeta = this.txController.txStateManager.getTx(txId)
|
||||||
this.platform.showTransactionNotification(txMeta)
|
this.platform.showTransactionNotification(txMeta)
|
||||||
|
|
||||||
@ -441,7 +445,10 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
processEncryptionPublicKey: this.newRequestEncryptionPublicKey.bind(this),
|
processEncryptionPublicKey: this.newRequestEncryptionPublicKey.bind(this),
|
||||||
getPendingNonce: this.getPendingNonce.bind(this),
|
getPendingNonce: this.getPendingNonce.bind(this),
|
||||||
getPendingTransactionByHash: (hash) =>
|
getPendingTransactionByHash: (hash) =>
|
||||||
this.txController.getFilteredTxList({ hash, status: 'submitted' })[0],
|
this.txController.getFilteredTxList({
|
||||||
|
hash,
|
||||||
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
|
})[0],
|
||||||
}
|
}
|
||||||
const providerProxy = this.networkController.initializeProvider(
|
const providerProxy = this.networkController.initializeProvider(
|
||||||
providerOpts,
|
providerOpts,
|
||||||
|
@ -6,6 +6,7 @@ to a 'failed' stated
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { cloneDeep } from 'lodash'
|
import { cloneDeep } from 'lodash'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction'
|
||||||
|
|
||||||
const version = 15
|
const version = 15
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ function transformState(state) {
|
|||||||
if (!txMeta.err) {
|
if (!txMeta.err) {
|
||||||
return txMeta
|
return txMeta
|
||||||
} else if (txMeta.err.message === 'Gave up submitting tx.') {
|
} else if (txMeta.err.message === 'Gave up submitting tx.') {
|
||||||
txMeta.status = 'failed'
|
txMeta.status = TRANSACTION_STATUSES.FAILED
|
||||||
}
|
}
|
||||||
return txMeta
|
return txMeta
|
||||||
})
|
})
|
||||||
|
@ -6,6 +6,7 @@ to a 'failed' stated
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { cloneDeep } from 'lodash'
|
import { cloneDeep } from 'lodash'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction'
|
||||||
|
|
||||||
const version = 16
|
const version = 16
|
||||||
|
|
||||||
@ -39,7 +40,7 @@ function transformState(state) {
|
|||||||
if (
|
if (
|
||||||
txMeta.err === 'transaction with the same hash was already imported.'
|
txMeta.err === 'transaction with the same hash was already imported.'
|
||||||
) {
|
) {
|
||||||
txMeta.status = 'submitted'
|
txMeta.status = TRANSACTION_STATUSES.SUBMITTED
|
||||||
delete txMeta.err
|
delete txMeta.err
|
||||||
}
|
}
|
||||||
return txMeta
|
return txMeta
|
||||||
|
@ -5,6 +5,7 @@ This migration sets transactions who were retried and marked as failed to submit
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { cloneDeep } from 'lodash'
|
import { cloneDeep } from 'lodash'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction'
|
||||||
|
|
||||||
const version = 17
|
const version = 17
|
||||||
|
|
||||||
@ -31,11 +32,11 @@ function transformState(state) {
|
|||||||
if (TransactionController && TransactionController.transactions) {
|
if (TransactionController && TransactionController.transactions) {
|
||||||
const { transactions } = newState.TransactionController
|
const { transactions } = newState.TransactionController
|
||||||
newState.TransactionController.transactions = transactions.map((txMeta) => {
|
newState.TransactionController.transactions = transactions.map((txMeta) => {
|
||||||
if (!txMeta.status === 'failed') {
|
if (!txMeta.status === TRANSACTION_STATUSES.FAILED) {
|
||||||
return txMeta
|
return txMeta
|
||||||
}
|
}
|
||||||
if (txMeta.retryCount > 0 && txMeta.retryCount < 2) {
|
if (txMeta.retryCount > 0 && txMeta.retryCount < 2) {
|
||||||
txMeta.status = 'submitted'
|
txMeta.status = TRANSACTION_STATUSES.SUBMITTED
|
||||||
delete txMeta.err
|
delete txMeta.err
|
||||||
}
|
}
|
||||||
return txMeta
|
return txMeta
|
||||||
|
@ -6,6 +6,7 @@ whos nonce is too high
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { cloneDeep } from 'lodash'
|
import { cloneDeep } from 'lodash'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction'
|
||||||
|
|
||||||
const version = 19
|
const version = 19
|
||||||
|
|
||||||
@ -34,12 +35,12 @@ function transformState(state) {
|
|||||||
|
|
||||||
newState.TransactionController.transactions = transactions.map(
|
newState.TransactionController.transactions = transactions.map(
|
||||||
(txMeta, _, txList) => {
|
(txMeta, _, txList) => {
|
||||||
if (txMeta.status !== 'submitted') {
|
if (txMeta.status !== TRANSACTION_STATUSES.SUBMITTED) {
|
||||||
return txMeta
|
return txMeta
|
||||||
}
|
}
|
||||||
|
|
||||||
const confirmedTxs = txList
|
const confirmedTxs = txList
|
||||||
.filter((tx) => tx.status === 'confirmed')
|
.filter((tx) => tx.status === TRANSACTION_STATUSES.CONFIRMED)
|
||||||
.filter((tx) => tx.txParams.from === txMeta.txParams.from)
|
.filter((tx) => tx.txParams.from === txMeta.txParams.from)
|
||||||
.filter(
|
.filter(
|
||||||
(tx) => tx.metamaskNetworkId.from === txMeta.metamaskNetworkId.from,
|
(tx) => tx.metamaskNetworkId.from === txMeta.metamaskNetworkId.from,
|
||||||
@ -47,7 +48,7 @@ function transformState(state) {
|
|||||||
const highestConfirmedNonce = getHighestNonce(confirmedTxs)
|
const highestConfirmedNonce = getHighestNonce(confirmedTxs)
|
||||||
|
|
||||||
const pendingTxs = txList
|
const pendingTxs = txList
|
||||||
.filter((tx) => tx.status === 'submitted')
|
.filter((tx) => tx.status === TRANSACTION_STATUSES.SUBMITTED)
|
||||||
.filter((tx) => tx.txParams.from === txMeta.txParams.from)
|
.filter((tx) => tx.txParams.from === txMeta.txParams.from)
|
||||||
.filter(
|
.filter(
|
||||||
(tx) => tx.metamaskNetworkId.from === txMeta.metamaskNetworkId.from,
|
(tx) => tx.metamaskNetworkId.from === txMeta.metamaskNetworkId.from,
|
||||||
@ -60,7 +61,7 @@ function transformState(state) {
|
|||||||
const maxNonce = Math.max(highestContinuousNonce, highestConfirmedNonce)
|
const maxNonce = Math.max(highestContinuousNonce, highestConfirmedNonce)
|
||||||
|
|
||||||
if (parseInt(txMeta.txParams.nonce, 16) > maxNonce + 1) {
|
if (parseInt(txMeta.txParams.nonce, 16) > maxNonce + 1) {
|
||||||
txMeta.status = 'failed'
|
txMeta.status = TRANSACTION_STATUSES.FAILED
|
||||||
txMeta.err = {
|
txMeta.err = {
|
||||||
message: 'nonce too high',
|
message: 'nonce too high',
|
||||||
note: 'migration 019 custom error',
|
note: 'migration 019 custom error',
|
||||||
|
@ -5,6 +5,7 @@ This migration adds submittedTime to the txMeta if it is not their
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { cloneDeep } from 'lodash'
|
import { cloneDeep } from 'lodash'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction'
|
||||||
|
|
||||||
const version = 22
|
const version = 22
|
||||||
|
|
||||||
@ -32,7 +33,10 @@ function transformState(state) {
|
|||||||
const { transactions } = newState.TransactionController
|
const { transactions } = newState.TransactionController
|
||||||
|
|
||||||
newState.TransactionController.transactions = transactions.map((txMeta) => {
|
newState.TransactionController.transactions = transactions.map((txMeta) => {
|
||||||
if (txMeta.status !== 'submitted' || txMeta.submittedTime) {
|
if (
|
||||||
|
txMeta.status !== TRANSACTION_STATUSES.SUBMITTED ||
|
||||||
|
txMeta.submittedTime
|
||||||
|
) {
|
||||||
return txMeta
|
return txMeta
|
||||||
}
|
}
|
||||||
txMeta.submittedTime = new Date().getTime()
|
txMeta.submittedTime = new Date().getTime()
|
||||||
|
@ -5,6 +5,7 @@ This migration removes transactions that are no longer usefull down to 40 total
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { cloneDeep } from 'lodash'
|
import { cloneDeep } from 'lodash'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction'
|
||||||
|
|
||||||
const version = 23
|
const version = 23
|
||||||
|
|
||||||
@ -41,10 +42,10 @@ function transformState(state) {
|
|||||||
while (reverseTxList.length > 40 && stripping) {
|
while (reverseTxList.length > 40 && stripping) {
|
||||||
const txIndex = reverseTxList.findIndex((txMeta) => {
|
const txIndex = reverseTxList.findIndex((txMeta) => {
|
||||||
return (
|
return (
|
||||||
txMeta.status === 'failed' ||
|
txMeta.status === TRANSACTION_STATUSES.FAILED ||
|
||||||
txMeta.status === 'rejected' ||
|
txMeta.status === TRANSACTION_STATUSES.REJECTED ||
|
||||||
txMeta.status === 'confirmed' ||
|
txMeta.status === TRANSACTION_STATUSES.CONFIRMED ||
|
||||||
txMeta.status === 'dropped'
|
txMeta.status === TRANSACTION_STATUSES.DROPPED
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
if (txIndex < 0) {
|
if (txIndex < 0) {
|
||||||
|
@ -6,6 +6,7 @@ all unapproved transactions
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { cloneDeep } from 'lodash'
|
import { cloneDeep } from 'lodash'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction'
|
||||||
|
|
||||||
const version = 24
|
const version = 24
|
||||||
|
|
||||||
@ -31,7 +32,7 @@ function transformState(state) {
|
|||||||
newState.TransactionController.transactions = transactions.map(
|
newState.TransactionController.transactions = transactions.map(
|
||||||
(txMeta, _) => {
|
(txMeta, _) => {
|
||||||
if (
|
if (
|
||||||
txMeta.status === 'unapproved' &&
|
txMeta.status === TRANSACTION_STATUSES.UNAPPROVED &&
|
||||||
txMeta.txParams &&
|
txMeta.txParams &&
|
||||||
txMeta.txParams.from
|
txMeta.txParams.from
|
||||||
) {
|
) {
|
||||||
|
@ -6,6 +6,7 @@ normalizes txParams on unconfirmed txs
|
|||||||
*/
|
*/
|
||||||
import { cloneDeep } from 'lodash'
|
import { cloneDeep } from 'lodash'
|
||||||
import { addHexPrefix } from '../lib/util'
|
import { addHexPrefix } from '../lib/util'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction'
|
||||||
|
|
||||||
const version = 25
|
const version = 25
|
||||||
|
|
||||||
@ -30,7 +31,7 @@ function transformState(state) {
|
|||||||
const { transactions } = newState.TransactionController
|
const { transactions } = newState.TransactionController
|
||||||
newState.TransactionController.transactions = transactions.map(
|
newState.TransactionController.transactions = transactions.map(
|
||||||
(txMeta) => {
|
(txMeta) => {
|
||||||
if (txMeta.status !== 'unapproved') {
|
if (txMeta.status !== TRANSACTION_STATUSES.UNAPPROVED) {
|
||||||
return txMeta
|
return txMeta
|
||||||
}
|
}
|
||||||
txMeta.txParams = normalizeTxParams(txMeta.txParams)
|
txMeta.txParams = normalizeTxParams(txMeta.txParams)
|
||||||
|
@ -5,6 +5,7 @@ normalizes txParams on unconfirmed txs
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
import { cloneDeep } from 'lodash'
|
import { cloneDeep } from 'lodash'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction'
|
||||||
|
|
||||||
const version = 27
|
const version = 27
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ function transformState(state) {
|
|||||||
if (newState.TransactionController.transactions) {
|
if (newState.TransactionController.transactions) {
|
||||||
const { transactions } = newState.TransactionController
|
const { transactions } = newState.TransactionController
|
||||||
newState.TransactionController.transactions = transactions.filter(
|
newState.TransactionController.transactions = transactions.filter(
|
||||||
(txMeta) => txMeta.status !== 'rejected',
|
(txMeta) => txMeta.status !== TRANSACTION_STATUSES.REJECTED,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
// next version number
|
// next version number
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction'
|
||||||
import failTxsThat from './fail-tx'
|
import failTxsThat from './fail-tx'
|
||||||
|
|
||||||
const version = 29
|
const version = 29
|
||||||
@ -22,7 +23,7 @@ export default {
|
|||||||
version,
|
version,
|
||||||
'Stuck in approved state for too long.',
|
'Stuck in approved state for too long.',
|
||||||
(txMeta) => {
|
(txMeta) => {
|
||||||
const isApproved = txMeta.status === 'approved'
|
const isApproved = txMeta.status === TRANSACTION_STATUSES.APPROVED
|
||||||
const createdTime = txMeta.submittedTime
|
const createdTime = txMeta.submittedTime
|
||||||
const now = Date.now()
|
const now = Date.now()
|
||||||
return isApproved && now - createdTime > unacceptableDelay
|
return isApproved && now - createdTime > unacceptableDelay
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { cloneDeep } from 'lodash'
|
import { cloneDeep } from 'lodash'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction'
|
||||||
|
|
||||||
export default function failTxsThat(version, reason, condition) {
|
export default function failTxsThat(version, reason, condition) {
|
||||||
return function (originalVersionedData) {
|
return function (originalVersionedData) {
|
||||||
@ -26,7 +27,7 @@ function transformState(state, condition, reason) {
|
|||||||
return txMeta
|
return txMeta
|
||||||
}
|
}
|
||||||
|
|
||||||
txMeta.status = 'failed'
|
txMeta.status = TRANSACTION_STATUSES.FAILED
|
||||||
txMeta.err = {
|
txMeta.err = {
|
||||||
message: reason,
|
message: reason,
|
||||||
note: `Tx automatically failed by migration because ${reason}`,
|
note: `Tx automatically failed by migration because ${reason}`,
|
||||||
|
@ -2,6 +2,7 @@ import extension from 'extensionizer'
|
|||||||
import { createExplorerLink as explorerLink } from '@metamask/etherscan-link'
|
import { createExplorerLink as explorerLink } from '@metamask/etherscan-link'
|
||||||
import { getEnvironmentType, checkForError } from '../lib/util'
|
import { getEnvironmentType, checkForError } from '../lib/util'
|
||||||
import { ENVIRONMENT_TYPE_BACKGROUND } from '../lib/enums'
|
import { ENVIRONMENT_TYPE_BACKGROUND } from '../lib/enums'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction'
|
||||||
|
|
||||||
export default class ExtensionPlatform {
|
export default class ExtensionPlatform {
|
||||||
//
|
//
|
||||||
@ -112,7 +113,7 @@ export default class ExtensionPlatform {
|
|||||||
showTransactionNotification(txMeta) {
|
showTransactionNotification(txMeta) {
|
||||||
const { status, txReceipt: { status: receiptStatus } = {} } = txMeta
|
const { status, txReceipt: { status: receiptStatus } = {} } = txMeta
|
||||||
|
|
||||||
if (status === 'confirmed') {
|
if (status === TRANSACTION_STATUSES.CONFIRMED) {
|
||||||
// There was an on-chain failure
|
// There was an on-chain failure
|
||||||
receiptStatus === '0x0'
|
receiptStatus === '0x0'
|
||||||
? this._showFailedTransaction(
|
? this._showFailedTransaction(
|
||||||
@ -120,7 +121,7 @@ export default class ExtensionPlatform {
|
|||||||
'Transaction encountered an error.',
|
'Transaction encountered an error.',
|
||||||
)
|
)
|
||||||
: this._showConfirmedTransaction(txMeta)
|
: this._showConfirmedTransaction(txMeta)
|
||||||
} else if (status === 'failed') {
|
} else if (status === TRANSACTION_STATUSES.FAILED) {
|
||||||
this._showFailedTransaction(txMeta)
|
this._showFailedTransaction(txMeta)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ export const TRANSACTION_TYPES = {
|
|||||||
* @property {'rejected'} REJECTED - The user has rejected the transaction in the
|
* @property {'rejected'} REJECTED - The user has rejected the transaction in the
|
||||||
* MetaMask UI
|
* MetaMask UI
|
||||||
* @property {'signed'} SIGNED - The transaction has been signed
|
* @property {'signed'} SIGNED - The transaction has been signed
|
||||||
* @property {'submitted'} SIGNED - The transaction has been submitted to network
|
* @property {'submitted'} SUBMITTED - The transaction has been submitted to network
|
||||||
* @property {'failed'} FAILED - The transaction has failed for some reason
|
* @property {'failed'} FAILED - The transaction has failed for some reason
|
||||||
* @property {'dropped'} DROPPED - The transaction was dropped due to a tx with same
|
* @property {'dropped'} DROPPED - The transaction was dropped due to a tx with same
|
||||||
* nonce being accepted
|
* nonce being accepted
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import { snapshotFromTxMeta } from '../../app/scripts/controllers/transactions/lib/tx-state-history-helpers'
|
import { snapshotFromTxMeta } from '../../app/scripts/controllers/transactions/lib/tx-state-history-helpers'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../shared/constants/transaction'
|
||||||
|
|
||||||
export default function createTxMeta(partialMeta) {
|
export default function createTxMeta(partialMeta) {
|
||||||
const txMeta = {
|
const txMeta = {
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
...partialMeta,
|
...partialMeta,
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,10 @@ import {
|
|||||||
ROPSTEN_CHAIN_ID,
|
ROPSTEN_CHAIN_ID,
|
||||||
ROPSTEN_NETWORK_ID,
|
ROPSTEN_NETWORK_ID,
|
||||||
} from '../../../../app/scripts/controllers/network/enums'
|
} from '../../../../app/scripts/controllers/network/enums'
|
||||||
|
import {
|
||||||
|
TRANSACTION_CATEGORIES,
|
||||||
|
TRANSACTION_STATUSES,
|
||||||
|
} from '../../../../shared/constants/transaction'
|
||||||
|
|
||||||
const IncomingTransactionsController = proxyquire(
|
const IncomingTransactionsController = proxyquire(
|
||||||
'../../../../app/scripts/controllers/incoming-transactions',
|
'../../../../app/scripts/controllers/incoming-transactions',
|
||||||
@ -266,9 +270,9 @@ describe('IncomingTransactionsController', function () {
|
|||||||
blockNumber: '10',
|
blockNumber: '10',
|
||||||
hash: '0xfake',
|
hash: '0xfake',
|
||||||
metamaskNetworkId: '3',
|
metamaskNetworkId: '3',
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
time: 16000000000000000,
|
time: 16000000000000000,
|
||||||
transactionCategory: 'incoming',
|
transactionCategory: TRANSACTION_CATEGORIES.INCOMING,
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0xfake',
|
from: '0xfake',
|
||||||
gas: '0x0',
|
gas: '0x0',
|
||||||
@ -609,9 +613,9 @@ describe('IncomingTransactionsController', function () {
|
|||||||
blockNumber: '10',
|
blockNumber: '10',
|
||||||
hash: '0xfake',
|
hash: '0xfake',
|
||||||
metamaskNetworkId: '3',
|
metamaskNetworkId: '3',
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
time: 16000000000000000,
|
time: 16000000000000000,
|
||||||
transactionCategory: 'incoming',
|
transactionCategory: TRANSACTION_CATEGORIES.INCOMING,
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0xfake',
|
from: '0xfake',
|
||||||
gas: '0x0',
|
gas: '0x0',
|
||||||
@ -763,9 +767,9 @@ describe('IncomingTransactionsController', function () {
|
|||||||
blockNumber: '10',
|
blockNumber: '10',
|
||||||
hash: '0xfake',
|
hash: '0xfake',
|
||||||
metamaskNetworkId: '3',
|
metamaskNetworkId: '3',
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
time: 16000000000000000,
|
time: 16000000000000000,
|
||||||
transactionCategory: 'incoming',
|
transactionCategory: TRANSACTION_CATEGORIES.INCOMING,
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0xfake',
|
from: '0xfake',
|
||||||
gas: '0x0',
|
gas: '0x0',
|
||||||
@ -1340,7 +1344,7 @@ describe('IncomingTransactionsController', function () {
|
|||||||
blockNumber: 333,
|
blockNumber: 333,
|
||||||
id: 54321,
|
id: 54321,
|
||||||
metamaskNetworkId: ROPSTEN_NETWORK_ID,
|
metamaskNetworkId: ROPSTEN_NETWORK_ID,
|
||||||
status: 'failed',
|
status: TRANSACTION_STATUSES.FAILED,
|
||||||
time: 4444000,
|
time: 4444000,
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0xa',
|
from: '0xa',
|
||||||
@ -1351,7 +1355,7 @@ describe('IncomingTransactionsController', function () {
|
|||||||
value: '0xf',
|
value: '0xf',
|
||||||
},
|
},
|
||||||
hash: '0xg',
|
hash: '0xg',
|
||||||
transactionCategory: 'incoming',
|
transactionCategory: TRANSACTION_CATEGORIES.INCOMING,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -1385,7 +1389,7 @@ describe('IncomingTransactionsController', function () {
|
|||||||
blockNumber: 333,
|
blockNumber: 333,
|
||||||
id: 54321,
|
id: 54321,
|
||||||
metamaskNetworkId: ROPSTEN_NETWORK_ID,
|
metamaskNetworkId: ROPSTEN_NETWORK_ID,
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
time: 4444000,
|
time: 4444000,
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0xa',
|
from: '0xa',
|
||||||
@ -1396,7 +1400,7 @@ describe('IncomingTransactionsController', function () {
|
|||||||
value: '0xf',
|
value: '0xf',
|
||||||
},
|
},
|
||||||
hash: '0xg',
|
hash: '0xg',
|
||||||
transactionCategory: 'incoming',
|
transactionCategory: TRANSACTION_CATEGORIES.INCOMING,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -9,6 +9,7 @@ import proxyquire from 'proxyquire'
|
|||||||
import firstTimeState from '../../localhostState'
|
import firstTimeState from '../../localhostState'
|
||||||
import createTxMeta from '../../../lib/createTxMeta'
|
import createTxMeta from '../../../lib/createTxMeta'
|
||||||
import { addHexPrefix } from '../../../../app/scripts/lib/util'
|
import { addHexPrefix } from '../../../../app/scripts/lib/util'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../../shared/constants/transaction'
|
||||||
|
|
||||||
const threeBoxSpies = {
|
const threeBoxSpies = {
|
||||||
init: sinon.stub(),
|
init: sinon.stub(),
|
||||||
@ -708,20 +709,24 @@ describe('MetaMaskController', function () {
|
|||||||
metamaskController.txController.txStateManager._saveTxList([
|
metamaskController.txController.txStateManager._saveTxList([
|
||||||
createTxMeta({
|
createTxMeta({
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: { from: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc' },
|
txParams: { from: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc' },
|
||||||
}),
|
}),
|
||||||
createTxMeta({
|
createTxMeta({
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: { from: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc' },
|
txParams: { from: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc' },
|
||||||
}),
|
}),
|
||||||
createTxMeta({ id: 2, status: 'rejected', metamaskNetworkId: '32' }),
|
createTxMeta({
|
||||||
|
id: 2,
|
||||||
|
status: TRANSACTION_STATUSES.REJECTED,
|
||||||
|
metamaskNetworkId: '32',
|
||||||
|
}),
|
||||||
createTxMeta({
|
createTxMeta({
|
||||||
id: 3,
|
id: 3,
|
||||||
status: 'submitted',
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: { from: '0xB09d8505E1F4EF1CeA089D47094f5DD3464083d4' },
|
txParams: { from: '0xB09d8505E1F4EF1CeA089D47094f5DD3464083d4' },
|
||||||
}),
|
}),
|
||||||
@ -847,7 +852,7 @@ describe('MetaMaskController', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('sets the status to unapproved', function () {
|
it('sets the status to unapproved', function () {
|
||||||
assert.equal(metamaskMsgs[msgId].status, 'unapproved')
|
assert.equal(metamaskMsgs[msgId].status, TRANSACTION_STATUSES.UNAPPROVED)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets the type to eth_sign', function () {
|
it('sets the type to eth_sign', function () {
|
||||||
@ -857,7 +862,7 @@ describe('MetaMaskController', function () {
|
|||||||
it('rejects the message', function () {
|
it('rejects the message', function () {
|
||||||
const msgIdInt = parseInt(msgId, 10)
|
const msgIdInt = parseInt(msgId, 10)
|
||||||
metamaskController.cancelMessage(msgIdInt, noop)
|
metamaskController.cancelMessage(msgIdInt, noop)
|
||||||
assert.equal(messages[0].status, 'rejected')
|
assert.equal(messages[0].status, TRANSACTION_STATUSES.REJECTED)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('errors when signing a message', async function () {
|
it('errors when signing a message', async function () {
|
||||||
@ -924,7 +929,10 @@ describe('MetaMaskController', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('sets the status to unapproved', function () {
|
it('sets the status to unapproved', function () {
|
||||||
assert.equal(metamaskPersonalMsgs[msgId].status, 'unapproved')
|
assert.equal(
|
||||||
|
metamaskPersonalMsgs[msgId].status,
|
||||||
|
TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets the type to personal_sign', function () {
|
it('sets the type to personal_sign', function () {
|
||||||
@ -934,14 +942,17 @@ describe('MetaMaskController', function () {
|
|||||||
it('rejects the message', function () {
|
it('rejects the message', function () {
|
||||||
const msgIdInt = parseInt(msgId, 10)
|
const msgIdInt = parseInt(msgId, 10)
|
||||||
metamaskController.cancelPersonalMessage(msgIdInt, noop)
|
metamaskController.cancelPersonalMessage(msgIdInt, noop)
|
||||||
assert.equal(personalMessages[0].status, 'rejected')
|
assert.equal(personalMessages[0].status, TRANSACTION_STATUSES.REJECTED)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('errors when signing a message', async function () {
|
it('errors when signing a message', async function () {
|
||||||
await metamaskController.signPersonalMessage(
|
await metamaskController.signPersonalMessage(
|
||||||
personalMessages[0].msgParams,
|
personalMessages[0].msgParams,
|
||||||
)
|
)
|
||||||
assert.equal(metamaskPersonalMsgs[msgId].status, 'signed')
|
assert.equal(
|
||||||
|
metamaskPersonalMsgs[msgId].status,
|
||||||
|
TRANSACTION_STATUSES.SIGNED,
|
||||||
|
)
|
||||||
assert.equal(
|
assert.equal(
|
||||||
metamaskPersonalMsgs[msgId].rawSig,
|
metamaskPersonalMsgs[msgId].rawSig,
|
||||||
'0x6a1b65e2b8ed53cf398a769fad24738f9fbe29841fe6854e226953542c4b6a173473cb152b6b1ae5f06d601d45dd699a129b0a8ca84e78b423031db5baa734741b',
|
'0x6a1b65e2b8ed53cf398a769fad24738f9fbe29841fe6854e226953542c4b6a173473cb152b6b1ae5f06d601d45dd699a129b0a8ca84e78b423031db5baa734741b',
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
import {
|
||||||
|
TRANSACTION_CATEGORIES,
|
||||||
|
TRANSACTION_STATUSES,
|
||||||
|
TRANSACTION_TYPES,
|
||||||
|
} from '../../../../../shared/constants/transaction'
|
||||||
|
|
||||||
export const txMetaStub = {
|
export const txMetaStub = {
|
||||||
firstRetryBlockNumber: '0x51a402',
|
firstRetryBlockNumber: '0x51a402',
|
||||||
hash: '0x2cc5a25744486f7383edebbf32003e5a66e18135799593d6b5cdd2bb43674f09',
|
hash: '0x2cc5a25744486f7383edebbf32003e5a66e18135799593d6b5cdd2bb43674f09',
|
||||||
@ -6,9 +12,9 @@ export const txMetaStub = {
|
|||||||
id: 405984854664302,
|
id: 405984854664302,
|
||||||
loadingDefaults: true,
|
loadingDefaults: true,
|
||||||
metamaskNetworkId: '4',
|
metamaskNetworkId: '4',
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
time: 1572395156620,
|
time: 1572395156620,
|
||||||
transactionCategory: 'sentEther',
|
transactionCategory: TRANSACTION_CATEGORIES.SENT_ETHER,
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0xf231d46dd78806e1dd93442cf33c7671f8538748',
|
from: '0xf231d46dd78806e1dd93442cf33c7671f8538748',
|
||||||
gas: '0x5208',
|
gas: '0x5208',
|
||||||
@ -16,7 +22,7 @@ export const txMetaStub = {
|
|||||||
to: '0xf231d46dd78806e1dd93442cf33c7671f8538748',
|
to: '0xf231d46dd78806e1dd93442cf33c7671f8538748',
|
||||||
value: '0x0',
|
value: '0x0',
|
||||||
},
|
},
|
||||||
type: 'standard',
|
type: TRANSACTION_TYPES.STANDARD,
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
@ -42,7 +48,7 @@ export const txMetaStub = {
|
|||||||
op: 'replace',
|
op: 'replace',
|
||||||
path: '/status',
|
path: '/status',
|
||||||
timestamp: 1572395158240,
|
timestamp: 1572395158240,
|
||||||
value: 'approved',
|
value: TRANSACTION_STATUSES.APPROVED,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -108,7 +114,7 @@ export const txMetaStub = {
|
|||||||
op: 'replace',
|
op: 'replace',
|
||||||
path: '/status',
|
path: '/status',
|
||||||
timestamp: 1572395158281,
|
timestamp: 1572395158281,
|
||||||
value: 'signed',
|
value: TRANSACTION_STATUSES.SIGNED,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
op: 'add',
|
op: 'add',
|
||||||
@ -143,7 +149,7 @@ export const txMetaStub = {
|
|||||||
op: 'replace',
|
op: 'replace',
|
||||||
path: '/status',
|
path: '/status',
|
||||||
timestamp: 1572395158576,
|
timestamp: 1572395158576,
|
||||||
value: 'submitted',
|
value: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -187,10 +193,10 @@ export const txMetaStub = {
|
|||||||
rawTx:
|
rawTx:
|
||||||
'0xf86204831e848082520894f231d46dd78806e1dd93442cf33c7671f853874880802ca05f973e540f2d3c2f06d3725a626b75247593cb36477187ae07ecfe0a4db3cf57a00259b52ee8c58baaa385fb05c3f96116e58de89bcc165cb3bfdfc708672fed8a',
|
'0xf86204831e848082520894f231d46dd78806e1dd93442cf33c7671f853874880802ca05f973e540f2d3c2f06d3725a626b75247593cb36477187ae07ecfe0a4db3cf57a00259b52ee8c58baaa385fb05c3f96116e58de89bcc165cb3bfdfc708672fed8a',
|
||||||
s: '0x0259b52ee8c58baaa385fb05c3f96116e58de89bcc165cb3bfdfc708672fed8a',
|
s: '0x0259b52ee8c58baaa385fb05c3f96116e58de89bcc165cb3bfdfc708672fed8a',
|
||||||
status: 'submitted',
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
submittedTime: 1572395158570,
|
submittedTime: 1572395158570,
|
||||||
time: 1572395156620,
|
time: 1572395156620,
|
||||||
transactionCategory: 'sentEther',
|
transactionCategory: TRANSACTION_CATEGORIES.SENT_ETHER,
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0xf231d46dd78806e1dd93442cf33c7671f8538748',
|
from: '0xf231d46dd78806e1dd93442cf33c7671f8538748',
|
||||||
gas: '0x5208',
|
gas: '0x5208',
|
||||||
@ -199,6 +205,6 @@ export const txMetaStub = {
|
|||||||
to: '0xf231d46dd78806e1dd93442cf33c7671f8538748',
|
to: '0xf231d46dd78806e1dd93442cf33c7671f8538748',
|
||||||
value: '0x0',
|
value: '0x0',
|
||||||
},
|
},
|
||||||
type: 'standard',
|
type: TRANSACTION_TYPES.STANDARD,
|
||||||
v: '0x2c',
|
v: '0x2c',
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import { strict as assert } from 'assert'
|
|||||||
import sinon from 'sinon'
|
import sinon from 'sinon'
|
||||||
import BN from 'bn.js'
|
import BN from 'bn.js'
|
||||||
import PendingTransactionTracker from '../../../../../app/scripts/controllers/transactions/pending-tx-tracker'
|
import PendingTransactionTracker from '../../../../../app/scripts/controllers/transactions/pending-tx-tracker'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../../../shared/constants/transaction'
|
||||||
|
|
||||||
describe('PendingTransactionTracker', function () {
|
describe('PendingTransactionTracker', function () {
|
||||||
describe('#resubmitPendingTxs', function () {
|
describe('#resubmitPendingTxs', function () {
|
||||||
@ -155,7 +156,7 @@ describe('PendingTransactionTracker', function () {
|
|||||||
id: 1,
|
id: 1,
|
||||||
hash:
|
hash:
|
||||||
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
|
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
|
||||||
status: 'signed',
|
status: TRANSACTION_STATUSES.SIGNED,
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
||||||
nonce: '0x1',
|
nonce: '0x1',
|
||||||
@ -213,7 +214,7 @@ describe('PendingTransactionTracker', function () {
|
|||||||
id: 1,
|
id: 1,
|
||||||
hash:
|
hash:
|
||||||
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
|
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
|
||||||
status: 'signed',
|
status: TRANSACTION_STATUSES.SIGNED,
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
||||||
nonce: '0x1',
|
nonce: '0x1',
|
||||||
@ -258,7 +259,7 @@ describe('PendingTransactionTracker', function () {
|
|||||||
id: 1,
|
id: 1,
|
||||||
hash:
|
hash:
|
||||||
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
|
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
|
||||||
status: 'signed',
|
status: TRANSACTION_STATUSES.SIGNED,
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
||||||
nonce: '0x1',
|
nonce: '0x1',
|
||||||
@ -305,7 +306,7 @@ describe('PendingTransactionTracker', function () {
|
|||||||
id: 1,
|
id: 1,
|
||||||
hash:
|
hash:
|
||||||
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
|
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
|
||||||
status: 'signed',
|
status: TRANSACTION_STATUSES.SIGNED,
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
||||||
nonce: '0x1',
|
nonce: '0x1',
|
||||||
@ -405,7 +406,7 @@ describe('PendingTransactionTracker', function () {
|
|||||||
id: 1,
|
id: 1,
|
||||||
hash:
|
hash:
|
||||||
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
|
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
|
||||||
status: 'submitted',
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
||||||
nonce: '0x1',
|
nonce: '0x1',
|
||||||
@ -438,7 +439,7 @@ describe('PendingTransactionTracker', function () {
|
|||||||
id: 1,
|
id: 1,
|
||||||
hash:
|
hash:
|
||||||
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
|
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
|
||||||
status: 'submitted',
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
||||||
nonce: '0x1',
|
nonce: '0x1',
|
||||||
@ -459,7 +460,7 @@ describe('PendingTransactionTracker', function () {
|
|||||||
id: 1,
|
id: 1,
|
||||||
hash:
|
hash:
|
||||||
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
|
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
||||||
nonce: '0x1',
|
nonce: '0x1',
|
||||||
@ -472,7 +473,7 @@ describe('PendingTransactionTracker', function () {
|
|||||||
id: 2,
|
id: 2,
|
||||||
hash:
|
hash:
|
||||||
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
|
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
||||||
nonce: '0x2',
|
nonce: '0x2',
|
||||||
@ -518,7 +519,7 @@ describe('PendingTransactionTracker', function () {
|
|||||||
id: 1,
|
id: 1,
|
||||||
hash:
|
hash:
|
||||||
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
|
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
||||||
nonce: '0x1',
|
nonce: '0x1',
|
||||||
@ -531,7 +532,7 @@ describe('PendingTransactionTracker', function () {
|
|||||||
id: 2,
|
id: 2,
|
||||||
hash:
|
hash:
|
||||||
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
|
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
||||||
nonce: '0x2',
|
nonce: '0x2',
|
||||||
@ -578,7 +579,7 @@ describe('PendingTransactionTracker', function () {
|
|||||||
id: 1,
|
id: 1,
|
||||||
hash:
|
hash:
|
||||||
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
|
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
|
||||||
status: 'submitted',
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
||||||
nonce: '0x1',
|
nonce: '0x1',
|
||||||
@ -647,7 +648,7 @@ describe('PendingTransactionTracker', function () {
|
|||||||
pendingTxTracker.once('tx:failed', listeners.failed)
|
pendingTxTracker.once('tx:failed', listeners.failed)
|
||||||
pendingTxTracker.once('tx:warning', listeners.warning)
|
pendingTxTracker.once('tx:warning', listeners.warning)
|
||||||
await pendingTxTracker._checkPendingTx({
|
await pendingTxTracker._checkPendingTx({
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
history: [{}],
|
history: [{}],
|
||||||
txParams: { nonce: '0x1' },
|
txParams: { nonce: '0x1' },
|
||||||
id: '456',
|
id: '456',
|
||||||
@ -688,7 +689,7 @@ describe('PendingTransactionTracker', function () {
|
|||||||
await pendingTxTracker._checkPendingTx({
|
await pendingTxTracker._checkPendingTx({
|
||||||
id: '2',
|
id: '2',
|
||||||
history: [{}],
|
history: [{}],
|
||||||
status: 'submitted',
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
txParams: { from: '0x1678a085c290ebd122dc42cba69373b5953b831d' },
|
txParams: { from: '0x1678a085c290ebd122dc42cba69373b5953b831d' },
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -707,7 +708,7 @@ describe('PendingTransactionTracker', function () {
|
|||||||
it("should emit 'tx:dropped' if another tx with the same nonce succeeds", async function () {
|
it("should emit 'tx:dropped' if another tx with the same nonce succeeds", async function () {
|
||||||
const txs = [
|
const txs = [
|
||||||
{
|
{
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
history: [{}],
|
history: [{}],
|
||||||
txParams: { nonce: '0x1' },
|
txParams: { nonce: '0x1' },
|
||||||
id: '456',
|
id: '456',
|
||||||
@ -715,7 +716,7 @@ describe('PendingTransactionTracker', function () {
|
|||||||
hash: '0xbad',
|
hash: '0xbad',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
status: 'submitted',
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
history: [{}],
|
history: [{}],
|
||||||
txParams: { nonce: '0x1' },
|
txParams: { nonce: '0x1' },
|
||||||
id: '123',
|
id: '123',
|
||||||
@ -763,7 +764,7 @@ describe('PendingTransactionTracker', function () {
|
|||||||
id: 1,
|
id: 1,
|
||||||
hash:
|
hash:
|
||||||
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
|
'0x0593ee121b92e10d63150ad08b4b8f9c7857d1bd160195ee648fb9a0f8d00eeb',
|
||||||
status: 'submitted',
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
from: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
||||||
nonce: '0x1',
|
nonce: '0x1',
|
||||||
|
@ -12,6 +12,7 @@ import {
|
|||||||
} from '../../../../stub/provider'
|
} from '../../../../stub/provider'
|
||||||
import {
|
import {
|
||||||
TRANSACTION_CATEGORIES,
|
TRANSACTION_CATEGORIES,
|
||||||
|
TRANSACTION_STATUSES,
|
||||||
TRANSACTION_TYPES,
|
TRANSACTION_TYPES,
|
||||||
} from '../../../../../shared/constants/transaction'
|
} from '../../../../../shared/constants/transaction'
|
||||||
|
|
||||||
@ -83,21 +84,21 @@ describe('Transaction Controller', function () {
|
|||||||
txController.txStateManager._saveTxList([
|
txController.txStateManager._saveTxList([
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
history: [{}],
|
history: [{}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
history: [{}],
|
history: [{}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 3,
|
id: 3,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
history: [{}],
|
history: [{}],
|
||||||
@ -113,21 +114,21 @@ describe('Transaction Controller', function () {
|
|||||||
txController.txStateManager._saveTxList([
|
txController.txStateManager._saveTxList([
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'submitted',
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
history: [{}],
|
history: [{}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
status: 'submitted',
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
history: [{}],
|
history: [{}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 3,
|
id: 3,
|
||||||
status: 'submitted',
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
history: [{}],
|
history: [{}],
|
||||||
@ -148,63 +149,63 @@ describe('Transaction Controller', function () {
|
|||||||
txController.txStateManager._saveTxList([
|
txController.txStateManager._saveTxList([
|
||||||
{
|
{
|
||||||
id: 0,
|
id: 0,
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams,
|
txParams,
|
||||||
history: [{}],
|
history: [{}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams,
|
txParams,
|
||||||
history: [{}],
|
history: [{}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams,
|
txParams,
|
||||||
history: [{}],
|
history: [{}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 3,
|
id: 3,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams,
|
txParams,
|
||||||
history: [{}],
|
history: [{}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 4,
|
id: 4,
|
||||||
status: 'rejected',
|
status: TRANSACTION_STATUSES.REJECTED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams,
|
txParams,
|
||||||
history: [{}],
|
history: [{}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 5,
|
id: 5,
|
||||||
status: 'approved',
|
status: TRANSACTION_STATUSES.APPROVED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams,
|
txParams,
|
||||||
history: [{}],
|
history: [{}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 6,
|
id: 6,
|
||||||
status: 'signed',
|
status: TRANSACTION_STATUSES.SIGNED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams,
|
txParams,
|
||||||
history: [{}],
|
history: [{}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 7,
|
id: 7,
|
||||||
status: 'submitted',
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams,
|
txParams,
|
||||||
history: [{}],
|
history: [{}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 8,
|
id: 8,
|
||||||
status: 'failed',
|
status: TRANSACTION_STATUSES.FAILED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams,
|
txParams,
|
||||||
history: [{}],
|
history: [{}],
|
||||||
@ -225,7 +226,7 @@ describe('Transaction Controller', function () {
|
|||||||
to: '0xc684832530fcbddae4b4230a47e991ddcec2831d',
|
to: '0xc684832530fcbddae4b4230a47e991ddcec2831d',
|
||||||
}
|
}
|
||||||
txMeta = {
|
txMeta = {
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
id: 1,
|
id: 1,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams,
|
txParams,
|
||||||
@ -350,7 +351,7 @@ describe('Transaction Controller', function () {
|
|||||||
txController.txStateManager._saveTxList([
|
txController.txStateManager._saveTxList([
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
history: [{}],
|
history: [{}],
|
||||||
@ -384,7 +385,7 @@ describe('Transaction Controller', function () {
|
|||||||
it('should emit updates', function (done) {
|
it('should emit updates', function (done) {
|
||||||
const txMeta = {
|
const txMeta = {
|
||||||
id: '1',
|
id: '1',
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
}
|
}
|
||||||
@ -419,7 +420,7 @@ describe('Transaction Controller', function () {
|
|||||||
const originalValue = '0x01'
|
const originalValue = '0x01'
|
||||||
const txMeta = {
|
const txMeta = {
|
||||||
id: '1',
|
id: '1',
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {
|
txParams: {
|
||||||
nonce: originalValue,
|
nonce: originalValue,
|
||||||
@ -454,7 +455,7 @@ describe('Transaction Controller', function () {
|
|||||||
assert.equal(result.hash, originalValue)
|
assert.equal(result.hash, originalValue)
|
||||||
assert.equal(
|
assert.equal(
|
||||||
result.status,
|
result.status,
|
||||||
'submitted',
|
TRANSACTION_STATUSES.SUBMITTED,
|
||||||
'should have reached the submitted status.',
|
'should have reached the submitted status.',
|
||||||
)
|
)
|
||||||
signStub.restore()
|
signStub.restore()
|
||||||
@ -467,7 +468,7 @@ describe('Transaction Controller', function () {
|
|||||||
txController.addTx(
|
txController.addTx(
|
||||||
{
|
{
|
||||||
id: '1',
|
id: '1',
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
},
|
},
|
||||||
@ -483,7 +484,7 @@ describe('Transaction Controller', function () {
|
|||||||
it('should update and approve transactions', async function () {
|
it('should update and approve transactions', async function () {
|
||||||
const txMeta = {
|
const txMeta = {
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
txParams: {
|
txParams: {
|
||||||
from: fromAccount.address,
|
from: fromAccount.address,
|
||||||
to: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
to: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
||||||
@ -496,7 +497,7 @@ describe('Transaction Controller', function () {
|
|||||||
txController.txStateManager.addTx(txMeta)
|
txController.txStateManager.addTx(txMeta)
|
||||||
const approvalPromise = txController.updateAndApproveTransaction(txMeta)
|
const approvalPromise = txController.updateAndApproveTransaction(txMeta)
|
||||||
const tx = txController.txStateManager.getTx(1)
|
const tx = txController.txStateManager.getTx(1)
|
||||||
assert.equal(tx.status, 'approved')
|
assert.equal(tx.status, TRANSACTION_STATUSES.APPROVED)
|
||||||
await approvalPromise
|
await approvalPromise
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -513,49 +514,49 @@ describe('Transaction Controller', function () {
|
|||||||
txController.txStateManager._saveTxList([
|
txController.txStateManager._saveTxList([
|
||||||
{
|
{
|
||||||
id: 0,
|
id: 0,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
history: [{}],
|
history: [{}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'rejected',
|
status: TRANSACTION_STATUSES.REJECTED,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
history: [{}],
|
history: [{}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
status: 'approved',
|
status: TRANSACTION_STATUSES.APPROVED,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
history: [{}],
|
history: [{}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 3,
|
id: 3,
|
||||||
status: 'signed',
|
status: TRANSACTION_STATUSES.SIGNED,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
history: [{}],
|
history: [{}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 4,
|
id: 4,
|
||||||
status: 'submitted',
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
history: [{}],
|
history: [{}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 5,
|
id: 5,
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
history: [{}],
|
history: [{}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 6,
|
id: 6,
|
||||||
status: 'failed',
|
status: TRANSACTION_STATUSES.FAILED,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
history: [{}],
|
history: [{}],
|
||||||
@ -564,7 +565,11 @@ describe('Transaction Controller', function () {
|
|||||||
|
|
||||||
txController.once('tx:status-update', (txId, status) => {
|
txController.once('tx:status-update', (txId, status) => {
|
||||||
try {
|
try {
|
||||||
assert.equal(status, 'rejected', 'status should e rejected')
|
assert.equal(
|
||||||
|
status,
|
||||||
|
TRANSACTION_STATUSES.REJECTED,
|
||||||
|
'status should be rejected',
|
||||||
|
)
|
||||||
assert.equal(txId, 0, 'id should e 0')
|
assert.equal(txId, 0, 'id should e 0')
|
||||||
done()
|
done()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -596,7 +601,7 @@ describe('Transaction Controller', function () {
|
|||||||
txController.txStateManager._saveTxList([
|
txController.txStateManager._saveTxList([
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'submitted',
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams,
|
txParams,
|
||||||
history: [{}],
|
history: [{}],
|
||||||
@ -659,7 +664,7 @@ describe('Transaction Controller', function () {
|
|||||||
'0x2a5523c6fa98b47b7d9b6c8320179785150b42a16bcff36b398c5062b65657e8'
|
'0x2a5523c6fa98b47b7d9b6c8320179785150b42a16bcff36b398c5062b65657e8'
|
||||||
txMeta = {
|
txMeta = {
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
}
|
}
|
||||||
@ -673,7 +678,7 @@ describe('Transaction Controller', function () {
|
|||||||
await txController.publishTransaction(txMeta.id, rawTx)
|
await txController.publishTransaction(txMeta.id, rawTx)
|
||||||
const publishedTx = txController.txStateManager.getTx(1)
|
const publishedTx = txController.txStateManager.getTx(1)
|
||||||
assert.equal(publishedTx.hash, hash)
|
assert.equal(publishedTx.hash, hash)
|
||||||
assert.equal(publishedTx.status, 'submitted')
|
assert.equal(publishedTx.status, TRANSACTION_STATUSES.SUBMITTED)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should ignore the error "Transaction Failed: known transaction" and be as usual', async function () {
|
it('should ignore the error "Transaction Failed: known transaction" and be as usual', async function () {
|
||||||
@ -689,7 +694,7 @@ describe('Transaction Controller', function () {
|
|||||||
publishedTx.hash,
|
publishedTx.hash,
|
||||||
'0x2cc5a25744486f7383edebbf32003e5a66e18135799593d6b5cdd2bb43674f09',
|
'0x2cc5a25744486f7383edebbf32003e5a66e18135799593d6b5cdd2bb43674f09',
|
||||||
)
|
)
|
||||||
assert.equal(publishedTx.status, 'submitted')
|
assert.equal(publishedTx.status, TRANSACTION_STATUSES.SUBMITTED)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -698,49 +703,49 @@ describe('Transaction Controller', function () {
|
|||||||
txController.txStateManager._saveTxList([
|
txController.txStateManager._saveTxList([
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
history: [{}],
|
history: [{}],
|
||||||
txParams: { nonce: '0x01' },
|
txParams: { nonce: '0x01' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
status: 'submitted',
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
history: [{}],
|
history: [{}],
|
||||||
txParams: { nonce: '0x01' },
|
txParams: { nonce: '0x01' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 3,
|
id: 3,
|
||||||
status: 'submitted',
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
history: [{}],
|
history: [{}],
|
||||||
txParams: { nonce: '0x01' },
|
txParams: { nonce: '0x01' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 4,
|
id: 4,
|
||||||
status: 'submitted',
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
history: [{}],
|
history: [{}],
|
||||||
txParams: { nonce: '0x01' },
|
txParams: { nonce: '0x01' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 5,
|
id: 5,
|
||||||
status: 'submitted',
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
history: [{}],
|
history: [{}],
|
||||||
txParams: { nonce: '0x01' },
|
txParams: { nonce: '0x01' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 6,
|
id: 6,
|
||||||
status: 'submitted',
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
history: [{}],
|
history: [{}],
|
||||||
txParams: { nonce: '0x01' },
|
txParams: { nonce: '0x01' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 7,
|
id: 7,
|
||||||
status: 'submitted',
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
history: [{}],
|
history: [{}],
|
||||||
txParams: { nonce: '0x01' },
|
txParams: { nonce: '0x01' },
|
||||||
@ -750,11 +755,11 @@ describe('Transaction Controller', function () {
|
|||||||
const confirmedTx = txController.txStateManager.getTx(1)
|
const confirmedTx = txController.txStateManager.getTx(1)
|
||||||
const droppedTxs = txController.txStateManager.getFilteredTxList({
|
const droppedTxs = txController.txStateManager.getFilteredTxList({
|
||||||
nonce: '0x01',
|
nonce: '0x01',
|
||||||
status: 'dropped',
|
status: TRANSACTION_STATUSES.DROPPED,
|
||||||
})
|
})
|
||||||
assert.equal(
|
assert.equal(
|
||||||
confirmedTx.status,
|
confirmedTx.status,
|
||||||
'confirmed',
|
TRANSACTION_STATUSES.CONFIRMED,
|
||||||
'the confirmedTx should remain confirmed',
|
'the confirmedTx should remain confirmed',
|
||||||
)
|
)
|
||||||
assert.equal(droppedTxs.length, 6, 'their should be 6 dropped txs')
|
assert.equal(droppedTxs.length, 6, 'their should be 6 dropped txs')
|
||||||
@ -914,48 +919,48 @@ describe('Transaction Controller', function () {
|
|||||||
txController.txStateManager._saveTxList([
|
txController.txStateManager._saveTxList([
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
status: 'rejected',
|
status: TRANSACTION_STATUSES.REJECTED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
history: [{}],
|
history: [{}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 3,
|
id: 3,
|
||||||
status: 'approved',
|
status: TRANSACTION_STATUSES.APPROVED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
history: [{}],
|
history: [{}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 4,
|
id: 4,
|
||||||
status: 'signed',
|
status: TRANSACTION_STATUSES.SIGNED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
history: [{}],
|
history: [{}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 5,
|
id: 5,
|
||||||
status: 'submitted',
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
history: [{}],
|
history: [{}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 6,
|
id: 6,
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
history: [{}],
|
history: [{}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 7,
|
id: 7,
|
||||||
status: 'failed',
|
status: TRANSACTION_STATUSES.FAILED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
history: [{}],
|
history: [{}],
|
||||||
@ -969,8 +974,14 @@ describe('Transaction Controller', function () {
|
|||||||
const states = txController.pendingTxTracker
|
const states = txController.pendingTxTracker
|
||||||
.getPendingTransactions()
|
.getPendingTransactions()
|
||||||
.map((tx) => tx.status)
|
.map((tx) => tx.status)
|
||||||
assert.ok(states.includes('approved'), 'includes approved')
|
assert.ok(
|
||||||
assert.ok(states.includes('submitted'), 'includes submitted')
|
states.includes(TRANSACTION_STATUSES.APPROVED),
|
||||||
|
'includes approved',
|
||||||
|
)
|
||||||
|
assert.ok(
|
||||||
|
states.includes(TRANSACTION_STATUSES.SUBMITTED),
|
||||||
|
'includes submitted',
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -2,6 +2,7 @@ import { strict as assert } from 'assert'
|
|||||||
import sinon from 'sinon'
|
import sinon from 'sinon'
|
||||||
import TxStateManager from '../../../../../app/scripts/controllers/transactions/tx-state-manager'
|
import TxStateManager from '../../../../../app/scripts/controllers/transactions/tx-state-manager'
|
||||||
import { snapshotFromTxMeta } from '../../../../../app/scripts/controllers/transactions/lib/tx-state-history-helpers'
|
import { snapshotFromTxMeta } from '../../../../../app/scripts/controllers/transactions/lib/tx-state-history-helpers'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../../../shared/constants/transaction'
|
||||||
|
|
||||||
const noop = () => true
|
const noop = () => true
|
||||||
|
|
||||||
@ -24,7 +25,7 @@ describe('TransactionStateManager', function () {
|
|||||||
it('sets the tx status to signed', function () {
|
it('sets the tx status to signed', function () {
|
||||||
const tx = {
|
const tx = {
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
}
|
}
|
||||||
@ -33,13 +34,13 @@ describe('TransactionStateManager', function () {
|
|||||||
const result = txStateManager.getTxList()
|
const result = txStateManager.getTxList()
|
||||||
assert.ok(Array.isArray(result))
|
assert.ok(Array.isArray(result))
|
||||||
assert.equal(result.length, 1)
|
assert.equal(result.length, 1)
|
||||||
assert.equal(result[0].status, 'signed')
|
assert.equal(result[0].status, TRANSACTION_STATUSES.SIGNED)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should emit a signed event to signal the execution of callback', function () {
|
it('should emit a signed event to signal the execution of callback', function () {
|
||||||
const tx = {
|
const tx = {
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
}
|
}
|
||||||
@ -60,7 +61,7 @@ describe('TransactionStateManager', function () {
|
|||||||
it('sets the tx status to rejected and removes it from history', function () {
|
it('sets the tx status to rejected and removes it from history', function () {
|
||||||
const tx = {
|
const tx = {
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
}
|
}
|
||||||
@ -74,7 +75,7 @@ describe('TransactionStateManager', function () {
|
|||||||
it('should emit a rejected event to signal the execution of callback', function () {
|
it('should emit a rejected event to signal the execution of callback', function () {
|
||||||
const tx = {
|
const tx = {
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
}
|
}
|
||||||
@ -116,7 +117,7 @@ describe('TransactionStateManager', function () {
|
|||||||
to: '0xRecipient',
|
to: '0xRecipient',
|
||||||
nonce: '0x0',
|
nonce: '0x0',
|
||||||
},
|
},
|
||||||
status: 'submitted',
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
}
|
}
|
||||||
|
|
||||||
const confirmedTx = {
|
const confirmedTx = {
|
||||||
@ -128,7 +129,7 @@ describe('TransactionStateManager', function () {
|
|||||||
to: '0xRecipient',
|
to: '0xRecipient',
|
||||||
nonce: '0x3',
|
nonce: '0x3',
|
||||||
},
|
},
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
}
|
}
|
||||||
|
|
||||||
const txm = new TxStateManager({
|
const txm = new TxStateManager({
|
||||||
@ -151,7 +152,7 @@ describe('TransactionStateManager', function () {
|
|||||||
to: '0xRecipient',
|
to: '0xRecipient',
|
||||||
nonce: '0x0',
|
nonce: '0x0',
|
||||||
},
|
},
|
||||||
status: 'submitted',
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
}
|
}
|
||||||
|
|
||||||
const unapprovedTx1 = {
|
const unapprovedTx1 = {
|
||||||
@ -163,7 +164,7 @@ describe('TransactionStateManager', function () {
|
|||||||
to: '0xRecipient',
|
to: '0xRecipient',
|
||||||
nonce: '0x1',
|
nonce: '0x1',
|
||||||
},
|
},
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
}
|
}
|
||||||
|
|
||||||
const approvedTx2 = {
|
const approvedTx2 = {
|
||||||
@ -175,7 +176,7 @@ describe('TransactionStateManager', function () {
|
|||||||
to: '0xRecipient',
|
to: '0xRecipient',
|
||||||
nonce: '0x2',
|
nonce: '0x2',
|
||||||
},
|
},
|
||||||
status: 'approved',
|
status: TRANSACTION_STATUSES.APPROVED,
|
||||||
}
|
}
|
||||||
|
|
||||||
const confirmedTx3 = {
|
const confirmedTx3 = {
|
||||||
@ -187,7 +188,7 @@ describe('TransactionStateManager', function () {
|
|||||||
to: '0xRecipient',
|
to: '0xRecipient',
|
||||||
nonce: '0x3',
|
nonce: '0x3',
|
||||||
},
|
},
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
}
|
}
|
||||||
|
|
||||||
const txm = new TxStateManager({
|
const txm = new TxStateManager({
|
||||||
@ -216,7 +217,7 @@ describe('TransactionStateManager', function () {
|
|||||||
to: '0xRecipient',
|
to: '0xRecipient',
|
||||||
nonce: '0x0',
|
nonce: '0x0',
|
||||||
},
|
},
|
||||||
status: 'submitted',
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 0,
|
id: 0,
|
||||||
@ -227,7 +228,7 @@ describe('TransactionStateManager', function () {
|
|||||||
to: '0xRecipient',
|
to: '0xRecipient',
|
||||||
nonce: '0x0',
|
nonce: '0x0',
|
||||||
},
|
},
|
||||||
status: 'submitted',
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -240,7 +241,7 @@ describe('TransactionStateManager', function () {
|
|||||||
to: '0xRecipient',
|
to: '0xRecipient',
|
||||||
nonce: '0x1',
|
nonce: '0x1',
|
||||||
},
|
},
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
}
|
}
|
||||||
|
|
||||||
const approvedTx2s = [
|
const approvedTx2s = [
|
||||||
@ -253,7 +254,7 @@ describe('TransactionStateManager', function () {
|
|||||||
to: '0xRecipient',
|
to: '0xRecipient',
|
||||||
nonce: '0x2',
|
nonce: '0x2',
|
||||||
},
|
},
|
||||||
status: 'approved',
|
status: TRANSACTION_STATUSES.APPROVED,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
@ -264,7 +265,7 @@ describe('TransactionStateManager', function () {
|
|||||||
to: '0xRecipient',
|
to: '0xRecipient',
|
||||||
nonce: '0x2',
|
nonce: '0x2',
|
||||||
},
|
},
|
||||||
status: 'approved',
|
status: TRANSACTION_STATUSES.APPROVED,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -278,7 +279,7 @@ describe('TransactionStateManager', function () {
|
|||||||
to: '0xRecipient',
|
to: '0xRecipient',
|
||||||
nonce: '0x3',
|
nonce: '0x3',
|
||||||
},
|
},
|
||||||
status: 'failed',
|
status: TRANSACTION_STATUSES.FAILED,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 3,
|
id: 3,
|
||||||
@ -289,7 +290,7 @@ describe('TransactionStateManager', function () {
|
|||||||
to: '0xRecipient',
|
to: '0xRecipient',
|
||||||
nonce: '0x3',
|
nonce: '0x3',
|
||||||
},
|
},
|
||||||
status: 'failed',
|
status: TRANSACTION_STATUSES.FAILED,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -313,7 +314,7 @@ describe('TransactionStateManager', function () {
|
|||||||
it('adds a tx returned in getTxList', function () {
|
it('adds a tx returned in getTxList', function () {
|
||||||
const tx = {
|
const tx = {
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
}
|
}
|
||||||
@ -340,7 +341,7 @@ describe('TransactionStateManager', function () {
|
|||||||
for (const value of invalidValues) {
|
for (const value of invalidValues) {
|
||||||
const tx = {
|
const tx = {
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {
|
txParams: {
|
||||||
...validTxParams,
|
...validTxParams,
|
||||||
@ -361,13 +362,13 @@ describe('TransactionStateManager', function () {
|
|||||||
it('does not override txs from other networks', function () {
|
it('does not override txs from other networks', function () {
|
||||||
const tx = {
|
const tx = {
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
}
|
}
|
||||||
const tx2 = {
|
const tx2 = {
|
||||||
id: 2,
|
id: 2,
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
metamaskNetworkId: otherNetworkId,
|
metamaskNetworkId: otherNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
}
|
}
|
||||||
@ -385,7 +386,7 @@ describe('TransactionStateManager', function () {
|
|||||||
const tx = {
|
const tx = {
|
||||||
id: i,
|
id: i,
|
||||||
time: new Date(),
|
time: new Date(),
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
}
|
}
|
||||||
@ -402,7 +403,7 @@ describe('TransactionStateManager', function () {
|
|||||||
const tx = {
|
const tx = {
|
||||||
id: i,
|
id: i,
|
||||||
time: new Date(),
|
time: new Date(),
|
||||||
status: 'rejected',
|
status: TRANSACTION_STATUSES.REJECTED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
}
|
}
|
||||||
@ -417,7 +418,7 @@ describe('TransactionStateManager', function () {
|
|||||||
const unconfirmedTx = {
|
const unconfirmedTx = {
|
||||||
id: 0,
|
id: 0,
|
||||||
time: new Date(),
|
time: new Date(),
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
}
|
}
|
||||||
@ -427,7 +428,7 @@ describe('TransactionStateManager', function () {
|
|||||||
const tx = {
|
const tx = {
|
||||||
id: i,
|
id: i,
|
||||||
time: new Date(),
|
time: new Date(),
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
}
|
}
|
||||||
@ -438,7 +439,7 @@ describe('TransactionStateManager', function () {
|
|||||||
assert.equal(result[0].id, 0, 'first tx should still be there')
|
assert.equal(result[0].id, 0, 'first tx should still be there')
|
||||||
assert.equal(
|
assert.equal(
|
||||||
result[0].status,
|
result[0].status,
|
||||||
'unapproved',
|
TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
'first tx should be unapproved',
|
'first tx should be unapproved',
|
||||||
)
|
)
|
||||||
assert.equal(result[1].id, 2, 'early txs truncated')
|
assert.equal(result[1].id, 2, 'early txs truncated')
|
||||||
@ -450,7 +451,7 @@ describe('TransactionStateManager', function () {
|
|||||||
txStateManager.addTx(
|
txStateManager.addTx(
|
||||||
{
|
{
|
||||||
id: '1',
|
id: '1',
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
},
|
},
|
||||||
@ -459,7 +460,7 @@ describe('TransactionStateManager', function () {
|
|||||||
txStateManager.addTx(
|
txStateManager.addTx(
|
||||||
{
|
{
|
||||||
id: '2',
|
id: '2',
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
},
|
},
|
||||||
@ -486,7 +487,7 @@ describe('TransactionStateManager', function () {
|
|||||||
|
|
||||||
txStateManager.addTx({
|
txStateManager.addTx({
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: validTxParams,
|
txParams: validTxParams,
|
||||||
})
|
})
|
||||||
@ -517,7 +518,7 @@ describe('TransactionStateManager', function () {
|
|||||||
|
|
||||||
const txMeta = {
|
const txMeta = {
|
||||||
id: '1',
|
id: '1',
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {
|
txParams: {
|
||||||
gasPrice: originalGasPrice,
|
gasPrice: originalGasPrice,
|
||||||
@ -591,7 +592,7 @@ describe('TransactionStateManager', function () {
|
|||||||
it('does NOT add empty history items', function () {
|
it('does NOT add empty history items', function () {
|
||||||
const txMeta = {
|
const txMeta = {
|
||||||
id: '1',
|
id: '1',
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {
|
txParams: {
|
||||||
gasPrice: '0x01',
|
gasPrice: '0x01',
|
||||||
@ -611,7 +612,7 @@ describe('TransactionStateManager', function () {
|
|||||||
txStateManager.addTx(
|
txStateManager.addTx(
|
||||||
{
|
{
|
||||||
id: '1',
|
id: '1',
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
},
|
},
|
||||||
@ -620,7 +621,7 @@ describe('TransactionStateManager', function () {
|
|||||||
txStateManager.addTx(
|
txStateManager.addTx(
|
||||||
{
|
{
|
||||||
id: '2',
|
id: '2',
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
},
|
},
|
||||||
@ -628,7 +629,7 @@ describe('TransactionStateManager', function () {
|
|||||||
)
|
)
|
||||||
const result = txStateManager.getUnapprovedTxList()
|
const result = txStateManager.getUnapprovedTxList()
|
||||||
assert.equal(typeof result, 'object')
|
assert.equal(typeof result, 'object')
|
||||||
assert.equal(result['1'].status, 'unapproved')
|
assert.equal(result['1'].status, TRANSACTION_STATUSES.UNAPPROVED)
|
||||||
assert.equal(result['2'], undefined)
|
assert.equal(result['2'], undefined)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -638,7 +639,7 @@ describe('TransactionStateManager', function () {
|
|||||||
txStateManager.addTx(
|
txStateManager.addTx(
|
||||||
{
|
{
|
||||||
id: '1',
|
id: '1',
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
},
|
},
|
||||||
@ -647,14 +648,20 @@ describe('TransactionStateManager', function () {
|
|||||||
txStateManager.addTx(
|
txStateManager.addTx(
|
||||||
{
|
{
|
||||||
id: '2',
|
id: '2',
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams: {},
|
txParams: {},
|
||||||
},
|
},
|
||||||
noop,
|
noop,
|
||||||
)
|
)
|
||||||
assert.equal(txStateManager.getTx('1').status, 'unapproved')
|
assert.equal(
|
||||||
assert.equal(txStateManager.getTx('2').status, 'confirmed')
|
txStateManager.getTx('1').status,
|
||||||
|
TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
|
)
|
||||||
|
assert.equal(
|
||||||
|
txStateManager.getTx('2').status,
|
||||||
|
TRANSACTION_STATUSES.CONFIRMED,
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -663,61 +670,61 @@ describe('TransactionStateManager', function () {
|
|||||||
const txMetas = [
|
const txMetas = [
|
||||||
{
|
{
|
||||||
id: 0,
|
id: 0,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
txParams: { from: '0xaa', to: '0xbb' },
|
txParams: { from: '0xaa', to: '0xbb' },
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
txParams: { from: '0xaa', to: '0xbb' },
|
txParams: { from: '0xaa', to: '0xbb' },
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
txParams: { from: '0xaa', to: '0xbb' },
|
txParams: { from: '0xaa', to: '0xbb' },
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 3,
|
id: 3,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
txParams: { from: '0xbb', to: '0xaa' },
|
txParams: { from: '0xbb', to: '0xaa' },
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 4,
|
id: 4,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
txParams: { from: '0xbb', to: '0xaa' },
|
txParams: { from: '0xbb', to: '0xaa' },
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 5,
|
id: 5,
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
txParams: { from: '0xaa', to: '0xbb' },
|
txParams: { from: '0xaa', to: '0xbb' },
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 6,
|
id: 6,
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
txParams: { from: '0xaa', to: '0xbb' },
|
txParams: { from: '0xaa', to: '0xbb' },
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 7,
|
id: 7,
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
txParams: { from: '0xbb', to: '0xaa' },
|
txParams: { from: '0xbb', to: '0xaa' },
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 8,
|
id: 8,
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
txParams: { from: '0xbb', to: '0xaa' },
|
txParams: { from: '0xbb', to: '0xaa' },
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 9,
|
id: 9,
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
txParams: { from: '0xbb', to: '0xaa' },
|
txParams: { from: '0xbb', to: '0xaa' },
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
},
|
},
|
||||||
@ -725,25 +732,25 @@ describe('TransactionStateManager', function () {
|
|||||||
txMetas.forEach((txMeta) => txStateManager.addTx(txMeta, noop))
|
txMetas.forEach((txMeta) => txStateManager.addTx(txMeta, noop))
|
||||||
let filterParams
|
let filterParams
|
||||||
|
|
||||||
filterParams = { status: 'unapproved', from: '0xaa' }
|
filterParams = { status: TRANSACTION_STATUSES.UNAPPROVED, from: '0xaa' }
|
||||||
assert.equal(
|
assert.equal(
|
||||||
txStateManager.getFilteredTxList(filterParams).length,
|
txStateManager.getFilteredTxList(filterParams).length,
|
||||||
3,
|
3,
|
||||||
`getFilteredTxList - ${JSON.stringify(filterParams)}`,
|
`getFilteredTxList - ${JSON.stringify(filterParams)}`,
|
||||||
)
|
)
|
||||||
filterParams = { status: 'unapproved', to: '0xaa' }
|
filterParams = { status: TRANSACTION_STATUSES.UNAPPROVED, to: '0xaa' }
|
||||||
assert.equal(
|
assert.equal(
|
||||||
txStateManager.getFilteredTxList(filterParams).length,
|
txStateManager.getFilteredTxList(filterParams).length,
|
||||||
2,
|
2,
|
||||||
`getFilteredTxList - ${JSON.stringify(filterParams)}`,
|
`getFilteredTxList - ${JSON.stringify(filterParams)}`,
|
||||||
)
|
)
|
||||||
filterParams = { status: 'confirmed', from: '0xbb' }
|
filterParams = { status: TRANSACTION_STATUSES.CONFIRMED, from: '0xbb' }
|
||||||
assert.equal(
|
assert.equal(
|
||||||
txStateManager.getFilteredTxList(filterParams).length,
|
txStateManager.getFilteredTxList(filterParams).length,
|
||||||
3,
|
3,
|
||||||
`getFilteredTxList - ${JSON.stringify(filterParams)}`,
|
`getFilteredTxList - ${JSON.stringify(filterParams)}`,
|
||||||
)
|
)
|
||||||
filterParams = { status: 'confirmed' }
|
filterParams = { status: TRANSACTION_STATUSES.CONFIRMED }
|
||||||
assert.equal(
|
assert.equal(
|
||||||
txStateManager.getFilteredTxList(filterParams).length,
|
txStateManager.getFilteredTxList(filterParams).length,
|
||||||
5,
|
5,
|
||||||
@ -761,7 +768,9 @@ describe('TransactionStateManager', function () {
|
|||||||
5,
|
5,
|
||||||
`getFilteredTxList - ${JSON.stringify(filterParams)}`,
|
`getFilteredTxList - ${JSON.stringify(filterParams)}`,
|
||||||
)
|
)
|
||||||
filterParams = { status: (status) => status !== 'confirmed' }
|
filterParams = {
|
||||||
|
status: (status) => status !== TRANSACTION_STATUSES.CONFIRMED,
|
||||||
|
}
|
||||||
assert.equal(
|
assert.equal(
|
||||||
txStateManager.getFilteredTxList(filterParams).length,
|
txStateManager.getFilteredTxList(filterParams).length,
|
||||||
5,
|
5,
|
||||||
@ -778,19 +787,19 @@ describe('TransactionStateManager', function () {
|
|||||||
const txMetas = [
|
const txMetas = [
|
||||||
{
|
{
|
||||||
id: 0,
|
id: 0,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
txParams: { from: specificAddress, to: otherAddress },
|
txParams: { from: specificAddress, to: otherAddress },
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
txParams: { from: otherAddress, to: specificAddress },
|
txParams: { from: otherAddress, to: specificAddress },
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
txParams: { from: otherAddress, to: specificAddress },
|
txParams: { from: otherAddress, to: specificAddress },
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
},
|
},
|
||||||
@ -814,19 +823,19 @@ describe('TransactionStateManager', function () {
|
|||||||
const txMetas = [
|
const txMetas = [
|
||||||
{
|
{
|
||||||
id: 0,
|
id: 0,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
txParams: { from: specificAddress, to: otherAddress },
|
txParams: { from: specificAddress, to: otherAddress },
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
txParams: { from: specificAddress, to: otherAddress },
|
txParams: { from: specificAddress, to: otherAddress },
|
||||||
metamaskNetworkId: otherNetworkId,
|
metamaskNetworkId: otherNetworkId,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
txParams: { from: specificAddress, to: otherAddress },
|
txParams: { from: specificAddress, to: otherAddress },
|
||||||
metamaskNetworkId: otherNetworkId,
|
metamaskNetworkId: otherNetworkId,
|
||||||
},
|
},
|
||||||
@ -874,25 +883,25 @@ describe('TransactionStateManager', function () {
|
|||||||
const txMetas = [
|
const txMetas = [
|
||||||
{
|
{
|
||||||
id: 0,
|
id: 0,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
txParams: { from: '0xaa', to: '0xbb' },
|
txParams: { from: '0xaa', to: '0xbb' },
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
txParams: { from: '0xaa', to: '0xbb' },
|
txParams: { from: '0xaa', to: '0xbb' },
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
txParams: { from: '0xaa', to: '0xbb' },
|
txParams: { from: '0xaa', to: '0xbb' },
|
||||||
metamaskNetworkId: otherNetworkId,
|
metamaskNetworkId: otherNetworkId,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 3,
|
id: 3,
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
txParams: { from: '0xaa', to: '0xbb' },
|
txParams: { from: '0xaa', to: '0xbb' },
|
||||||
metamaskNetworkId: otherNetworkId,
|
metamaskNetworkId: otherNetworkId,
|
||||||
},
|
},
|
||||||
@ -904,7 +913,7 @@ describe('TransactionStateManager', function () {
|
|||||||
|
|
||||||
const unapprovedTxList = txStateManager
|
const unapprovedTxList = txStateManager
|
||||||
.getFullTxList()
|
.getFullTxList()
|
||||||
.filter((tx) => tx.status === 'unapproved')
|
.filter((tx) => tx.status === TRANSACTION_STATUSES.UNAPPROVED)
|
||||||
|
|
||||||
assert.equal(unapprovedTxList.length, 0)
|
assert.equal(unapprovedTxList.length, 0)
|
||||||
})
|
})
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import MessageManager from '../../../app/scripts/lib/message-manager'
|
import MessageManager from '../../../app/scripts/lib/message-manager'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction'
|
||||||
|
|
||||||
describe('Message Manager', function () {
|
describe('Message Manager', function () {
|
||||||
let messageManager
|
let messageManager
|
||||||
@ -18,7 +19,11 @@ describe('Message Manager', function () {
|
|||||||
|
|
||||||
describe('#addMsg', function () {
|
describe('#addMsg', function () {
|
||||||
it('adds a Msg returned in getMsgList', function () {
|
it('adds a Msg returned in getMsgList', function () {
|
||||||
const Msg = { id: 1, status: 'approved', metamaskNetworkId: 'unit test' }
|
const Msg = {
|
||||||
|
id: 1,
|
||||||
|
status: TRANSACTION_STATUSES.APPROVED,
|
||||||
|
metamaskNetworkId: 'unit test',
|
||||||
|
}
|
||||||
messageManager.addMsg(Msg)
|
messageManager.addMsg(Msg)
|
||||||
const result = messageManager.messages
|
const result = messageManager.messages
|
||||||
assert.ok(Array.isArray(result))
|
assert.ok(Array.isArray(result))
|
||||||
@ -39,7 +44,7 @@ describe('Message Manager', function () {
|
|||||||
const result = messageManager.messages
|
const result = messageManager.messages
|
||||||
assert.ok(Array.isArray(result))
|
assert.ok(Array.isArray(result))
|
||||||
assert.equal(result.length, 1)
|
assert.equal(result.length, 1)
|
||||||
assert.equal(result[0].status, 'approved')
|
assert.equal(result[0].status, TRANSACTION_STATUSES.APPROVED)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -55,7 +60,7 @@ describe('Message Manager', function () {
|
|||||||
const result = messageManager.messages
|
const result = messageManager.messages
|
||||||
assert.ok(Array.isArray(result))
|
assert.ok(Array.isArray(result))
|
||||||
assert.equal(result.length, 1)
|
assert.equal(result.length, 1)
|
||||||
assert.equal(result[0].status, 'rejected')
|
assert.equal(result[0].status, TRANSACTION_STATUSES.REJECTED)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -68,7 +73,7 @@ describe('Message Manager', function () {
|
|||||||
})
|
})
|
||||||
messageManager.addMsg({
|
messageManager.addMsg({
|
||||||
id: '2',
|
id: '2',
|
||||||
status: 'approved',
|
status: TRANSACTION_STATUSES.APPROVED,
|
||||||
metamaskNetworkId: 'unit test',
|
metamaskNetworkId: 'unit test',
|
||||||
})
|
})
|
||||||
messageManager._updateMsg({
|
messageManager._updateMsg({
|
||||||
@ -91,7 +96,7 @@ describe('Message Manager', function () {
|
|||||||
})
|
})
|
||||||
messageManager.addMsg({
|
messageManager.addMsg({
|
||||||
id: '2',
|
id: '2',
|
||||||
status: 'approved',
|
status: TRANSACTION_STATUSES.APPROVED,
|
||||||
metamaskNetworkId: 'unit test',
|
metamaskNetworkId: 'unit test',
|
||||||
})
|
})
|
||||||
const result = messageManager.getUnapprovedMsgs()
|
const result = messageManager.getUnapprovedMsgs()
|
||||||
@ -110,11 +115,14 @@ describe('Message Manager', function () {
|
|||||||
})
|
})
|
||||||
messageManager.addMsg({
|
messageManager.addMsg({
|
||||||
id: '2',
|
id: '2',
|
||||||
status: 'approved',
|
status: TRANSACTION_STATUSES.APPROVED,
|
||||||
metamaskNetworkId: 'unit test',
|
metamaskNetworkId: 'unit test',
|
||||||
})
|
})
|
||||||
assert.equal(messageManager.getMsg('1').status, 'unapproved')
|
assert.equal(messageManager.getMsg('1').status, 'unapproved')
|
||||||
assert.equal(messageManager.getMsg('2').status, 'approved')
|
assert.equal(
|
||||||
|
messageManager.getMsg('2').status,
|
||||||
|
TRANSACTION_STATUSES.APPROVED,
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import PersonalMessageManager from '../../../app/scripts/lib/personal-message-manager'
|
import PersonalMessageManager from '../../../app/scripts/lib/personal-message-manager'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction'
|
||||||
|
|
||||||
describe('Personal Message Manager', function () {
|
describe('Personal Message Manager', function () {
|
||||||
let messageManager
|
let messageManager
|
||||||
@ -18,7 +19,11 @@ describe('Personal Message Manager', function () {
|
|||||||
|
|
||||||
describe('#addMsg', function () {
|
describe('#addMsg', function () {
|
||||||
it('adds a Msg returned in getMsgList', function () {
|
it('adds a Msg returned in getMsgList', function () {
|
||||||
const Msg = { id: 1, status: 'approved', metamaskNetworkId: 'unit test' }
|
const Msg = {
|
||||||
|
id: 1,
|
||||||
|
status: TRANSACTION_STATUSES.APPROVED,
|
||||||
|
metamaskNetworkId: 'unit test',
|
||||||
|
}
|
||||||
messageManager.addMsg(Msg)
|
messageManager.addMsg(Msg)
|
||||||
const result = messageManager.messages
|
const result = messageManager.messages
|
||||||
assert.ok(Array.isArray(result))
|
assert.ok(Array.isArray(result))
|
||||||
@ -31,7 +36,7 @@ describe('Personal Message Manager', function () {
|
|||||||
it('sets the Msg status to approved', function () {
|
it('sets the Msg status to approved', function () {
|
||||||
const Msg = {
|
const Msg = {
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: 'unit test',
|
metamaskNetworkId: 'unit test',
|
||||||
}
|
}
|
||||||
messageManager.addMsg(Msg)
|
messageManager.addMsg(Msg)
|
||||||
@ -39,7 +44,7 @@ describe('Personal Message Manager', function () {
|
|||||||
const result = messageManager.messages
|
const result = messageManager.messages
|
||||||
assert.ok(Array.isArray(result))
|
assert.ok(Array.isArray(result))
|
||||||
assert.equal(result.length, 1)
|
assert.equal(result.length, 1)
|
||||||
assert.equal(result[0].status, 'approved')
|
assert.equal(result[0].status, TRANSACTION_STATUSES.APPROVED)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -47,7 +52,7 @@ describe('Personal Message Manager', function () {
|
|||||||
it('sets the Msg status to rejected', function () {
|
it('sets the Msg status to rejected', function () {
|
||||||
const Msg = {
|
const Msg = {
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: 'unit test',
|
metamaskNetworkId: 'unit test',
|
||||||
}
|
}
|
||||||
messageManager.addMsg(Msg)
|
messageManager.addMsg(Msg)
|
||||||
@ -55,7 +60,7 @@ describe('Personal Message Manager', function () {
|
|||||||
const result = messageManager.messages
|
const result = messageManager.messages
|
||||||
assert.ok(Array.isArray(result))
|
assert.ok(Array.isArray(result))
|
||||||
assert.equal(result.length, 1)
|
assert.equal(result.length, 1)
|
||||||
assert.equal(result[0].status, 'rejected')
|
assert.equal(result[0].status, TRANSACTION_STATUSES.REJECTED)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -63,12 +68,12 @@ describe('Personal Message Manager', function () {
|
|||||||
it('replaces the Msg with the same id', function () {
|
it('replaces the Msg with the same id', function () {
|
||||||
messageManager.addMsg({
|
messageManager.addMsg({
|
||||||
id: '1',
|
id: '1',
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: 'unit test',
|
metamaskNetworkId: 'unit test',
|
||||||
})
|
})
|
||||||
messageManager.addMsg({
|
messageManager.addMsg({
|
||||||
id: '2',
|
id: '2',
|
||||||
status: 'approved',
|
status: TRANSACTION_STATUSES.APPROVED,
|
||||||
metamaskNetworkId: 'unit test',
|
metamaskNetworkId: 'unit test',
|
||||||
})
|
})
|
||||||
messageManager._updateMsg({
|
messageManager._updateMsg({
|
||||||
@ -86,17 +91,17 @@ describe('Personal Message Manager', function () {
|
|||||||
it('returns unapproved Msgs in a hash', function () {
|
it('returns unapproved Msgs in a hash', function () {
|
||||||
messageManager.addMsg({
|
messageManager.addMsg({
|
||||||
id: '1',
|
id: '1',
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: 'unit test',
|
metamaskNetworkId: 'unit test',
|
||||||
})
|
})
|
||||||
messageManager.addMsg({
|
messageManager.addMsg({
|
||||||
id: '2',
|
id: '2',
|
||||||
status: 'approved',
|
status: TRANSACTION_STATUSES.APPROVED,
|
||||||
metamaskNetworkId: 'unit test',
|
metamaskNetworkId: 'unit test',
|
||||||
})
|
})
|
||||||
const result = messageManager.getUnapprovedMsgs()
|
const result = messageManager.getUnapprovedMsgs()
|
||||||
assert.equal(typeof result, 'object')
|
assert.equal(typeof result, 'object')
|
||||||
assert.equal(result['1'].status, 'unapproved')
|
assert.equal(result['1'].status, TRANSACTION_STATUSES.UNAPPROVED)
|
||||||
assert.equal(result['2'], undefined)
|
assert.equal(result['2'], undefined)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -105,16 +110,22 @@ describe('Personal Message Manager', function () {
|
|||||||
it('returns a Msg with the requested id', function () {
|
it('returns a Msg with the requested id', function () {
|
||||||
messageManager.addMsg({
|
messageManager.addMsg({
|
||||||
id: '1',
|
id: '1',
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: 'unit test',
|
metamaskNetworkId: 'unit test',
|
||||||
})
|
})
|
||||||
messageManager.addMsg({
|
messageManager.addMsg({
|
||||||
id: '2',
|
id: '2',
|
||||||
status: 'approved',
|
status: TRANSACTION_STATUSES.APPROVED,
|
||||||
metamaskNetworkId: 'unit test',
|
metamaskNetworkId: 'unit test',
|
||||||
})
|
})
|
||||||
assert.equal(messageManager.getMsg('1').status, 'unapproved')
|
assert.equal(
|
||||||
assert.equal(messageManager.getMsg('2').status, 'approved')
|
messageManager.getMsg('1').status,
|
||||||
|
TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
|
)
|
||||||
|
assert.equal(
|
||||||
|
messageManager.getMsg('2').status,
|
||||||
|
TRANSACTION_STATUSES.APPROVED,
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import sinon from 'sinon'
|
import sinon from 'sinon'
|
||||||
import TypedMessageManager from '../../../app/scripts/lib/typed-message-manager'
|
import TypedMessageManager from '../../../app/scripts/lib/typed-message-manager'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction'
|
||||||
|
|
||||||
describe('Typed Message Manager', function () {
|
describe('Typed Message Manager', function () {
|
||||||
let typedMessageManager,
|
let typedMessageManager,
|
||||||
@ -89,7 +90,7 @@ describe('Typed Message Manager', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('adds to unapproved messages and sets status to unapproved', function () {
|
it('adds to unapproved messages and sets status to unapproved', function () {
|
||||||
assert.equal(typedMsgs[msgId].status, 'unapproved')
|
assert.equal(typedMsgs[msgId].status, TRANSACTION_STATUSES.UNAPPROVED)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('validates params', function () {
|
it('validates params', function () {
|
||||||
@ -106,17 +107,17 @@ describe('Typed Message Manager', function () {
|
|||||||
it('approves messages', async function () {
|
it('approves messages', async function () {
|
||||||
const messageMetaMaskId = messages[0].msgParams
|
const messageMetaMaskId = messages[0].msgParams
|
||||||
typedMessageManager.approveMessage(messageMetaMaskId)
|
typedMessageManager.approveMessage(messageMetaMaskId)
|
||||||
assert.equal(messages[0].status, 'approved')
|
assert.equal(messages[0].status, TRANSACTION_STATUSES.APPROVED)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets msg status to signed and adds a raw sig to message details', function () {
|
it('sets msg status to signed and adds a raw sig to message details', function () {
|
||||||
typedMessageManager.setMsgStatusSigned(numberMsgId, 'raw sig')
|
typedMessageManager.setMsgStatusSigned(numberMsgId, 'raw sig')
|
||||||
assert.equal(messages[0].status, 'signed')
|
assert.equal(messages[0].status, TRANSACTION_STATUSES.SIGNED)
|
||||||
assert.equal(messages[0].rawSig, 'raw sig')
|
assert.equal(messages[0].rawSig, 'raw sig')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('rejects message', function () {
|
it('rejects message', function () {
|
||||||
typedMessageManager.rejectMsg(numberMsgId)
|
typedMessageManager.rejectMsg(numberMsgId)
|
||||||
assert.equal(messages[0].status, 'rejected')
|
assert.equal(messages[0].status, TRANSACTION_STATUSES.REJECTED)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import migration22 from '../../../app/scripts/migrations/022'
|
import migration22 from '../../../app/scripts/migrations/022'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction'
|
||||||
|
|
||||||
const properTime = new Date().getTime()
|
const properTime = new Date().getTime()
|
||||||
const storage = {
|
const storage = {
|
||||||
@ -7,9 +8,9 @@ const storage = {
|
|||||||
data: {
|
data: {
|
||||||
TransactionController: {
|
TransactionController: {
|
||||||
transactions: [
|
transactions: [
|
||||||
{ status: 'submitted' },
|
{ status: TRANSACTION_STATUSES.SUBMITTED },
|
||||||
{ status: 'submitted', submittedTime: properTime },
|
{ status: TRANSACTION_STATUSES.SUBMITTED, submittedTime: properTime },
|
||||||
{ status: 'confirmed' },
|
{ status: TRANSACTION_STATUSES.CONFIRMED },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import migration23 from '../../../app/scripts/migrations/023'
|
import migration23 from '../../../app/scripts/migrations/023'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction'
|
||||||
|
|
||||||
const storage = {
|
const storage = {
|
||||||
meta: {},
|
meta: {},
|
||||||
@ -14,18 +15,14 @@ const transactions = []
|
|||||||
const transactions40 = []
|
const transactions40 = []
|
||||||
const transactions20 = []
|
const transactions20 = []
|
||||||
|
|
||||||
const txStates = [
|
const txStates = Object.values(TRANSACTION_STATUSES)
|
||||||
'unapproved',
|
|
||||||
'approved',
|
|
||||||
'signed',
|
|
||||||
'submitted',
|
|
||||||
'confirmed',
|
|
||||||
'rejected',
|
|
||||||
'failed',
|
|
||||||
'dropped',
|
|
||||||
]
|
|
||||||
|
|
||||||
const deletableTxStates = ['confirmed', 'rejected', 'failed', 'dropped']
|
const deletableTxStates = [
|
||||||
|
TRANSACTION_STATUSES.CONFIRMED,
|
||||||
|
TRANSACTION_STATUSES.REJECTED,
|
||||||
|
TRANSACTION_STATUSES.FAILED,
|
||||||
|
TRANSACTION_STATUSES.DROPPED,
|
||||||
|
]
|
||||||
|
|
||||||
let nonDeletableCount = 0
|
let nonDeletableCount = 0
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import migration24 from '../../../app/scripts/migrations/024'
|
import migration24 from '../../../app/scripts/migrations/024'
|
||||||
import data from '../../../app/scripts/first-time-state'
|
import data from '../../../app/scripts/first-time-state'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction'
|
||||||
|
|
||||||
const firstTimeState = {
|
const firstTimeState = {
|
||||||
meta: {},
|
meta: {},
|
||||||
@ -20,11 +21,11 @@ const transactions = []
|
|||||||
while (transactions.length <= 10) {
|
while (transactions.length <= 10) {
|
||||||
transactions.push({
|
transactions.push({
|
||||||
txParams: { from: '0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675' },
|
txParams: { from: '0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675' },
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
})
|
})
|
||||||
transactions.push({
|
transactions.push({
|
||||||
txParams: { from: '0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675' },
|
txParams: { from: '0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675' },
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ describe('storage is migrated successfully and the txParams.from are lowercase',
|
|||||||
const migratedTransactions =
|
const migratedTransactions =
|
||||||
migratedData.data.TransactionController.transactions
|
migratedData.data.TransactionController.transactions
|
||||||
migratedTransactions.forEach((tx) => {
|
migratedTransactions.forEach((tx) => {
|
||||||
if (tx.status === 'unapproved') {
|
if (tx.status === TRANSACTION_STATUSES.UNAPPROVED) {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
tx.txParams.from,
|
tx.txParams.from,
|
||||||
'0x8acce2391c0d510a6c5e5d8f819a678f79b7e675',
|
'0x8acce2391c0d510a6c5e5d8f819a678f79b7e675',
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import migration25 from '../../../app/scripts/migrations/025'
|
import migration25 from '../../../app/scripts/migrations/025'
|
||||||
import data from '../../../app/scripts/first-time-state'
|
import data from '../../../app/scripts/first-time-state'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction'
|
||||||
|
|
||||||
const firstTimeState = {
|
const firstTimeState = {
|
||||||
meta: {},
|
meta: {},
|
||||||
@ -25,11 +26,11 @@ while (transactions.length <= 10) {
|
|||||||
random: 'stuff',
|
random: 'stuff',
|
||||||
chainId: 2,
|
chainId: 2,
|
||||||
},
|
},
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
})
|
})
|
||||||
transactions.push({
|
transactions.push({
|
||||||
txParams: { from: '0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675' },
|
txParams: { from: '0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675' },
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,10 +44,10 @@ describe('storage is migrated successfully and the txParams.from are lowercase',
|
|||||||
const migratedTransactions =
|
const migratedTransactions =
|
||||||
migratedData.data.TransactionController.transactions
|
migratedData.data.TransactionController.transactions
|
||||||
migratedTransactions.forEach((tx) => {
|
migratedTransactions.forEach((tx) => {
|
||||||
if (tx.status === 'unapproved') {
|
if (tx.status === TRANSACTION_STATUSES.UNAPPROVED) {
|
||||||
assert(!tx.txParams.random)
|
assert(!tx.txParams.random)
|
||||||
}
|
}
|
||||||
if (tx.status === 'unapproved') {
|
if (tx.status === TRANSACTION_STATUSES.UNAPPROVED) {
|
||||||
assert(!tx.txParams.chainId)
|
assert(!tx.txParams.chainId)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import firstTimeState from '../../../app/scripts/first-time-state'
|
import firstTimeState from '../../../app/scripts/first-time-state'
|
||||||
import migration27 from '../../../app/scripts/migrations/027'
|
import migration27 from '../../../app/scripts/migrations/027'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction'
|
||||||
|
|
||||||
const oldStorage = {
|
const oldStorage = {
|
||||||
meta: {},
|
meta: {},
|
||||||
@ -14,9 +15,9 @@ const oldStorage = {
|
|||||||
const transactions = []
|
const transactions = []
|
||||||
|
|
||||||
while (transactions.length < 9) {
|
while (transactions.length < 9) {
|
||||||
transactions.push({ status: 'rejected' })
|
transactions.push({ status: TRANSACTION_STATUSES.REJECTED })
|
||||||
transactions.push({ status: 'unapproved' })
|
transactions.push({ status: TRANSACTION_STATUSES.UNAPPROVED })
|
||||||
transactions.push({ status: 'approved' })
|
transactions.push({ status: TRANSACTION_STATUSES.APPROVED })
|
||||||
}
|
}
|
||||||
|
|
||||||
oldStorage.data.TransactionController.transactions = transactions
|
oldStorage.data.TransactionController.transactions = transactions
|
||||||
@ -34,7 +35,7 @@ describe('migration #27', function () {
|
|||||||
'transactions is expected to have the length of 6',
|
'transactions is expected to have the length of 6',
|
||||||
)
|
)
|
||||||
newTransactions.forEach((txMeta) => {
|
newTransactions.forEach((txMeta) => {
|
||||||
if (txMeta.status === 'rejected') {
|
if (txMeta.status === TRANSACTION_STATUSES.REJECTED) {
|
||||||
done(new Error('transaction was found with a status of rejected'))
|
done(new Error('transaction was found with a status of rejected'))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import migration29 from '../../../app/scripts/migrations/029'
|
import migration29 from '../../../app/scripts/migrations/029'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction'
|
||||||
|
|
||||||
const properTime = new Date().getTime()
|
const properTime = new Date().getTime()
|
||||||
const storage = {
|
const storage = {
|
||||||
@ -7,11 +8,23 @@ const storage = {
|
|||||||
data: {
|
data: {
|
||||||
TransactionController: {
|
TransactionController: {
|
||||||
transactions: [
|
transactions: [
|
||||||
{ status: 'approved', id: 1, submittedTime: 0 },
|
{ status: TRANSACTION_STATUSES.APPROVED, id: 1, submittedTime: 0 },
|
||||||
{ status: 'approved', id: 2, submittedTime: properTime },
|
{
|
||||||
{ status: 'confirmed', id: 3, submittedTime: properTime },
|
status: TRANSACTION_STATUSES.APPROVED,
|
||||||
{ status: 'submitted', id: 4, submittedTime: properTime },
|
id: 2,
|
||||||
{ status: 'submitted', id: 5, submittedTime: 0 },
|
submittedTime: properTime,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
|
id: 3,
|
||||||
|
submittedTime: properTime,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
|
id: 4,
|
||||||
|
submittedTime: properTime,
|
||||||
|
},
|
||||||
|
{ status: TRANSACTION_STATUSES.SUBMITTED, id: 5, submittedTime: 0 },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -26,7 +39,11 @@ describe('storage is migrated successfully where transactions that are submitted
|
|||||||
const [txMeta1] = txs
|
const [txMeta1] = txs
|
||||||
assert.equal(migratedData.meta.version, 29)
|
assert.equal(migratedData.meta.version, 29)
|
||||||
|
|
||||||
assert.equal(txMeta1.status, 'failed', 'old tx is auto failed')
|
assert.equal(
|
||||||
|
txMeta1.status,
|
||||||
|
TRANSACTION_STATUSES.FAILED,
|
||||||
|
'old tx is auto failed',
|
||||||
|
)
|
||||||
assert(
|
assert(
|
||||||
txMeta1.err.message.includes('too long'),
|
txMeta1.err.message.includes('too long'),
|
||||||
'error message assigned',
|
'error message assigned',
|
||||||
@ -36,7 +53,11 @@ describe('storage is migrated successfully where transactions that are submitted
|
|||||||
if (tx.id === 1) {
|
if (tx.id === 1) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
assert.notEqual(tx.status, 'failed', 'other tx is not auto failed')
|
assert.notEqual(
|
||||||
|
tx.status,
|
||||||
|
TRANSACTION_STATUSES.FAILED,
|
||||||
|
'other tx is not auto failed',
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
done()
|
done()
|
||||||
|
@ -11,6 +11,7 @@ import enLocale from '../../../../app/_locales/en/messages.json'
|
|||||||
import * as actions from '../../../../ui/app/store/actions'
|
import * as actions from '../../../../ui/app/store/actions'
|
||||||
import MetaMaskController from '../../../../app/scripts/metamask-controller'
|
import MetaMaskController from '../../../../app/scripts/metamask-controller'
|
||||||
import firstTimeState from '../../localhostState'
|
import firstTimeState from '../../localhostState'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../../shared/constants/transaction'
|
||||||
|
|
||||||
const { provider } = createTestProviderTools({ scaffold: {} })
|
const { provider } = createTestProviderTools({ scaffold: {} })
|
||||||
const middleware = [thunk]
|
const middleware = [thunk]
|
||||||
@ -891,7 +892,7 @@ describe('Actions', function () {
|
|||||||
|
|
||||||
const txData = {
|
const txData = {
|
||||||
id: '1',
|
id: '1',
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: currentNetworkId,
|
metamaskNetworkId: currentNetworkId,
|
||||||
txParams,
|
txParams,
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,7 @@ import {
|
|||||||
} from '../../../../pages/send/send.utils'
|
} from '../../../../pages/send/send.utils'
|
||||||
import { MIN_GAS_LIMIT_DEC } from '../../../../pages/send/send.constants'
|
import { MIN_GAS_LIMIT_DEC } from '../../../../pages/send/send.constants'
|
||||||
import { calcMaxAmount } from '../../../../pages/send/send-content/send-amount-row/amount-max-button/amount-max-button.utils'
|
import { calcMaxAmount } from '../../../../pages/send/send-content/send-amount-row/amount-max-button/amount-max-button.utils'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../../../../shared/constants/transaction'
|
||||||
import GasModalPageContainer from './gas-modal-page-container.component'
|
import GasModalPageContainer from './gas-modal-page-container.component'
|
||||||
|
|
||||||
const mapStateToProps = (state, ownProps) => {
|
const mapStateToProps = (state, ownProps) => {
|
||||||
@ -193,8 +194,8 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
sendAmount,
|
sendAmount,
|
||||||
},
|
},
|
||||||
transaction: txData || transaction,
|
transaction: txData || transaction,
|
||||||
isSpeedUp: transaction.status === 'submitted',
|
isSpeedUp: transaction.status === TRANSACTION_STATUSES.SUBMITTED,
|
||||||
isRetry: transaction.status === 'failed',
|
isRetry: transaction.status === TRANSACTION_STATUSES.FAILED,
|
||||||
txId: transaction.id,
|
txId: transaction.id,
|
||||||
insufficientBalance,
|
insufficientBalance,
|
||||||
gasEstimatesLoading,
|
gasEstimatesLoading,
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import proxyquire from 'proxyquire'
|
import proxyquire from 'proxyquire'
|
||||||
import sinon from 'sinon'
|
import sinon from 'sinon'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../../../../../shared/constants/transaction'
|
||||||
|
|
||||||
let mapStateToProps
|
let mapStateToProps
|
||||||
let mapDispatchToProps
|
let mapDispatchToProps
|
||||||
@ -195,7 +196,7 @@ describe('gas-modal-page-container container', function () {
|
|||||||
mockState: baseMockState,
|
mockState: baseMockState,
|
||||||
mockOwnProps: {
|
mockOwnProps: {
|
||||||
...baseMockOwnProps,
|
...baseMockOwnProps,
|
||||||
transaction: { id: 34, status: 'submitted' },
|
transaction: { id: 34, status: TRANSACTION_STATUSES.SUBMITTED },
|
||||||
},
|
},
|
||||||
expectedResult: {
|
expectedResult: {
|
||||||
...baseExpectedResult,
|
...baseExpectedResult,
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
|
import {
|
||||||
|
TRANSACTION_STATUSES,
|
||||||
|
TRANSACTION_TYPES,
|
||||||
|
} from '../../../../../../shared/constants/transaction'
|
||||||
import {
|
import {
|
||||||
combineTransactionHistories,
|
combineTransactionHistories,
|
||||||
getActivities,
|
getActivities,
|
||||||
@ -19,7 +23,7 @@ describe('TransactionActivityLog utils', function () {
|
|||||||
{
|
{
|
||||||
id: 6400627574331058,
|
id: 6400627574331058,
|
||||||
time: 1543958845581,
|
time: 1543958845581,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: '3',
|
metamaskNetworkId: '3',
|
||||||
loadingDefaults: true,
|
loadingDefaults: true,
|
||||||
txParams: {
|
txParams: {
|
||||||
@ -29,13 +33,13 @@ describe('TransactionActivityLog utils', function () {
|
|||||||
gas: '0x5208',
|
gas: '0x5208',
|
||||||
gasPrice: '0x3b9aca00',
|
gasPrice: '0x3b9aca00',
|
||||||
},
|
},
|
||||||
type: 'standard',
|
type: TRANSACTION_TYPES.STANDARD,
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
op: 'replace',
|
op: 'replace',
|
||||||
path: '/status',
|
path: '/status',
|
||||||
value: 'approved',
|
value: TRANSACTION_STATUSES.APPROVED,
|
||||||
note: 'txStateManager: setting status to approved',
|
note: 'txStateManager: setting status to approved',
|
||||||
timestamp: 1543958847813,
|
timestamp: 1543958847813,
|
||||||
},
|
},
|
||||||
@ -44,7 +48,7 @@ describe('TransactionActivityLog utils', function () {
|
|||||||
{
|
{
|
||||||
op: 'replace',
|
op: 'replace',
|
||||||
path: '/status',
|
path: '/status',
|
||||||
value: 'submitted',
|
value: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
note: 'txStateManager: setting status to submitted',
|
note: 'txStateManager: setting status to submitted',
|
||||||
timestamp: 1543958848147,
|
timestamp: 1543958848147,
|
||||||
},
|
},
|
||||||
@ -53,7 +57,7 @@ describe('TransactionActivityLog utils', function () {
|
|||||||
{
|
{
|
||||||
op: 'replace',
|
op: 'replace',
|
||||||
path: '/status',
|
path: '/status',
|
||||||
value: 'dropped',
|
value: TRANSACTION_STATUSES.DROPPED,
|
||||||
note: 'txStateManager: setting status to dropped',
|
note: 'txStateManager: setting status to dropped',
|
||||||
timestamp: 1543958897181,
|
timestamp: 1543958897181,
|
||||||
},
|
},
|
||||||
@ -68,7 +72,7 @@ describe('TransactionActivityLog utils', function () {
|
|||||||
id: 6400627574331058,
|
id: 6400627574331058,
|
||||||
loadingDefaults: false,
|
loadingDefaults: false,
|
||||||
metamaskNetworkId: '3',
|
metamaskNetworkId: '3',
|
||||||
status: 'dropped',
|
status: TRANSACTION_STATUSES.DROPPED,
|
||||||
submittedTime: 1543958848135,
|
submittedTime: 1543958848135,
|
||||||
time: 1543958845581,
|
time: 1543958845581,
|
||||||
txParams: {
|
txParams: {
|
||||||
@ -79,7 +83,7 @@ describe('TransactionActivityLog utils', function () {
|
|||||||
to: '0xc5ae6383e126f901dcb06131d97a88745bfa88d6',
|
to: '0xc5ae6383e126f901dcb06131d97a88745bfa88d6',
|
||||||
value: '0x2386f26fc10000',
|
value: '0x2386f26fc10000',
|
||||||
},
|
},
|
||||||
type: 'standard',
|
type: TRANSACTION_TYPES.STANDARD,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
hash:
|
hash:
|
||||||
@ -88,7 +92,7 @@ describe('TransactionActivityLog utils', function () {
|
|||||||
{
|
{
|
||||||
id: 6400627574331060,
|
id: 6400627574331060,
|
||||||
time: 1543958857697,
|
time: 1543958857697,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
metamaskNetworkId: '3',
|
metamaskNetworkId: '3',
|
||||||
loadingDefaults: false,
|
loadingDefaults: false,
|
||||||
txParams: {
|
txParams: {
|
||||||
@ -100,7 +104,7 @@ describe('TransactionActivityLog utils', function () {
|
|||||||
nonce: '0x32',
|
nonce: '0x32',
|
||||||
},
|
},
|
||||||
lastGasPrice: '0x4190ab00',
|
lastGasPrice: '0x4190ab00',
|
||||||
type: 'retry',
|
type: TRANSACTION_TYPES.RETRY,
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
@ -115,7 +119,7 @@ describe('TransactionActivityLog utils', function () {
|
|||||||
{
|
{
|
||||||
op: 'replace',
|
op: 'replace',
|
||||||
path: '/status',
|
path: '/status',
|
||||||
value: 'approved',
|
value: TRANSACTION_STATUSES.APPROVED,
|
||||||
note: 'txStateManager: setting status to approved',
|
note: 'txStateManager: setting status to approved',
|
||||||
timestamp: 1543958859485,
|
timestamp: 1543958859485,
|
||||||
},
|
},
|
||||||
@ -124,7 +128,7 @@ describe('TransactionActivityLog utils', function () {
|
|||||||
{
|
{
|
||||||
op: 'replace',
|
op: 'replace',
|
||||||
path: '/status',
|
path: '/status',
|
||||||
value: 'signed',
|
value: TRANSACTION_STATUSES.SIGNED,
|
||||||
note: 'transactions#publishTransaction',
|
note: 'transactions#publishTransaction',
|
||||||
timestamp: 1543958859889,
|
timestamp: 1543958859889,
|
||||||
},
|
},
|
||||||
@ -133,7 +137,7 @@ describe('TransactionActivityLog utils', function () {
|
|||||||
{
|
{
|
||||||
op: 'replace',
|
op: 'replace',
|
||||||
path: '/status',
|
path: '/status',
|
||||||
value: 'submitted',
|
value: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
note: 'txStateManager: setting status to submitted',
|
note: 'txStateManager: setting status to submitted',
|
||||||
timestamp: 1543958860061,
|
timestamp: 1543958860061,
|
||||||
},
|
},
|
||||||
@ -151,7 +155,7 @@ describe('TransactionActivityLog utils', function () {
|
|||||||
{
|
{
|
||||||
op: 'replace',
|
op: 'replace',
|
||||||
path: '/status',
|
path: '/status',
|
||||||
value: 'confirmed',
|
value: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
timestamp: 1543958897165,
|
timestamp: 1543958897165,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -160,7 +164,7 @@ describe('TransactionActivityLog utils', function () {
|
|||||||
lastGasPrice: '0x4190ab00',
|
lastGasPrice: '0x4190ab00',
|
||||||
loadingDefaults: false,
|
loadingDefaults: false,
|
||||||
metamaskNetworkId: '3',
|
metamaskNetworkId: '3',
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
submittedTime: 1543958860054,
|
submittedTime: 1543958860054,
|
||||||
time: 1543958857697,
|
time: 1543958857697,
|
||||||
txParams: {
|
txParams: {
|
||||||
@ -174,7 +178,7 @@ describe('TransactionActivityLog utils', function () {
|
|||||||
txReceipt: {
|
txReceipt: {
|
||||||
status: '0x1',
|
status: '0x1',
|
||||||
},
|
},
|
||||||
type: 'retry',
|
type: TRANSACTION_TYPES.RETRY,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -222,7 +226,7 @@ describe('TransactionActivityLog utils', function () {
|
|||||||
const transaction = {
|
const transaction = {
|
||||||
history: [],
|
history: [],
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0x1',
|
from: '0x1',
|
||||||
gas: '0x5208',
|
gas: '0x5208',
|
||||||
@ -243,7 +247,7 @@ describe('TransactionActivityLog utils', function () {
|
|||||||
id: 5559712943815343,
|
id: 5559712943815343,
|
||||||
loadingDefaults: true,
|
loadingDefaults: true,
|
||||||
metamaskNetworkId: '3',
|
metamaskNetworkId: '3',
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
time: 1535507561452,
|
time: 1535507561452,
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0x1',
|
from: '0x1',
|
||||||
@ -287,7 +291,7 @@ describe('TransactionActivityLog utils', function () {
|
|||||||
op: 'replace',
|
op: 'replace',
|
||||||
path: '/status',
|
path: '/status',
|
||||||
timestamp: 1535507564302,
|
timestamp: 1535507564302,
|
||||||
value: 'approved',
|
value: TRANSACTION_STATUSES.APPROVED,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -314,7 +318,7 @@ describe('TransactionActivityLog utils', function () {
|
|||||||
op: 'replace',
|
op: 'replace',
|
||||||
path: '/status',
|
path: '/status',
|
||||||
timestamp: 1535507564518,
|
timestamp: 1535507564518,
|
||||||
value: 'signed',
|
value: TRANSACTION_STATUSES.SIGNED,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
op: 'add',
|
op: 'add',
|
||||||
@ -349,7 +353,7 @@ describe('TransactionActivityLog utils', function () {
|
|||||||
op: 'replace',
|
op: 'replace',
|
||||||
path: '/status',
|
path: '/status',
|
||||||
timestamp: 1535507564665,
|
timestamp: 1535507564665,
|
||||||
value: 'submitted',
|
value: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -367,12 +371,12 @@ describe('TransactionActivityLog utils', function () {
|
|||||||
op: 'replace',
|
op: 'replace',
|
||||||
path: '/status',
|
path: '/status',
|
||||||
timestamp: 1535507615993,
|
timestamp: 1535507615993,
|
||||||
value: 'confirmed',
|
value: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0x1',
|
from: '0x1',
|
||||||
gas: '0x5208',
|
gas: '0x5208',
|
||||||
|
@ -2,13 +2,14 @@ import assert from 'assert'
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { shallow } from 'enzyme'
|
import { shallow } from 'enzyme'
|
||||||
import TransactionBreakdown from '../transaction-breakdown.component'
|
import TransactionBreakdown from '../transaction-breakdown.component'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../../../../shared/constants/transaction'
|
||||||
|
|
||||||
describe('TransactionBreakdown Component', function () {
|
describe('TransactionBreakdown Component', function () {
|
||||||
it('should render properly', function () {
|
it('should render properly', function () {
|
||||||
const transaction = {
|
const transaction = {
|
||||||
history: [],
|
history: [],
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0x1',
|
from: '0x1',
|
||||||
gas: '0x5208',
|
gas: '0x5208',
|
||||||
|
@ -6,13 +6,14 @@ import Button from '../../../ui/button'
|
|||||||
import SenderToRecipient from '../../../ui/sender-to-recipient'
|
import SenderToRecipient from '../../../ui/sender-to-recipient'
|
||||||
import TransactionBreakdown from '../../transaction-breakdown'
|
import TransactionBreakdown from '../../transaction-breakdown'
|
||||||
import TransactionActivityLog from '../../transaction-activity-log'
|
import TransactionActivityLog from '../../transaction-activity-log'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../../../../shared/constants/transaction'
|
||||||
|
|
||||||
describe('TransactionListItemDetails Component', function () {
|
describe('TransactionListItemDetails Component', function () {
|
||||||
it('should render properly', function () {
|
it('should render properly', function () {
|
||||||
const transaction = {
|
const transaction = {
|
||||||
history: [],
|
history: [],
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0x1',
|
from: '0x1',
|
||||||
gas: '0x5208',
|
gas: '0x5208',
|
||||||
@ -53,7 +54,7 @@ describe('TransactionListItemDetails Component', function () {
|
|||||||
const transaction = {
|
const transaction = {
|
||||||
history: [],
|
history: [],
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0x1',
|
from: '0x1',
|
||||||
gas: '0x5208',
|
gas: '0x5208',
|
||||||
@ -96,7 +97,7 @@ describe('TransactionListItemDetails Component', function () {
|
|||||||
const transaction = {
|
const transaction = {
|
||||||
history: [],
|
history: [],
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0x1',
|
from: '0x1',
|
||||||
gas: '0x5208',
|
gas: '0x5208',
|
||||||
@ -137,7 +138,7 @@ describe('TransactionListItemDetails Component', function () {
|
|||||||
const transaction = {
|
const transaction = {
|
||||||
history: [],
|
history: [],
|
||||||
id: 1,
|
id: 1,
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
hash: '0xaa',
|
hash: '0xaa',
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0x1',
|
from: '0x1',
|
||||||
|
@ -10,7 +10,6 @@ import {
|
|||||||
} from '../../../../../shared/constants/transaction'
|
} from '../../../../../shared/constants/transaction'
|
||||||
|
|
||||||
const QUEUED_PSEUDO_STATUS = 'queued'
|
const QUEUED_PSEUDO_STATUS = 'queued'
|
||||||
const PENDING_PSEUDO_STATUS = 'pending'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A note about status logic for this component:
|
* A note about status logic for this component:
|
||||||
@ -23,9 +22,9 @@ const PENDING_PSEUDO_STATUS = 'pending'
|
|||||||
* status label will be the date the transaction was finalized.
|
* status label will be the date the transaction was finalized.
|
||||||
*/
|
*/
|
||||||
const pendingStatusHash = {
|
const pendingStatusHash = {
|
||||||
[TRANSACTION_STATUSES.SUBMITTED]: PENDING_PSEUDO_STATUS,
|
[TRANSACTION_STATUSES.SUBMITTED]: TRANSACTION_GROUP_STATUSES.PENDING,
|
||||||
[TRANSACTION_STATUSES.APPROVED]: PENDING_PSEUDO_STATUS,
|
[TRANSACTION_STATUSES.APPROVED]: TRANSACTION_GROUP_STATUSES.PENDING,
|
||||||
[TRANSACTION_STATUSES.SIGNED]: PENDING_PSEUDO_STATUS,
|
[TRANSACTION_STATUSES.SIGNED]: TRANSACTION_GROUP_STATUSES.PENDING,
|
||||||
}
|
}
|
||||||
|
|
||||||
const statusToClassNameHash = {
|
const statusToClassNameHash = {
|
||||||
@ -35,7 +34,7 @@ const statusToClassNameHash = {
|
|||||||
[TRANSACTION_STATUSES.DROPPED]: 'transaction-status--dropped',
|
[TRANSACTION_STATUSES.DROPPED]: 'transaction-status--dropped',
|
||||||
[TRANSACTION_GROUP_STATUSES.CANCELLED]: 'transaction-status--cancelled',
|
[TRANSACTION_GROUP_STATUSES.CANCELLED]: 'transaction-status--cancelled',
|
||||||
[QUEUED_PSEUDO_STATUS]: 'transaction-status--queued',
|
[QUEUED_PSEUDO_STATUS]: 'transaction-status--queued',
|
||||||
[PENDING_PSEUDO_STATUS]: 'transaction-status--pending',
|
[TRANSACTION_GROUP_STATUSES.PENDING]: 'transaction-status--pending',
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function TransactionStatus({
|
export default function TransactionStatus({
|
||||||
@ -49,7 +48,9 @@ export default function TransactionStatus({
|
|||||||
const tooltipText = error?.rpc?.message || error?.message
|
const tooltipText = error?.rpc?.message || error?.message
|
||||||
let statusKey = status
|
let statusKey = status
|
||||||
if (pendingStatusHash[status]) {
|
if (pendingStatusHash[status]) {
|
||||||
statusKey = isEarliestNonce ? PENDING_PSEUDO_STATUS : QUEUED_PSEUDO_STATUS
|
statusKey = isEarliestNonce
|
||||||
|
? TRANSACTION_GROUP_STATUSES.PENDING
|
||||||
|
: QUEUED_PSEUDO_STATUS
|
||||||
}
|
}
|
||||||
|
|
||||||
const statusText =
|
const statusText =
|
||||||
|
@ -2,6 +2,10 @@ import assert from 'assert'
|
|||||||
import configureMockStore from 'redux-mock-store'
|
import configureMockStore from 'redux-mock-store'
|
||||||
import thunk from 'redux-thunk'
|
import thunk from 'redux-thunk'
|
||||||
import sinon from 'sinon'
|
import sinon from 'sinon'
|
||||||
|
import {
|
||||||
|
TRANSACTION_CATEGORIES,
|
||||||
|
TRANSACTION_STATUSES,
|
||||||
|
} from '../../../../shared/constants/transaction'
|
||||||
|
|
||||||
import ConfirmTransactionReducer, * as actions from './confirm-transaction.duck'
|
import ConfirmTransactionReducer, * as actions from './confirm-transaction.duck'
|
||||||
|
|
||||||
@ -58,7 +62,7 @@ describe('Confirm Transaction Duck', function () {
|
|||||||
name: 'abcToken',
|
name: 'abcToken',
|
||||||
},
|
},
|
||||||
methodData: {
|
methodData: {
|
||||||
name: 'approve',
|
name: TRANSACTION_CATEGORIES.TOKEN_METHOD_APPROVE,
|
||||||
},
|
},
|
||||||
tokenProps: {
|
tokenProps: {
|
||||||
tokenDecimals: '3',
|
tokenDecimals: '3',
|
||||||
@ -503,7 +507,7 @@ describe('Confirm Transaction Duck', function () {
|
|||||||
loadingDefaults: false,
|
loadingDefaults: false,
|
||||||
metamaskNetworkId: '3',
|
metamaskNetworkId: '3',
|
||||||
origin: 'faucet.metamask.io',
|
origin: 'faucet.metamask.io',
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
time: 1530838113716,
|
time: 1530838113716,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -537,7 +541,7 @@ describe('Confirm Transaction Duck', function () {
|
|||||||
loadingDefaults: false,
|
loadingDefaults: false,
|
||||||
metamaskNetworkId: '3',
|
metamaskNetworkId: '3',
|
||||||
origin: 'faucet.metamask.io',
|
origin: 'faucet.metamask.io',
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
time: 1530838113716,
|
time: 1530838113716,
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0xc5ae6383e126f901dcb06131d97a88745bfa88d6',
|
from: '0xc5ae6383e126f901dcb06131d97a88745bfa88d6',
|
||||||
@ -609,7 +613,7 @@ describe('Confirm Transaction Duck', function () {
|
|||||||
loadingDefaults: false,
|
loadingDefaults: false,
|
||||||
metamaskNetworkId: '3',
|
metamaskNetworkId: '3',
|
||||||
origin: 'faucet.metamask.io',
|
origin: 'faucet.metamask.io',
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
time: 1530838113716,
|
time: 1530838113716,
|
||||||
txParams: {
|
txParams: {
|
||||||
from: '0xc5ae6383e126f901dcb06131d97a88745bfa88d6',
|
from: '0xc5ae6383e126f901dcb06131d97a88745bfa88d6',
|
||||||
|
@ -6,6 +6,7 @@ import { addHexPrefix } from '../../../../app/scripts/lib/util'
|
|||||||
import { getEtherscanNetworkPrefix } from '../../../lib/etherscan-prefix-for-network'
|
import { getEtherscanNetworkPrefix } from '../../../lib/etherscan-prefix-for-network'
|
||||||
import {
|
import {
|
||||||
TRANSACTION_CATEGORIES,
|
TRANSACTION_CATEGORIES,
|
||||||
|
TRANSACTION_GROUP_STATUSES,
|
||||||
TRANSACTION_STATUSES,
|
TRANSACTION_STATUSES,
|
||||||
TRANSACTION_TYPES,
|
TRANSACTION_TYPES,
|
||||||
} from '../../../../shared/constants/transaction'
|
} from '../../../../shared/constants/transaction'
|
||||||
@ -176,14 +177,14 @@ export function getStatusKey(transaction) {
|
|||||||
|
|
||||||
// There was an on-chain failure
|
// There was an on-chain failure
|
||||||
if (receiptStatus === '0x0') {
|
if (receiptStatus === '0x0') {
|
||||||
return 'failed'
|
return TRANSACTION_STATUSES.FAILED
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
status === TRANSACTION_STATUSES.CONFIRMED &&
|
status === TRANSACTION_STATUSES.CONFIRMED &&
|
||||||
type === TRANSACTION_TYPES.CANCEL
|
type === TRANSACTION_TYPES.CANCEL
|
||||||
) {
|
) {
|
||||||
return 'cancelled'
|
return TRANSACTION_GROUP_STATUSES.CANCELLED
|
||||||
}
|
}
|
||||||
|
|
||||||
return transaction.status
|
return transaction.status
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
|
import {
|
||||||
|
TRANSACTION_CATEGORIES,
|
||||||
|
TRANSACTION_GROUP_STATUSES,
|
||||||
|
TRANSACTION_STATUSES,
|
||||||
|
} from '../../../../shared/constants/transaction'
|
||||||
import * as utils from './transactions.util'
|
import * as utils from './transactions.util'
|
||||||
|
|
||||||
describe('Transactions utils', function () {
|
describe('Transactions utils', function () {
|
||||||
@ -9,7 +14,7 @@ describe('Transactions utils', function () {
|
|||||||
)
|
)
|
||||||
assert.ok(tokenData)
|
assert.ok(tokenData)
|
||||||
const { name, args } = tokenData
|
const { name, args } = tokenData
|
||||||
assert.equal(name, 'transfer')
|
assert.equal(name, TRANSACTION_CATEGORIES.TOKEN_METHOD_TRANSFER)
|
||||||
const to = args._to
|
const to = args._to
|
||||||
const value = args._value.toString()
|
const value = args._value.toString()
|
||||||
assert.equal(to, '0x50A9D56C2B8BA9A5c7f2C08C3d26E0499F23a706')
|
assert.equal(to, '0x50A9D56C2B8BA9A5c7f2C08C3d26E0499F23a706')
|
||||||
@ -26,27 +31,27 @@ describe('Transactions utils', function () {
|
|||||||
const tests = [
|
const tests = [
|
||||||
{
|
{
|
||||||
transaction: {
|
transaction: {
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
txReceipt: {
|
txReceipt: {
|
||||||
status: '0x0',
|
status: '0x0',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: 'failed',
|
expected: TRANSACTION_STATUSES.FAILED,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
transaction: {
|
transaction: {
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
txReceipt: {
|
txReceipt: {
|
||||||
status: '0x1',
|
status: '0x1',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: 'confirmed',
|
expected: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
transaction: {
|
transaction: {
|
||||||
status: 'pending',
|
status: TRANSACTION_GROUP_STATUSES.PENDING,
|
||||||
},
|
},
|
||||||
expected: 'pending',
|
expected: TRANSACTION_GROUP_STATUSES.PENDING,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -2,13 +2,14 @@ import assert from 'assert'
|
|||||||
import { ethers } from 'ethers'
|
import { ethers } from 'ethers'
|
||||||
import { renderHook } from '@testing-library/react-hooks'
|
import { renderHook } from '@testing-library/react-hooks'
|
||||||
import { useTokenData } from '../useTokenData'
|
import { useTokenData } from '../useTokenData'
|
||||||
|
import { TRANSACTION_CATEGORIES } from '../../../../shared/constants/transaction'
|
||||||
|
|
||||||
const tests = [
|
const tests = [
|
||||||
{
|
{
|
||||||
data:
|
data:
|
||||||
'0xa9059cbb000000000000000000000000ffe5bc4e8f1f969934d773fa67da095d2e491a970000000000000000000000000000000000000000000000000000000000003a98',
|
'0xa9059cbb000000000000000000000000ffe5bc4e8f1f969934d773fa67da095d2e491a970000000000000000000000000000000000000000000000000000000000003a98',
|
||||||
tokenData: {
|
tokenData: {
|
||||||
name: 'transfer',
|
name: TRANSACTION_CATEGORIES.TOKEN_METHOD_TRANSFER,
|
||||||
args: [
|
args: [
|
||||||
'0xffe5bc4e8f1f969934d773fa67da095d2e491a97',
|
'0xffe5bc4e8f1f969934d773fa67da095d2e491a97',
|
||||||
ethers.BigNumber.from(15000),
|
ethers.BigNumber.from(15000),
|
||||||
@ -19,7 +20,7 @@ const tests = [
|
|||||||
data:
|
data:
|
||||||
'0xa9059cbb000000000000000000000000ffe5bc4e8f1f969934d773fa67da095d2e491a9700000000000000000000000000000000000000000000000000000000000061a8',
|
'0xa9059cbb000000000000000000000000ffe5bc4e8f1f969934d773fa67da095d2e491a9700000000000000000000000000000000000000000000000000000000000061a8',
|
||||||
tokenData: {
|
tokenData: {
|
||||||
name: 'transfer',
|
name: TRANSACTION_CATEGORIES.TOKEN_METHOD_TRANSFER,
|
||||||
args: [
|
args: [
|
||||||
'0xffe5bc4e8f1f969934d773fa67da095d2e491a97',
|
'0xffe5bc4e8f1f969934d773fa67da095d2e491a97',
|
||||||
ethers.BigNumber.from(25000),
|
ethers.BigNumber.from(25000),
|
||||||
@ -30,7 +31,7 @@ const tests = [
|
|||||||
data:
|
data:
|
||||||
'0xa9059cbb000000000000000000000000ffe5bc4e8f1f969934d773fa67da095d2e491a970000000000000000000000000000000000000000000000000000000000002710',
|
'0xa9059cbb000000000000000000000000ffe5bc4e8f1f969934d773fa67da095d2e491a970000000000000000000000000000000000000000000000000000000000002710',
|
||||||
tokenData: {
|
tokenData: {
|
||||||
name: 'transfer',
|
name: TRANSACTION_CATEGORIES.TOKEN_METHOD_TRANSFER,
|
||||||
args: [
|
args: [
|
||||||
'0xffe5bc4e8f1f969934d773fa67da095d2e491a97',
|
'0xffe5bc4e8f1f969934d773fa67da095d2e491a97',
|
||||||
ethers.BigNumber.from(10000),
|
ethers.BigNumber.from(10000),
|
||||||
|
@ -18,11 +18,16 @@ import * as i18nhooks from '../useI18nContext'
|
|||||||
import { getMessage } from '../../helpers/utils/i18n-helper'
|
import { getMessage } from '../../helpers/utils/i18n-helper'
|
||||||
import messages from '../../../../app/_locales/en/messages.json'
|
import messages from '../../../../app/_locales/en/messages.json'
|
||||||
import { ASSET_ROUTE, DEFAULT_ROUTE } from '../../helpers/constants/routes'
|
import { ASSET_ROUTE, DEFAULT_ROUTE } from '../../helpers/constants/routes'
|
||||||
|
import {
|
||||||
|
TRANSACTION_CATEGORIES,
|
||||||
|
TRANSACTION_GROUP_CATEGORIES,
|
||||||
|
TRANSACTION_STATUSES,
|
||||||
|
} from '../../../../shared/constants/transaction'
|
||||||
|
|
||||||
const expectedResults = [
|
const expectedResults = [
|
||||||
{
|
{
|
||||||
title: 'Send ETH',
|
title: 'Send ETH',
|
||||||
category: 'send',
|
category: TRANSACTION_GROUP_CATEGORIES.SEND,
|
||||||
subtitle: 'To: 0xffe5...1a97',
|
subtitle: 'To: 0xffe5...1a97',
|
||||||
subtitleContainsOrigin: false,
|
subtitleContainsOrigin: false,
|
||||||
date: 'May 12',
|
date: 'May 12',
|
||||||
@ -31,12 +36,12 @@ const expectedResults = [
|
|||||||
recipientAddress: '0xffe5bc4e8f1f969934d773fa67da095d2e491a97',
|
recipientAddress: '0xffe5bc4e8f1f969934d773fa67da095d2e491a97',
|
||||||
secondaryCurrency: '-1 ETH',
|
secondaryCurrency: '-1 ETH',
|
||||||
isPending: false,
|
isPending: false,
|
||||||
displayedStatusKey: 'confirmed',
|
displayedStatusKey: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
isSubmitted: false,
|
isSubmitted: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Send ETH',
|
title: 'Send ETH',
|
||||||
category: 'send',
|
category: TRANSACTION_GROUP_CATEGORIES.SEND,
|
||||||
subtitle: 'To: 0x0ccc...8848',
|
subtitle: 'To: 0x0ccc...8848',
|
||||||
subtitleContainsOrigin: false,
|
subtitleContainsOrigin: false,
|
||||||
date: 'May 12',
|
date: 'May 12',
|
||||||
@ -45,11 +50,11 @@ const expectedResults = [
|
|||||||
recipientAddress: '0x0ccc8aeeaf5ce790f3b448325981a143fdef8848',
|
recipientAddress: '0x0ccc8aeeaf5ce790f3b448325981a143fdef8848',
|
||||||
secondaryCurrency: '-2 ETH',
|
secondaryCurrency: '-2 ETH',
|
||||||
isPending: false,
|
isPending: false,
|
||||||
displayedStatusKey: 'confirmed',
|
displayedStatusKey: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Send ETH',
|
title: 'Send ETH',
|
||||||
category: 'send',
|
category: TRANSACTION_GROUP_CATEGORIES.SEND,
|
||||||
subtitle: 'To: 0xffe5...1a97',
|
subtitle: 'To: 0xffe5...1a97',
|
||||||
subtitleContainsOrigin: false,
|
subtitleContainsOrigin: false,
|
||||||
date: 'May 12',
|
date: 'May 12',
|
||||||
@ -58,11 +63,11 @@ const expectedResults = [
|
|||||||
recipientAddress: '0xffe5bc4e8f1f969934d773fa67da095d2e491a97',
|
recipientAddress: '0xffe5bc4e8f1f969934d773fa67da095d2e491a97',
|
||||||
secondaryCurrency: '-2 ETH',
|
secondaryCurrency: '-2 ETH',
|
||||||
isPending: false,
|
isPending: false,
|
||||||
displayedStatusKey: 'confirmed',
|
displayedStatusKey: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Receive',
|
title: 'Receive',
|
||||||
category: 'receive',
|
category: TRANSACTION_GROUP_CATEGORIES.RECEIVE,
|
||||||
subtitle: 'From: 0x31b9...4523',
|
subtitle: 'From: 0x31b9...4523',
|
||||||
subtitleContainsOrigin: false,
|
subtitleContainsOrigin: false,
|
||||||
date: 'May 12',
|
date: 'May 12',
|
||||||
@ -71,11 +76,11 @@ const expectedResults = [
|
|||||||
recipientAddress: '0x9eca64466f257793eaa52fcfff5066894b76a149',
|
recipientAddress: '0x9eca64466f257793eaa52fcfff5066894b76a149',
|
||||||
secondaryCurrency: '18.75 ETH',
|
secondaryCurrency: '18.75 ETH',
|
||||||
isPending: false,
|
isPending: false,
|
||||||
displayedStatusKey: 'confirmed',
|
displayedStatusKey: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Receive',
|
title: 'Receive',
|
||||||
category: 'receive',
|
category: TRANSACTION_GROUP_CATEGORIES.RECEIVE,
|
||||||
subtitle: 'From: 0x9eca...a149',
|
subtitle: 'From: 0x9eca...a149',
|
||||||
subtitleContainsOrigin: false,
|
subtitleContainsOrigin: false,
|
||||||
date: 'May 8',
|
date: 'May 8',
|
||||||
@ -84,11 +89,11 @@ const expectedResults = [
|
|||||||
recipientAddress: '0x9eca64466f257793eaa52fcfff5066894b76a149',
|
recipientAddress: '0x9eca64466f257793eaa52fcfff5066894b76a149',
|
||||||
secondaryCurrency: '0 ETH',
|
secondaryCurrency: '0 ETH',
|
||||||
isPending: false,
|
isPending: false,
|
||||||
displayedStatusKey: 'confirmed',
|
displayedStatusKey: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Receive',
|
title: 'Receive',
|
||||||
category: 'receive',
|
category: TRANSACTION_GROUP_CATEGORIES.RECEIVE,
|
||||||
subtitle: 'From: 0xee01...febb',
|
subtitle: 'From: 0xee01...febb',
|
||||||
subtitleContainsOrigin: false,
|
subtitleContainsOrigin: false,
|
||||||
date: 'May 24',
|
date: 'May 24',
|
||||||
@ -97,11 +102,11 @@ const expectedResults = [
|
|||||||
recipientAddress: '0x9eca64466f257793eaa52fcfff5066894b76a149',
|
recipientAddress: '0x9eca64466f257793eaa52fcfff5066894b76a149',
|
||||||
secondaryCurrency: '1 ETH',
|
secondaryCurrency: '1 ETH',
|
||||||
isPending: false,
|
isPending: false,
|
||||||
displayedStatusKey: 'confirmed',
|
displayedStatusKey: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Swap ETH to ABC',
|
title: 'Swap ETH to ABC',
|
||||||
category: 'swap',
|
category: TRANSACTION_CATEGORIES.SWAP,
|
||||||
subtitle: '',
|
subtitle: '',
|
||||||
subtitleContainsOrigin: false,
|
subtitleContainsOrigin: false,
|
||||||
date: 'May 12',
|
date: 'May 12',
|
||||||
@ -110,7 +115,7 @@ const expectedResults = [
|
|||||||
recipientAddress: '0xabca64466f257793eaa52fcfff5066894b76a149',
|
recipientAddress: '0xabca64466f257793eaa52fcfff5066894b76a149',
|
||||||
secondaryCurrency: undefined,
|
secondaryCurrency: undefined,
|
||||||
isPending: false,
|
isPending: false,
|
||||||
displayedStatusKey: 'confirmed',
|
displayedStatusKey: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -120,8 +125,9 @@ const renderHookWithRouter = (cb, tokenAddress) => {
|
|||||||
const initialEntries = [
|
const initialEntries = [
|
||||||
tokenAddress ? `${ASSET_ROUTE}/${tokenAddress}` : DEFAULT_ROUTE,
|
tokenAddress ? `${ASSET_ROUTE}/${tokenAddress}` : DEFAULT_ROUTE,
|
||||||
]
|
]
|
||||||
// eslint-disable-next-line
|
const wrapper = ({ children }) => (
|
||||||
const wrapper = ({ children }) => <MemoryRouter initialEntries={initialEntries}>{children}</MemoryRouter>
|
<MemoryRouter initialEntries={initialEntries}>{children}</MemoryRouter>
|
||||||
|
)
|
||||||
return renderHook(cb, { wrapper })
|
return renderHook(cb, { wrapper })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { TRANSACTION_CATEGORIES } from '../../../../shared/constants/transaction'
|
||||||
import { decimalToHex } from '../../helpers/utils/conversions.util'
|
import { decimalToHex } from '../../helpers/utils/conversions.util'
|
||||||
import {
|
import {
|
||||||
calcTokenValue,
|
calcTokenValue,
|
||||||
@ -13,7 +14,7 @@ export function getCustomTxParamsData(
|
|||||||
|
|
||||||
if (!tokenData) {
|
if (!tokenData) {
|
||||||
throw new Error('Invalid data')
|
throw new Error('Invalid data')
|
||||||
} else if (tokenData.name !== 'approve') {
|
} else if (tokenData.name !== TRANSACTION_CATEGORIES.TOKEN_METHOD_APPROVE) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Invalid data; should be 'approve' method, but instead is '${tokenData.name}'`,
|
`Invalid data; should be 'approve' method, but instead is '${tokenData.name}'`,
|
||||||
)
|
)
|
||||||
|
@ -18,7 +18,10 @@ import { PRIMARY, SECONDARY } from '../../helpers/constants/common'
|
|||||||
import { hexToDecimal } from '../../helpers/utils/conversions.util'
|
import { hexToDecimal } from '../../helpers/utils/conversions.util'
|
||||||
import AdvancedGasInputs from '../../components/app/gas-customization/advanced-gas-inputs'
|
import AdvancedGasInputs from '../../components/app/gas-customization/advanced-gas-inputs'
|
||||||
import TextField from '../../components/ui/text-field'
|
import TextField from '../../components/ui/text-field'
|
||||||
import { TRANSACTION_STATUSES } from '../../../../shared/constants/transaction'
|
import {
|
||||||
|
TRANSACTION_CATEGORIES,
|
||||||
|
TRANSACTION_STATUSES,
|
||||||
|
} from '../../../../shared/constants/transaction'
|
||||||
|
|
||||||
export default class ConfirmTransactionBase extends Component {
|
export default class ConfirmTransactionBase extends Component {
|
||||||
static contextTypes = {
|
static contextTypes = {
|
||||||
@ -225,7 +228,9 @@ export default class ConfirmTransactionBase extends Component {
|
|||||||
customVariables: {
|
customVariables: {
|
||||||
recipientKnown: null,
|
recipientKnown: null,
|
||||||
functionType:
|
functionType:
|
||||||
actionKey || getMethodName(methodData.name) || 'contractInteraction',
|
actionKey ||
|
||||||
|
getMethodName(methodData.name) ||
|
||||||
|
TRANSACTION_CATEGORIES.CONTRACT_INTERACTION,
|
||||||
origin,
|
origin,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -416,7 +421,9 @@ export default class ConfirmTransactionBase extends Component {
|
|||||||
customVariables: {
|
customVariables: {
|
||||||
recipientKnown: null,
|
recipientKnown: null,
|
||||||
functionType:
|
functionType:
|
||||||
actionKey || getMethodName(methodData.name) || 'contractInteraction',
|
actionKey ||
|
||||||
|
getMethodName(methodData.name) ||
|
||||||
|
TRANSACTION_CATEGORIES.CONTRACT_INTERACTION,
|
||||||
origin,
|
origin,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -470,7 +477,9 @@ export default class ConfirmTransactionBase extends Component {
|
|||||||
customVariables: {
|
customVariables: {
|
||||||
recipientKnown: null,
|
recipientKnown: null,
|
||||||
functionType:
|
functionType:
|
||||||
actionKey || getMethodName(methodData.name) || 'contractInteraction',
|
actionKey ||
|
||||||
|
getMethodName(methodData.name) ||
|
||||||
|
TRANSACTION_CATEGORIES.CONTRACT_INTERACTION,
|
||||||
origin,
|
origin,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -525,7 +534,7 @@ export default class ConfirmTransactionBase extends Component {
|
|||||||
functionType:
|
functionType:
|
||||||
actionKey ||
|
actionKey ||
|
||||||
getMethodName(methodData.name) ||
|
getMethodName(methodData.name) ||
|
||||||
'contractInteraction',
|
TRANSACTION_CATEGORIES.CONTRACT_INTERACTION,
|
||||||
origin,
|
origin,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -11,6 +11,7 @@ import SignatureRequestOriginal from '../../components/app/signature-request-ori
|
|||||||
import Loading from '../../components/ui/loading-screen'
|
import Loading from '../../components/ui/loading-screen'
|
||||||
import { getMostRecentOverviewPage } from '../../ducks/history/history'
|
import { getMostRecentOverviewPage } from '../../ducks/history/history'
|
||||||
import { MESSAGE_TYPE } from '../../../../app/scripts/lib/enums'
|
import { MESSAGE_TYPE } from '../../../../app/scripts/lib/enums'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../../shared/constants/transaction'
|
||||||
|
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps(state) {
|
||||||
const { metamask, appState } = state
|
const { metamask, appState } = state
|
||||||
@ -213,7 +214,7 @@ class ConfirmTxScreen extends Component {
|
|||||||
|
|
||||||
const unconfTxList = txHelper(unapprovedTxs, {}, {}, {}, network)
|
const unconfTxList = txHelper(unapprovedTxs, {}, {}, {}, network)
|
||||||
|
|
||||||
if (prevTx && prevTx.status === 'dropped') {
|
if (prevTx && prevTx.status === TRANSACTION_STATUSES.DROPPED) {
|
||||||
this.props.dispatch(
|
this.props.dispatch(
|
||||||
actions.showModal({
|
actions.showModal({
|
||||||
name: 'TRANSACTION_CONFIRMED',
|
name: 'TRANSACTION_CONFIRMED',
|
||||||
|
@ -58,6 +58,7 @@ import {
|
|||||||
ENVIRONMENT_TYPE_POPUP,
|
ENVIRONMENT_TYPE_POPUP,
|
||||||
} from '../../../../app/scripts/lib/enums'
|
} from '../../../../app/scripts/lib/enums'
|
||||||
import { getEnvironmentType } from '../../../../app/scripts/lib/util'
|
import { getEnvironmentType } from '../../../../app/scripts/lib/util'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../../shared/constants/transaction'
|
||||||
|
|
||||||
export default class Routes extends Component {
|
export default class Routes extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
@ -271,7 +272,7 @@ export default class Routes extends Component {
|
|||||||
|
|
||||||
const sidebarShouldClose =
|
const sidebarShouldClose =
|
||||||
sidebarTransaction &&
|
sidebarTransaction &&
|
||||||
!sidebarTransaction.status === 'failed' &&
|
!sidebarTransaction.status === TRANSACTION_STATUSES.FAILED &&
|
||||||
!submittedPendingTransactions.find(
|
!submittedPendingTransactions.find(
|
||||||
({ id }) => id === sidebarTransaction.id,
|
({ id }) => id === sidebarTransaction.id,
|
||||||
)
|
)
|
||||||
|
@ -64,6 +64,7 @@ import { useNewMetricEvent } from '../../hooks/useMetricEvent'
|
|||||||
import { getValueFromWeiHex } from '../../helpers/utils/conversions.util'
|
import { getValueFromWeiHex } from '../../helpers/utils/conversions.util'
|
||||||
|
|
||||||
import FeatureToggledRoute from '../../helpers/higher-order-components/feature-toggled-route'
|
import FeatureToggledRoute from '../../helpers/higher-order-components/feature-toggled-route'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../../shared/constants/transaction'
|
||||||
import {
|
import {
|
||||||
fetchTokens,
|
fetchTokens,
|
||||||
fetchTopAssets,
|
fetchTopAssets,
|
||||||
@ -139,12 +140,13 @@ export default function Swap() {
|
|||||||
destinationTokenInfo?.decimals,
|
destinationTokenInfo?.decimals,
|
||||||
approveTxData,
|
approveTxData,
|
||||||
)
|
)
|
||||||
const tradeConfirmed = tradeTxData?.status === 'confirmed'
|
const tradeConfirmed = tradeTxData?.status === TRANSACTION_STATUSES.CONFIRMED
|
||||||
const approveError =
|
const approveError =
|
||||||
approveTxData?.status === 'failed' ||
|
approveTxData?.status === TRANSACTION_STATUSES.FAILED ||
|
||||||
approveTxData?.txReceipt?.status === '0x0'
|
approveTxData?.txReceipt?.status === '0x0'
|
||||||
const tradeError =
|
const tradeError =
|
||||||
tradeTxData?.status === 'failed' || tradeTxData?.txReceipt?.status === '0x0'
|
tradeTxData?.status === TRANSACTION_STATUSES.FAILED ||
|
||||||
|
tradeTxData?.txReceipt?.status === '0x0'
|
||||||
const conversionError = approveError || tradeError
|
const conversionError = approveError || tradeError
|
||||||
|
|
||||||
if (conversionError) {
|
if (conversionError) {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
|
import { TRANSACTION_CATEGORIES } from '../../../../shared/constants/transaction'
|
||||||
import {
|
import {
|
||||||
unconfirmedTransactionsCountSelector,
|
unconfirmedTransactionsCountSelector,
|
||||||
sendTokenTokenAmountAndToAddressSelector,
|
sendTokenTokenAmountAndToAddressSelector,
|
||||||
@ -43,7 +44,7 @@ describe('Confirm Transaction Selector', function () {
|
|||||||
const state = {
|
const state = {
|
||||||
confirmTransaction: {
|
confirmTransaction: {
|
||||||
tokenData: {
|
tokenData: {
|
||||||
name: 'transfer',
|
name: TRANSACTION_CATEGORIES.TOKEN_METHOD_TRANSFER,
|
||||||
args: getEthersArrayLikeFromObj({
|
args: getEthersArrayLikeFromObj({
|
||||||
_to: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
|
_to: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
|
||||||
_value: { toString: () => '1' },
|
_value: { toString: () => '1' },
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { TRANSACTION_STATUSES } from '../../../../shared/constants/transaction'
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
metamask: {
|
metamask: {
|
||||||
isInitialized: true,
|
isInitialized: true,
|
||||||
@ -168,7 +170,7 @@ const state = {
|
|||||||
4768706228115573: {
|
4768706228115573: {
|
||||||
id: 4768706228115573,
|
id: 4768706228115573,
|
||||||
time: 1487363153561,
|
time: 1487363153561,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
gasMultiplier: 1,
|
gasMultiplier: 1,
|
||||||
metamaskNetworkId: '3',
|
metamaskNetworkId: '3',
|
||||||
txParams: {
|
txParams: {
|
||||||
|
@ -4,6 +4,7 @@ import {
|
|||||||
accountsWithSendEtherInfoSelector,
|
accountsWithSendEtherInfoSelector,
|
||||||
getCurrentAccountWithSendEtherInfo,
|
getCurrentAccountWithSendEtherInfo,
|
||||||
} from '..'
|
} from '..'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../../shared/constants/transaction'
|
||||||
import {
|
import {
|
||||||
getBlockGasLimit,
|
getBlockGasLimit,
|
||||||
getConversionRate,
|
getConversionRate,
|
||||||
@ -343,7 +344,7 @@ describe('send selectors', function () {
|
|||||||
4768706228115573: {
|
4768706228115573: {
|
||||||
id: 4768706228115573,
|
id: 4768706228115573,
|
||||||
time: 1487363153561,
|
time: 1487363153561,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
gasMultiplier: 1,
|
gasMultiplier: 1,
|
||||||
metamaskNetworkId: '3',
|
metamaskNetworkId: '3',
|
||||||
txParams: {
|
txParams: {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { strict as assert } from 'assert'
|
import { strict as assert } from 'assert'
|
||||||
|
import { TRANSACTION_STATUSES } from '../../../../shared/constants/transaction'
|
||||||
import {
|
import {
|
||||||
unapprovedMessagesSelector,
|
unapprovedMessagesSelector,
|
||||||
transactionsSelector,
|
transactionsSelector,
|
||||||
@ -19,7 +20,7 @@ describe('Transaction Selectors', function () {
|
|||||||
origin: 'origin',
|
origin: 'origin',
|
||||||
},
|
},
|
||||||
time: 1,
|
time: 1,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
type: 'eth_sign',
|
type: 'eth_sign',
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +47,7 @@ describe('Transaction Selectors', function () {
|
|||||||
origin: 'origin',
|
origin: 'origin',
|
||||||
},
|
},
|
||||||
time: 1,
|
time: 1,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
type: 'personal_sign',
|
type: 'personal_sign',
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +75,7 @@ describe('Transaction Selectors', function () {
|
|||||||
origin: 'origin',
|
origin: 'origin',
|
||||||
},
|
},
|
||||||
time: 1,
|
time: 1,
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
type: 'eth_signTypedData',
|
type: 'eth_signTypedData',
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +204,7 @@ describe('Transaction Selectors', function () {
|
|||||||
to: '0xRecipient',
|
to: '0xRecipient',
|
||||||
nonce: '0x0',
|
nonce: '0x0',
|
||||||
},
|
},
|
||||||
status: 'submitted',
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||||||
}
|
}
|
||||||
|
|
||||||
const unapprovedTx = {
|
const unapprovedTx = {
|
||||||
@ -214,7 +215,7 @@ describe('Transaction Selectors', function () {
|
|||||||
to: '0xRecipient',
|
to: '0xRecipient',
|
||||||
nonce: '0x1',
|
nonce: '0x1',
|
||||||
},
|
},
|
||||||
status: 'unapproved',
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||||||
}
|
}
|
||||||
|
|
||||||
const approvedTx = {
|
const approvedTx = {
|
||||||
@ -225,7 +226,7 @@ describe('Transaction Selectors', function () {
|
|||||||
to: '0xRecipient',
|
to: '0xRecipient',
|
||||||
nonce: '0x2',
|
nonce: '0x2',
|
||||||
},
|
},
|
||||||
status: 'approved',
|
status: TRANSACTION_STATUSES.APPROVED,
|
||||||
}
|
}
|
||||||
|
|
||||||
const confirmedTx = {
|
const confirmedTx = {
|
||||||
@ -236,7 +237,7 @@ describe('Transaction Selectors', function () {
|
|||||||
to: '0xRecipient',
|
to: '0xRecipient',
|
||||||
nonce: '0x3',
|
nonce: '0x3',
|
||||||
},
|
},
|
||||||
status: 'confirmed',
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||||||
}
|
}
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
|
@ -6,6 +6,7 @@ import {
|
|||||||
import { hexToDecimal } from '../helpers/utils/conversions.util'
|
import { hexToDecimal } from '../helpers/utils/conversions.util'
|
||||||
import txHelper from '../../lib/tx-helper'
|
import txHelper from '../../lib/tx-helper'
|
||||||
import {
|
import {
|
||||||
|
TRANSACTION_CATEGORIES,
|
||||||
TRANSACTION_STATUSES,
|
TRANSACTION_STATUSES,
|
||||||
TRANSACTION_TYPES,
|
TRANSACTION_TYPES,
|
||||||
} from '../../../shared/constants/transaction'
|
} from '../../../shared/constants/transaction'
|
||||||
@ -223,7 +224,10 @@ export const nonceSortedTransactionsSelector = createSelector(
|
|||||||
transactionCategory,
|
transactionCategory,
|
||||||
} = transaction
|
} = transaction
|
||||||
|
|
||||||
if (typeof nonce === 'undefined' || transactionCategory === 'incoming') {
|
if (
|
||||||
|
typeof nonce === 'undefined' ||
|
||||||
|
transactionCategory === TRANSACTION_CATEGORIES.INCOMING
|
||||||
|
) {
|
||||||
const transactionGroup = {
|
const transactionGroup = {
|
||||||
transactions: [transaction],
|
transactions: [transaction],
|
||||||
initialTransaction: transaction,
|
initialTransaction: transaction,
|
||||||
@ -232,7 +236,7 @@ export const nonceSortedTransactionsSelector = createSelector(
|
|||||||
hasCancelled: false,
|
hasCancelled: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (transactionCategory === 'incoming') {
|
if (transactionCategory === TRANSACTION_CATEGORIES.INCOMING) {
|
||||||
incomingTransactionGroups.push(transactionGroup)
|
incomingTransactionGroups.push(transactionGroup)
|
||||||
} else {
|
} else {
|
||||||
insertTransactionGroupByTime(
|
insertTransactionGroupByTime(
|
||||||
|
Loading…
Reference in New Issue
Block a user