2017-08-01 06:16:07 +02:00
|
|
|
const Component = require('react').Component
|
|
|
|
const connect = require('react-redux').connect
|
|
|
|
const h = require('react-hyperscript')
|
2017-08-08 10:49:45 +02:00
|
|
|
const ethUtil = require('ethereumjs-util')
|
2017-08-01 06:16:07 +02:00
|
|
|
const inherits = require('util').inherits
|
2017-08-02 22:32:02 +02:00
|
|
|
const actions = require('../actions')
|
|
|
|
// slideout menu
|
|
|
|
const WalletView = require('./wallet-view')
|
|
|
|
|
2017-08-08 10:49:45 +02:00
|
|
|
// balance component
|
|
|
|
const BalanceComponent = require('./balance-component')
|
|
|
|
|
2017-08-06 23:55:28 +02:00
|
|
|
const Identicon = require('./identicon')
|
2017-08-01 06:16:07 +02:00
|
|
|
// const AccountDropdowns = require('./account-dropdowns').AccountDropdowns
|
|
|
|
// const Content = require('./wallet-content-display')
|
|
|
|
|
2017-08-02 22:32:02 +02:00
|
|
|
module.exports = connect(mapStateToProps, mapDispatchToProps)(TxView)
|
|
|
|
|
|
|
|
function mapStateToProps (state) {
|
|
|
|
return {
|
|
|
|
sidebarOpen: state.appState.sidebarOpen,
|
2017-08-08 10:49:45 +02:00
|
|
|
identities: state.metamask.identities,
|
|
|
|
accounts: state.metamask.accounts,
|
|
|
|
address: state.metamask.selectedAddress,
|
|
|
|
conversionRate: state.metamask.conversionRate,
|
|
|
|
currentCurrency: state.metamask.currentCurrency,
|
2017-08-02 22:32:02 +02:00
|
|
|
}
|
|
|
|
}
|
2017-08-01 06:16:07 +02:00
|
|
|
|
2017-08-02 22:32:02 +02:00
|
|
|
function mapDispatchToProps (dispatch) {
|
|
|
|
return {
|
2017-08-08 10:49:45 +02:00
|
|
|
showSidebar: () => { dispatch(actions.showSidebar()) },
|
|
|
|
hideSidebar: () => { dispatch(actions.hideSidebar()) },
|
2017-08-08 22:37:52 +02:00
|
|
|
showModal: () => { dispatch(actions.showModal()) },
|
2017-08-02 22:32:02 +02:00
|
|
|
}
|
|
|
|
}
|
2017-08-01 06:34:37 +02:00
|
|
|
|
2017-08-01 06:27:37 +02:00
|
|
|
const contentDivider = h('div', {
|
|
|
|
style: {
|
|
|
|
marginLeft: '1.3em',
|
|
|
|
marginRight: '1.3em',
|
|
|
|
height:'1px',
|
|
|
|
background:'#E7E7E7', // TODO: make custom color
|
|
|
|
},
|
|
|
|
})
|
2017-08-01 06:16:07 +02:00
|
|
|
|
|
|
|
inherits(TxView, Component)
|
|
|
|
function TxView () {
|
|
|
|
Component.call(this)
|
|
|
|
}
|
|
|
|
|
|
|
|
TxView.prototype.render = function () {
|
2017-08-08 10:49:45 +02:00
|
|
|
|
|
|
|
var props = this.props
|
|
|
|
var selected = props.address || Object.keys(props.accounts)[0]
|
|
|
|
var checksumAddress = selected && ethUtil.toChecksumAddress(selected)
|
|
|
|
var identity = props.identities[selected]
|
|
|
|
var account = props.accounts[selected]
|
|
|
|
const { conversionRate, currentCurrency } = props
|
2017-08-06 23:55:28 +02:00
|
|
|
|
2017-08-01 06:16:07 +02:00
|
|
|
return h('div.tx-view.flex-column', {
|
2017-08-07 05:47:59 +02:00
|
|
|
style: {},
|
2017-08-01 06:16:07 +02:00
|
|
|
}, [
|
2017-08-06 23:55:28 +02:00
|
|
|
|
|
|
|
h('div.flex-row.phone-visible', {
|
|
|
|
style: {
|
|
|
|
margin: '1em 0.9em',
|
|
|
|
alignItems: 'center'
|
2017-08-07 04:29:51 +02:00
|
|
|
},
|
|
|
|
onClick: () => {
|
|
|
|
this.props.sidebarOpen ? this.props.hideSidebar() : this.props.showSidebar()
|
|
|
|
},
|
2017-08-02 23:17:58 +02:00
|
|
|
}, [
|
2017-08-06 23:55:28 +02:00
|
|
|
// burger
|
|
|
|
h('div.fa.fa-bars', {
|
|
|
|
style: {
|
|
|
|
fontSize: '1.3em',
|
|
|
|
},
|
|
|
|
}, []),
|
|
|
|
|
2017-08-08 10:49:45 +02:00
|
|
|
// account display
|
2017-08-06 23:55:28 +02:00
|
|
|
h('.identicon-wrapper.select-none', {
|
|
|
|
style: {
|
|
|
|
marginLeft: '0.9em',
|
|
|
|
},
|
|
|
|
}, [
|
|
|
|
h(Identicon, {
|
|
|
|
diameter: 24,
|
|
|
|
address: selected,
|
|
|
|
}),
|
|
|
|
]),
|
|
|
|
|
2017-08-07 04:26:52 +02:00
|
|
|
h('span.account-name', {
|
2017-08-08 10:49:45 +02:00
|
|
|
style: {},
|
2017-08-06 23:55:28 +02:00
|
|
|
}, [
|
2017-08-08 10:49:45 +02:00
|
|
|
identity.name,
|
2017-08-06 23:55:28 +02:00
|
|
|
]),
|
|
|
|
|
2017-08-02 23:17:58 +02:00
|
|
|
]),
|
2017-08-02 21:29:07 +02:00
|
|
|
|
2017-08-07 00:46:55 +02:00
|
|
|
// laptop: flex-row, flex-center
|
|
|
|
// mobile: flex-column
|
|
|
|
h('div.hero-balance', {
|
|
|
|
style: {},
|
2017-08-03 09:43:24 +02:00
|
|
|
}, [
|
|
|
|
|
2017-08-08 10:49:45 +02:00
|
|
|
h(BalanceComponent, {
|
|
|
|
balanceValue: account && account.balance,
|
|
|
|
conversionRate,
|
|
|
|
currentCurrency,
|
|
|
|
style: {},
|
2017-08-07 00:46:55 +02:00
|
|
|
}),
|
|
|
|
|
|
|
|
// laptop: 10vw?
|
|
|
|
// phone: 75vw?
|
|
|
|
h('div.flex-row.flex-center.hero-balance-buttons', {
|
|
|
|
style: {}
|
|
|
|
}, [
|
|
|
|
h('button.btn-clear', {
|
2017-08-03 10:17:27 +02:00
|
|
|
style: {
|
2017-08-07 00:46:55 +02:00
|
|
|
textAlign: 'center',
|
|
|
|
},
|
2017-08-08 22:37:52 +02:00
|
|
|
onClick: () => {
|
|
|
|
this.props.showModal()
|
|
|
|
},
|
2017-08-07 00:46:55 +02:00
|
|
|
}, 'BUY'),
|
2017-08-03 09:43:24 +02:00
|
|
|
|
2017-08-07 00:46:55 +02:00
|
|
|
h('button.btn-clear', {
|
|
|
|
style: {
|
|
|
|
textAlign: 'center',
|
|
|
|
marginLeft: '1.4em',
|
|
|
|
},
|
|
|
|
}, 'SEND'),
|
2017-08-03 10:17:27 +02:00
|
|
|
|
2017-08-07 00:46:55 +02:00
|
|
|
]),
|
2017-08-03 09:43:24 +02:00
|
|
|
]),
|
|
|
|
|
2017-08-01 06:16:07 +02:00
|
|
|
h('div.flex-row', {
|
2017-08-01 06:27:37 +02:00
|
|
|
style: {
|
2017-08-06 23:55:28 +02:00
|
|
|
margin: '1.8em 0.9em 0.8em 0.9em',
|
2017-08-01 06:27:37 +02:00
|
|
|
}
|
2017-08-01 06:16:07 +02:00
|
|
|
}, [
|
|
|
|
|
2017-08-01 06:27:37 +02:00
|
|
|
// tx-view-tab.js
|
|
|
|
h('div.flex-row', {
|
2017-08-01 06:16:07 +02:00
|
|
|
}, [
|
2017-08-01 06:27:37 +02:00
|
|
|
|
2017-08-01 06:16:07 +02:00
|
|
|
h('div', {
|
|
|
|
style: {
|
2017-08-01 06:27:37 +02:00
|
|
|
borderBottom: '0.07em solid black',
|
|
|
|
paddingBottom: '0.015em',
|
2017-08-01 06:16:07 +02:00
|
|
|
}
|
2017-08-01 06:27:37 +02:00
|
|
|
}, 'TRANSACTIONS'),
|
|
|
|
|
|
|
|
h('div', {
|
|
|
|
style: {
|
2017-08-01 06:34:37 +02:00
|
|
|
marginLeft: '1.25em',
|
2017-08-01 06:27:37 +02:00
|
|
|
}
|
|
|
|
}, 'TOKENS'),
|
2017-08-01 06:16:07 +02:00
|
|
|
|
2017-08-01 06:27:37 +02:00
|
|
|
]),
|
2017-08-01 06:34:37 +02:00
|
|
|
]),
|
|
|
|
|
|
|
|
contentDivider,
|
2017-08-01 06:27:37 +02:00
|
|
|
|
2017-08-01 07:00:18 +02:00
|
|
|
this.renderTransactionListItem(),
|
|
|
|
|
|
|
|
contentDivider,
|
|
|
|
|
|
|
|
this.renderTransactionListItem(),
|
|
|
|
|
|
|
|
contentDivider,
|
|
|
|
|
2017-08-01 06:16:07 +02:00
|
|
|
])
|
|
|
|
// column
|
|
|
|
// tab row
|
|
|
|
// divider
|
|
|
|
// item
|
|
|
|
}
|
2017-08-01 07:00:18 +02:00
|
|
|
|
|
|
|
TxView.prototype.renderTransactionListItem = function () {
|
|
|
|
return h('div.flex-column', {
|
|
|
|
style: {
|
|
|
|
alignItems: 'stretch',
|
|
|
|
margin: '0.6em 1.3em 0.6em 1.3em',
|
|
|
|
}
|
|
|
|
}, [
|
|
|
|
|
|
|
|
h('div', {
|
|
|
|
style: {
|
|
|
|
flexGrow: 1,
|
|
|
|
marginTop: '0.3em',
|
|
|
|
}
|
|
|
|
}, 'Jul 01, 2017'),
|
|
|
|
|
|
|
|
h('div.flex-row', {
|
|
|
|
style: {
|
|
|
|
alignItems: 'stretch',
|
|
|
|
}
|
|
|
|
}, [
|
|
|
|
|
|
|
|
h('div', {
|
|
|
|
style: {
|
|
|
|
flexGrow: 1,
|
|
|
|
}
|
|
|
|
}, 'icon'),
|
|
|
|
|
|
|
|
h('div', {
|
|
|
|
style: {
|
|
|
|
flexGrow: 3,
|
|
|
|
}
|
|
|
|
}, 'Hash'),
|
|
|
|
|
|
|
|
h('div', {
|
|
|
|
style: {
|
|
|
|
flexGrow: 5,
|
|
|
|
}
|
|
|
|
}, 'Status'),
|
|
|
|
|
|
|
|
h('div', {
|
|
|
|
style: {
|
|
|
|
flexGrow: 2,
|
|
|
|
}
|
|
|
|
}, 'Details'),
|
|
|
|
|
|
|
|
])
|
|
|
|
|
|
|
|
])
|
|
|
|
}
|
|
|
|
|
|
|
|
|