2016-04-14 00:28:44 +02:00
|
|
|
const inherits = require('util').inherits
|
2016-05-05 03:08:31 +02:00
|
|
|
const extend = require('xtend')
|
2016-04-14 00:28:44 +02:00
|
|
|
const Component = require('react').Component
|
|
|
|
const h = require('react-hyperscript')
|
|
|
|
const connect = require('react-redux').connect
|
|
|
|
const actions = require('./actions')
|
2016-05-26 02:18:04 +02:00
|
|
|
const valuesFor = require('./util').valuesFor
|
|
|
|
const TransactionList = require('./components/transaction-list')
|
2016-05-05 03:08:31 +02:00
|
|
|
const ExportAccountView = require('./components/account-export')
|
2017-04-21 04:07:09 +02:00
|
|
|
const TabBar = require('./components/tab-bar')
|
|
|
|
const TokenList = require('./components/token-list')
|
2017-06-13 02:06:39 +02:00
|
|
|
|
2016-04-14 00:28:44 +02:00
|
|
|
module.exports = connect(mapStateToProps)(AccountDetailScreen)
|
|
|
|
|
2016-06-21 22:18:32 +02:00
|
|
|
function mapStateToProps (state) {
|
2016-04-14 00:28:44 +02:00
|
|
|
return {
|
2016-08-05 21:18:44 +02:00
|
|
|
metamask: state.metamask,
|
2016-04-14 00:28:44 +02:00
|
|
|
identities: state.metamask.identities,
|
|
|
|
accounts: state.metamask.accounts,
|
2017-01-31 00:08:31 +01:00
|
|
|
address: state.metamask.selectedAddress,
|
2016-04-25 21:20:33 +02:00
|
|
|
accountDetail: state.appState.accountDetail,
|
2016-05-26 02:18:04 +02:00
|
|
|
network: state.metamask.network,
|
2017-01-28 01:11:59 +01:00
|
|
|
unapprovedMsgs: valuesFor(state.metamask.unapprovedMsgs),
|
2016-08-19 00:20:26 +02:00
|
|
|
shapeShiftTxList: state.metamask.shapeShiftTxList,
|
2017-02-01 21:57:00 +01:00
|
|
|
transactions: state.metamask.selectedAddressTxList || [],
|
2017-05-12 21:41:31 +02:00
|
|
|
conversionRate: state.metamask.conversionRate,
|
2017-05-16 20:34:53 +02:00
|
|
|
currentCurrency: state.metamask.currentCurrency,
|
2017-06-14 23:21:50 +02:00
|
|
|
currentAccountTab: state.metamask.currentAccountTab,
|
2017-06-16 01:22:53 +02:00
|
|
|
tokens: state.metamask.tokens,
|
2017-09-14 00:02:05 +02:00
|
|
|
computedBalances: state.metamask.computedBalances,
|
2016-04-14 00:28:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inherits(AccountDetailScreen, Component)
|
2016-06-21 22:18:32 +02:00
|
|
|
function AccountDetailScreen () {
|
2016-04-14 00:28:44 +02:00
|
|
|
Component.call(this)
|
|
|
|
}
|
|
|
|
|
2017-08-14 11:06:14 +02:00
|
|
|
// Note: This component is no longer used. Leaving the file for reference:
|
|
|
|
// - structuring routing for add token
|
|
|
|
// - state required for TxList
|
|
|
|
// Delete file when those features are complete
|
|
|
|
AccountDetailScreen.prototype.render = function () {}
|
2016-04-14 00:28:44 +02:00
|
|
|
|
2016-06-21 22:18:32 +02:00
|
|
|
AccountDetailScreen.prototype.subview = function () {
|
2016-05-05 03:08:31 +02:00
|
|
|
var subview
|
|
|
|
try {
|
|
|
|
subview = this.props.accountDetail.subview
|
|
|
|
} catch (e) {
|
|
|
|
subview = null
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (subview) {
|
|
|
|
case 'transactions':
|
2017-04-21 04:07:09 +02:00
|
|
|
return this.tabSections()
|
2016-05-05 03:08:31 +02:00
|
|
|
case 'export':
|
|
|
|
var state = extend({key: 'export'}, this.props)
|
|
|
|
return h(ExportAccountView, state)
|
2017-04-21 04:07:09 +02:00
|
|
|
default:
|
|
|
|
return this.tabSections()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AccountDetailScreen.prototype.tabSections = function () {
|
2017-06-14 23:21:50 +02:00
|
|
|
const { currentAccountTab } = this.props
|
|
|
|
|
2017-07-26 03:22:31 +02:00
|
|
|
return h('section.tabSection.full-flex-height.grow-tenx', [
|
2017-04-21 04:07:09 +02:00
|
|
|
|
|
|
|
h(TabBar, {
|
|
|
|
tabs: [
|
2017-06-14 03:00:06 +02:00
|
|
|
{ content: 'Sent', key: 'history' },
|
2017-04-21 04:07:09 +02:00
|
|
|
{ content: 'Tokens', key: 'tokens' },
|
|
|
|
],
|
2017-06-14 23:21:50 +02:00
|
|
|
defaultTab: currentAccountTab || 'history',
|
2017-04-21 04:07:09 +02:00
|
|
|
tabSelected: (key) => {
|
2017-06-14 23:21:50 +02:00
|
|
|
this.props.dispatch(actions.setCurrentAccountTab(key))
|
2017-04-21 04:07:09 +02:00
|
|
|
},
|
|
|
|
}),
|
|
|
|
|
|
|
|
this.tabSwitchView(),
|
|
|
|
])
|
|
|
|
}
|
|
|
|
|
|
|
|
AccountDetailScreen.prototype.tabSwitchView = function () {
|
2017-06-14 02:47:56 +02:00
|
|
|
const props = this.props
|
|
|
|
const { address, network } = props
|
2017-06-16 01:22:53 +02:00
|
|
|
const { currentAccountTab, tokens } = this.props
|
2017-04-21 04:07:09 +02:00
|
|
|
|
2017-06-14 23:21:50 +02:00
|
|
|
switch (currentAccountTab) {
|
2017-04-21 04:07:09 +02:00
|
|
|
case 'tokens':
|
2017-06-15 05:42:48 +02:00
|
|
|
return h(TokenList, {
|
|
|
|
userAddress: address,
|
|
|
|
network,
|
2017-06-16 01:22:53 +02:00
|
|
|
tokens,
|
2017-06-15 05:42:48 +02:00
|
|
|
addToken: () => this.props.dispatch(actions.showAddTokenPage()),
|
|
|
|
})
|
2016-05-05 03:08:31 +02:00
|
|
|
default:
|
|
|
|
return this.transactionList()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-21 22:18:32 +02:00
|
|
|
AccountDetailScreen.prototype.transactionList = function () {
|
2017-05-12 21:41:31 +02:00
|
|
|
const {transactions, unapprovedMsgs, address,
|
|
|
|
network, shapeShiftTxList, conversionRate } = this.props
|
2017-04-21 04:07:09 +02:00
|
|
|
|
2016-05-26 02:18:04 +02:00
|
|
|
return h(TransactionList, {
|
2017-01-13 19:44:22 +01:00
|
|
|
transactions: transactions.sort((a, b) => b.time - a.time),
|
2016-05-26 02:18:04 +02:00
|
|
|
network,
|
2017-01-28 01:11:59 +01:00
|
|
|
unapprovedMsgs,
|
2017-05-12 21:41:31 +02:00
|
|
|
conversionRate,
|
2016-08-19 01:23:12 +02:00
|
|
|
address,
|
2016-08-18 19:40:35 +02:00
|
|
|
shapeShiftTxList,
|
2016-06-21 22:18:32 +02:00
|
|
|
viewPendingTx: (txId) => {
|
2016-05-26 23:32:45 +02:00
|
|
|
this.props.dispatch(actions.viewPendingTx(txId))
|
2016-06-21 22:18:32 +02:00
|
|
|
},
|
2016-05-26 02:18:04 +02:00
|
|
|
})
|
2016-05-05 03:08:31 +02:00
|
|
|
}
|