mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge pull request #180 from MetaMask/PrettierTransactionList
Prettier transaction list
This commit is contained in:
commit
601d870592
@ -9,6 +9,7 @@
|
|||||||
- Restored back button to account detail view.
|
- Restored back button to account detail view.
|
||||||
- Show transaction list always, never collapsed.
|
- Show transaction list always, never collapsed.
|
||||||
- Changing provider now reloads current Dapps
|
- Changing provider now reloads current Dapps
|
||||||
|
- Improved appearance of transaction list in account detail view.
|
||||||
|
|
||||||
## 1.7.0 2016-04-29
|
## 1.7.0 2016-04-29
|
||||||
|
|
||||||
|
@ -58,7 +58,8 @@ AccountDetailScreen.prototype.render = function() {
|
|||||||
showFullAddress: true,
|
showFullAddress: true,
|
||||||
identity: identity,
|
identity: identity,
|
||||||
account: account,
|
account: account,
|
||||||
}, []),
|
key: 'accountPanel'
|
||||||
|
}),
|
||||||
|
|
||||||
h('div', {
|
h('div', {
|
||||||
style: {
|
style: {
|
||||||
|
@ -50,7 +50,7 @@ AccountsScreen.prototype.render = function() {
|
|||||||
* regardless of the current domain.
|
* regardless of the current domain.
|
||||||
*/
|
*/
|
||||||
h('.current-domain-panel.flex-center.font-small', [
|
h('.current-domain-panel.flex-center.font-small', [
|
||||||
h('spam', 'Selected address is visible to all sites you visit.'),
|
h('span', 'Selected address is visible to all sites you visit.'),
|
||||||
// h('span', state.currentDomain),
|
// h('span', state.currentDomain),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
|
@ -61,6 +61,7 @@ var actions = {
|
|||||||
signMsg: signMsg,
|
signMsg: signMsg,
|
||||||
cancelMsg: cancelMsg,
|
cancelMsg: cancelMsg,
|
||||||
sendTx: sendTx,
|
sendTx: sendTx,
|
||||||
|
signTx: signTx,
|
||||||
cancelTx: cancelTx,
|
cancelTx: cancelTx,
|
||||||
completedTx: completedTx,
|
completedTx: completedTx,
|
||||||
txError: txError,
|
txError: txError,
|
||||||
@ -165,6 +166,20 @@ function signMsg(msgData) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function signTx(txData) {
|
||||||
|
return (dispatch) => {
|
||||||
|
dispatch(this.showLoadingIndication())
|
||||||
|
|
||||||
|
web3.eth.sendTransaction(txData, (err, data) => {
|
||||||
|
dispatch(this.hideLoadingIndication())
|
||||||
|
|
||||||
|
if (err) return dispatch(this.displayWarning(err.message))
|
||||||
|
dispatch(this.hideWarning())
|
||||||
|
dispatch(this.goHome())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function sendTx(txData) {
|
function sendTx(txData) {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
_accountManager.approveTransaction(txData.id, (err) => {
|
_accountManager.approveTransaction(txData.id, (err) => {
|
||||||
|
@ -6,6 +6,8 @@ const addressSummary = require('../util').addressSummary
|
|||||||
const formatBalance = require('../util').formatBalance
|
const formatBalance = require('../util').formatBalance
|
||||||
const Identicon = require('identicon.js')
|
const Identicon = require('identicon.js')
|
||||||
|
|
||||||
|
const Panel = require('./panel')
|
||||||
|
|
||||||
module.exports = AccountPanel
|
module.exports = AccountPanel
|
||||||
|
|
||||||
|
|
||||||
@ -23,49 +25,29 @@ AccountPanel.prototype.render = function() {
|
|||||||
var identicon = new Identicon(identity.address, 46).toString()
|
var identicon = new Identicon(identity.address, 46).toString()
|
||||||
var identiconSrc = `data:image/png;base64,${identicon}`
|
var identiconSrc = `data:image/png;base64,${identicon}`
|
||||||
|
|
||||||
return (
|
var panelOpts = {
|
||||||
|
key: `accountPanel${identity.address}`,
|
||||||
h('.identity-panel.flex-row.flex-space-between'+(state.isSelected?'.selected':''), {
|
onClick: (event) => {
|
||||||
style: {
|
if (state.onShowDetail) {
|
||||||
flex: '1 0 auto',
|
state.onShowDetail(identity.address, event)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
identiconKey: identity.address,
|
||||||
|
identiconLabel: identity.name,
|
||||||
|
attributes: [
|
||||||
|
{
|
||||||
|
key: 'ADDRESS',
|
||||||
|
value: addressSummary(identity.address)
|
||||||
},
|
},
|
||||||
onClick: (event) => state.onShowDetail(identity.address, event),
|
balanceOrFaucetingIndication(account, isFauceting),
|
||||||
}, [
|
]
|
||||||
|
}
|
||||||
|
|
||||||
// account identicon
|
return h(Panel, panelOpts,
|
||||||
h('.identicon-wrapper.flex-column.select-none', [
|
!state.onShowDetail ? null : h('.arrow-right.cursor-pointer', [
|
||||||
h('img.identicon', {
|
h('i.fa.fa-chevron-right.fa-lg'),
|
||||||
src: identiconSrc,
|
]))
|
||||||
style: {
|
|
||||||
border: 'none',
|
|
||||||
borderRadius: '20px',
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
h('span.font-small', identity.name),
|
|
||||||
]),
|
|
||||||
|
|
||||||
// account address, balance
|
|
||||||
h('.identity-data.flex-column.flex-justify-center.flex-grow.select-none', [
|
|
||||||
|
|
||||||
h('.flex-row.flex-space-between', [
|
|
||||||
h('label.font-small', 'ADDRESS'),
|
|
||||||
h('span.font-small', addressSummary(identity.address)),
|
|
||||||
]),
|
|
||||||
|
|
||||||
balanceOrFaucetingIndication(account, isFauceting),
|
|
||||||
|
|
||||||
// outlet for inserting additional stuff
|
|
||||||
state.children,
|
|
||||||
|
|
||||||
]),
|
|
||||||
|
|
||||||
// navigate to account detail
|
|
||||||
!state.onShowDetail ? null :
|
|
||||||
h('.arrow-right.cursor-pointer', [
|
|
||||||
h('i.fa.fa-chevron-right.fa-lg'),
|
|
||||||
]),
|
|
||||||
])
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function balanceOrFaucetingIndication(account, isFauceting) {
|
function balanceOrFaucetingIndication(account, isFauceting) {
|
||||||
@ -73,27 +55,14 @@ function balanceOrFaucetingIndication(account, isFauceting) {
|
|||||||
// Temporarily deactivating isFauceting indication
|
// Temporarily deactivating isFauceting indication
|
||||||
// because it shows fauceting for empty restored accounts.
|
// because it shows fauceting for empty restored accounts.
|
||||||
if (/*isFauceting*/ false) {
|
if (/*isFauceting*/ false) {
|
||||||
|
return {
|
||||||
return h('.flex-row.flex-space-between', [
|
key: 'Account is auto-funding.',
|
||||||
h('span.font-small', {
|
value: 'Please wait.',
|
||||||
}, [
|
}
|
||||||
'Account is auto-funding,',
|
|
||||||
h('br'),
|
|
||||||
'please wait.'
|
|
||||||
]),
|
|
||||||
])
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
return {
|
||||||
return h('.flex-row.flex-space-between', [
|
key: 'BALANCE',
|
||||||
h('label.font-small', 'BALANCE'),
|
value: formatBalance(account.balance)
|
||||||
h('span.font-small', {
|
}
|
||||||
style: {
|
|
||||||
overflowX: 'hidden',
|
|
||||||
maxWidth: '136px',
|
|
||||||
}
|
|
||||||
}, formatBalance(account.balance)),
|
|
||||||
])
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
63
ui/app/components/panel.js
Normal file
63
ui/app/components/panel.js
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
const inherits = require('util').inherits
|
||||||
|
const ethUtil = require('ethereumjs-util')
|
||||||
|
const Component = require('react').Component
|
||||||
|
const h = require('react-hyperscript')
|
||||||
|
const Identicon = require('identicon.js')
|
||||||
|
|
||||||
|
module.exports = Panel
|
||||||
|
|
||||||
|
|
||||||
|
inherits(Panel, Component)
|
||||||
|
function Panel() {
|
||||||
|
Component.call(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
Panel.prototype.render = function() {
|
||||||
|
var state = this.props
|
||||||
|
|
||||||
|
var identity = state.identity || {}
|
||||||
|
var account = state.account || {}
|
||||||
|
var isFauceting = state.isFauceting
|
||||||
|
|
||||||
|
var identicon = new Identicon(state.identiconKey, 46).toString()
|
||||||
|
var identiconSrc = `data:image/png;base64,${identicon}`
|
||||||
|
|
||||||
|
return (
|
||||||
|
h('.identity-panel.flex-row.flex-space-between', {
|
||||||
|
style: {
|
||||||
|
flex: '1 0 auto',
|
||||||
|
},
|
||||||
|
onClick: state.onClick,
|
||||||
|
}, [
|
||||||
|
|
||||||
|
// account identicon
|
||||||
|
h('.identicon-wrapper.flex-column.select-none', [
|
||||||
|
h('img.identicon', {
|
||||||
|
src: identiconSrc,
|
||||||
|
style: {
|
||||||
|
border: 'none',
|
||||||
|
borderRadius: '20px',
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
h('span.font-small', state.identiconLabel),
|
||||||
|
]),
|
||||||
|
|
||||||
|
// account address, balance
|
||||||
|
h('.identity-data.flex-column.flex-justify-center.flex-grow.select-none', [
|
||||||
|
|
||||||
|
state.attributes.map((attr) => {
|
||||||
|
return h('.flex-row.flex-space-between', {
|
||||||
|
key: '' + Math.round(Math.random() * 1000000),
|
||||||
|
}, [
|
||||||
|
h('label.font-small', attr.key),
|
||||||
|
h('span.font-small', attr.value),
|
||||||
|
])
|
||||||
|
}),
|
||||||
|
]),
|
||||||
|
|
||||||
|
// outlet for inserting additional stuff
|
||||||
|
state.children,
|
||||||
|
])
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -2,30 +2,54 @@ const h = require('react-hyperscript')
|
|||||||
const formatBalance = require('../util').formatBalance
|
const formatBalance = require('../util').formatBalance
|
||||||
const addressSummary = require('../util').addressSummary
|
const addressSummary = require('../util').addressSummary
|
||||||
const explorerLink = require('../../lib/explorer-link')
|
const explorerLink = require('../../lib/explorer-link')
|
||||||
|
const Panel = require('./panel')
|
||||||
|
|
||||||
module.exports = function(transactions, network) {
|
module.exports = function(transactions, network) {
|
||||||
return h('.tx-list', {
|
return h('section', [
|
||||||
style: {
|
|
||||||
overflowY: 'auto',
|
h('.current-domain-panel.flex-center.font-small', [
|
||||||
height: '180px',
|
h('span', 'Transactions'),
|
||||||
textAlign: 'center',
|
]),
|
||||||
|
|
||||||
|
h('.tx-list', {
|
||||||
|
style: {
|
||||||
|
overflowY: 'auto',
|
||||||
|
height: '180px',
|
||||||
|
textAlign: 'center',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
|
|
||||||
[
|
[
|
||||||
h('div.font-small', {style: {display: 'inline'}}, 'Transactions'),
|
|
||||||
|
|
||||||
transactions.map((transaction) => {
|
transactions.map((transaction) => {
|
||||||
return h('.tx.flex-row.flex-space-around', [
|
console.dir(transaction)
|
||||||
h('a.font-small',
|
|
||||||
{
|
var panelOpts = {
|
||||||
href: explorerLink(transaction.hash, parseInt(network)),
|
key: `tx-${transaction.hash}`,
|
||||||
target: '_blank',
|
identiconKey: transaction.txParams.to,
|
||||||
},
|
style: {
|
||||||
addressSummary(transaction.txParams.to)),
|
cursor: 'pointer',
|
||||||
h('div.font-small', formatBalance(transaction.txParams.value))
|
},
|
||||||
])
|
onClick: (event) => {
|
||||||
})
|
var url = explorerLink(transaction.hash, parseInt(network))
|
||||||
]
|
chrome.tabs.create({ url });
|
||||||
)
|
},
|
||||||
}
|
attributes: [
|
||||||
|
{
|
||||||
|
key: 'TO',
|
||||||
|
value: addressSummary(transaction.txParams.to),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'VALUE',
|
||||||
|
value: formatBalance(transaction.txParams.value),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
return h(Panel, panelOpts)
|
||||||
|
})
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
])
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user