1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/ui/app/components/transaction-list.js

77 lines
1.7 KiB
JavaScript
Raw Normal View History

const h = require('react-hyperscript')
2016-05-14 02:02:33 +02:00
const vreme = new (require('vreme'))
2016-04-20 02:31:34 +02:00
const formatBalance = require('../util').formatBalance
const addressSummary = require('../util').addressSummary
const explorerLink = require('../../lib/explorer-link')
const Panel = require('./panel')
module.exports = function(transactions, network) {
return (
h('section.transaction-list', [
h('h3.flex-center.text-transform-uppercase', {
style: {
background: '#EBEBEB',
2016-05-14 02:02:33 +02:00
color: '#AEAEAE',
},
}, [
'Transactions',
]),
h('.tx-list', {
style: {
overflowY: 'auto',
height: '204px',
padding: '0 20px',
textAlign: 'center',
},
}, (
transactions.length ?
transactions.map(renderTransaction)
:
[h('.flex-center', {
style: {
height: '100%',
},
}, 'No transaction history...')]
))
])
)
}
function renderTransaction(transaction){
2016-05-14 02:02:33 +02:00
var panelOpts = {
key: `tx-${transaction.hash}`,
identiconKey: transaction.txParams.to,
onClick: (event) => {
var url = explorerLink(transaction.hash, parseInt(network))
chrome.tabs.create({ url })
},
attributes: [
2016-05-14 02:02:33 +02:00
{
key: 'TIME',
value: formatDate(transaction.time),
},
{
key: 'TO',
value: addressSummary(transaction.txParams.to),
},
{
key: 'VALUE',
value: formatBalance(transaction.txParams.value),
},
]
}
return h(Panel, panelOpts)
2016-05-14 02:02:33 +02:00
}
function formatDate(date){
return vreme.format(new Date(date), 'March 16 2014 14:30')
}