mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Add clicking txs in list shows tx conf screen
This commit is contained in:
parent
d31189b206
commit
5da6fd5ab1
@ -201,6 +201,9 @@ AccountDetailScreen.prototype.transactionList = function() {
|
|||||||
network,
|
network,
|
||||||
unconfTxs,
|
unconfTxs,
|
||||||
unconfMsgs,
|
unconfMsgs,
|
||||||
|
viewPendingTx:(txId) => {
|
||||||
|
this.props.dispatch(actions.viewPendingTx(txId))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +76,8 @@ var actions = {
|
|||||||
txError: txError,
|
txError: txError,
|
||||||
nextTx: nextTx,
|
nextTx: nextTx,
|
||||||
previousTx: previousTx,
|
previousTx: previousTx,
|
||||||
|
viewPendingTx: viewPendingTx,
|
||||||
|
VIEW_PENDING_TX: 'VIEW_PENDING_TX',
|
||||||
// app messages
|
// app messages
|
||||||
showAccountDetail: showAccountDetail,
|
showAccountDetail: showAccountDetail,
|
||||||
BACK_TO_ACCOUNT_DETAIL: 'BACK_TO_ACCOUNT_DETAIL',
|
BACK_TO_ACCOUNT_DETAIL: 'BACK_TO_ACCOUNT_DETAIL',
|
||||||
@ -387,6 +389,13 @@ function nextTx() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function viewPendingTx(txId) {
|
||||||
|
return {
|
||||||
|
type: actions.VIEW_PENDING_TX,
|
||||||
|
value: txId,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function previousTx() {
|
function previousTx() {
|
||||||
return {
|
return {
|
||||||
type: actions.PREVIOUS_TX,
|
type: actions.PREVIOUS_TX,
|
||||||
|
@ -25,6 +25,7 @@ TransactionListItem.prototype.render = function() {
|
|||||||
|
|
||||||
var isMsg = ('msgParams' in transaction)
|
var isMsg = ('msgParams' in transaction)
|
||||||
var isTx = ('txParams' in transaction)
|
var isTx = ('txParams' in transaction)
|
||||||
|
var isPending = transaction.status === 'unconfirmed'
|
||||||
|
|
||||||
let txParams
|
let txParams
|
||||||
if (isTx) {
|
if (isTx) {
|
||||||
@ -33,10 +34,16 @@ TransactionListItem.prototype.render = function() {
|
|||||||
txParams = transaction.msgParams
|
txParams = transaction.msgParams
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isClickable = ('hash' in transaction) || isPending
|
||||||
|
|
||||||
return (
|
return (
|
||||||
h(`.transaction-list-item.flex-row.flex-space-between${transaction.hash ? '.pointer' : ''}`, {
|
h(`.transaction-list-item.flex-row.flex-space-between${isClickable ? '.pointer' : ''}`, {
|
||||||
key: `tx-${transaction.id + i}`,
|
key: `tx-${transaction.id + i}`,
|
||||||
onClick: (event) => {
|
onClick: (event) => {
|
||||||
|
if (isPending) {
|
||||||
|
this.props.showTx(transaction.id)
|
||||||
|
}
|
||||||
|
|
||||||
if (!transaction.hash) return
|
if (!transaction.hash) return
|
||||||
var url = explorerLink(transaction.hash, parseInt(network))
|
var url = explorerLink(transaction.hash, parseInt(network))
|
||||||
chrome.tabs.create({ url })
|
chrome.tabs.create({ url })
|
||||||
|
@ -16,7 +16,6 @@ TransactionList.prototype.render = function() {
|
|||||||
const { txsToRender, network, unconfTxs, unconfMsgs } = this.props
|
const { txsToRender, network, unconfTxs, unconfMsgs } = this.props
|
||||||
const transactions = txsToRender.concat(unconfMsgs)
|
const transactions = txsToRender.concat(unconfMsgs)
|
||||||
.sort((a, b) => b.time - a.time)
|
.sort((a, b) => b.time - a.time)
|
||||||
console.dir(transactions)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
||||||
@ -53,7 +52,10 @@ TransactionList.prototype.render = function() {
|
|||||||
transactions.length ?
|
transactions.length ?
|
||||||
transactions.map((transaction, i) => {
|
transactions.map((transaction, i) => {
|
||||||
return h(TransactionListItem, {
|
return h(TransactionListItem, {
|
||||||
transaction, i
|
transaction, i,
|
||||||
|
showTx:(txId) => {
|
||||||
|
this.props.viewPendingTx(txId)
|
||||||
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
:
|
:
|
||||||
|
@ -12,10 +12,10 @@ function reduceApp(state, action) {
|
|||||||
const pendingTxs = hasPendingTxs(state)
|
const pendingTxs = hasPendingTxs(state)
|
||||||
let name = 'accounts'
|
let name = 'accounts'
|
||||||
if (selectedAccount) {
|
if (selectedAccount) {
|
||||||
defaultView = 'accountDetail'
|
name = 'accountDetail'
|
||||||
}
|
}
|
||||||
if (pendingTxs) {
|
if (pendingTxs) {
|
||||||
defaultView = 'confTx'
|
name = 'confTx'
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaultView = {
|
var defaultView = {
|
||||||
@ -270,6 +270,17 @@ function reduceApp(state, action) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
case actions.VIEW_PENDING_TX:
|
||||||
|
const context = indexForPending(state, action.value)
|
||||||
|
return extend(appState, {
|
||||||
|
transForward: true,
|
||||||
|
currentView: {
|
||||||
|
name: 'confTx',
|
||||||
|
context,
|
||||||
|
warning: null,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
case actions.PREVIOUS_TX:
|
case actions.PREVIOUS_TX:
|
||||||
return extend(appState, {
|
return extend(appState, {
|
||||||
transForward: false,
|
transForward: false,
|
||||||
@ -366,3 +377,16 @@ function hasPendingTxs (state) {
|
|||||||
var unconfTxList = txHelper(unconfTxs, unconfMsgs)
|
var unconfTxList = txHelper(unconfTxs, unconfMsgs)
|
||||||
return unconfTxList.length > 0
|
return unconfTxList.length > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function indexForPending(state, txId) {
|
||||||
|
var unconfTxs = state.metamask.unconfTxs
|
||||||
|
var unconfMsgs = state.metamask.unconfMsgs
|
||||||
|
var unconfTxList = txHelper(unconfTxs, unconfMsgs)
|
||||||
|
let idx
|
||||||
|
unconfTxList.forEach((tx, i) => {
|
||||||
|
if (tx.id === txId) {
|
||||||
|
idx = i
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return idx
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user