mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge pull request #142 from MetaMask/DetailViewFirst
Make account detail view into main view
This commit is contained in:
commit
7497b2c813
@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
## Current Master
|
## Current Master
|
||||||
|
|
||||||
|
- Account detail view is now the primary view.
|
||||||
|
- The account detail view now has a "Change acct" button which shows the account list.
|
||||||
|
- Clicking accounts in the account list now both selects that account and displays that account's detail view.
|
||||||
|
- Selected account is now persisted between sessions, so the current account stays selected.
|
||||||
|
|
||||||
# 1.6.0 2016-04-22
|
# 1.6.0 2016-04-22
|
||||||
|
|
||||||
- Pending transactions are now persisted to localStorage and resume even after browser is closed.
|
- Pending transactions are now persisted to localStorage and resume even after browser is closed.
|
||||||
|
@ -102,6 +102,17 @@ ConfigManager.prototype.setWallet = function(wallet) {
|
|||||||
this.setData(data)
|
this.setData(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConfigManager.prototype.getSelectedAccount = function() {
|
||||||
|
var config = this.getConfig()
|
||||||
|
return config.selectedAccount
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigManager.prototype.setSelectedAccount = function(address) {
|
||||||
|
var config = this.getConfig()
|
||||||
|
config.selectedAccount = address
|
||||||
|
this.setConfig(config)
|
||||||
|
}
|
||||||
|
|
||||||
ConfigManager.prototype.getWallet = function() {
|
ConfigManager.prototype.getWallet = function() {
|
||||||
return this.migrator.getData().wallet
|
return this.migrator.getData().wallet
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ const extend = require('xtend')
|
|||||||
const createId = require('web3-provider-engine/util/random-id')
|
const createId = require('web3-provider-engine/util/random-id')
|
||||||
const autoFaucet = require('./auto-faucet')
|
const autoFaucet = require('./auto-faucet')
|
||||||
const configManager = require('./config-manager-singleton')
|
const configManager = require('./config-manager-singleton')
|
||||||
const DEFAULT_RPC = 'https://rawtestrpc.metamask.io/'
|
const DEFAULT_RPC = 'https://testrpc.metamask.io/'
|
||||||
|
|
||||||
|
|
||||||
module.exports = IdentityStore
|
module.exports = IdentityStore
|
||||||
@ -72,7 +72,7 @@ IdentityStore.prototype.setStore = function(store){
|
|||||||
|
|
||||||
IdentityStore.prototype.clearSeedWordCache = function(cb) {
|
IdentityStore.prototype.clearSeedWordCache = function(cb) {
|
||||||
configManager.setShowSeedWords(false)
|
configManager.setShowSeedWords(false)
|
||||||
cb()
|
cb(null, configManager.getSelectedAccount())
|
||||||
}
|
}
|
||||||
|
|
||||||
IdentityStore.prototype.getState = function(){
|
IdentityStore.prototype.getState = function(){
|
||||||
@ -84,6 +84,7 @@ IdentityStore.prototype.getState = function(){
|
|||||||
seedWords: seedWords,
|
seedWords: seedWords,
|
||||||
unconfTxs: configManager.unconfirmedTxs(),
|
unconfTxs: configManager.unconfirmedTxs(),
|
||||||
transactions: configManager.getTxList(),
|
transactions: configManager.getTxList(),
|
||||||
|
selectedAddress: configManager.getSelectedAccount(),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +97,7 @@ IdentityStore.prototype.getSeedIfUnlocked = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IdentityStore.prototype.getSelectedAddress = function(){
|
IdentityStore.prototype.getSelectedAddress = function(){
|
||||||
return this._currentState.selectedAddress
|
return configManager.getSelectedAccount()
|
||||||
}
|
}
|
||||||
|
|
||||||
IdentityStore.prototype.setSelectedAddress = function(address){
|
IdentityStore.prototype.setSelectedAddress = function(address){
|
||||||
@ -105,7 +106,7 @@ IdentityStore.prototype.setSelectedAddress = function(address){
|
|||||||
address = addresses[0]
|
address = addresses[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
this._currentState.selectedAddress = address
|
configManager.setSelectedAccount(address)
|
||||||
this._didUpdate()
|
this._didUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +121,7 @@ IdentityStore.prototype.submitPassword = function(password, cb){
|
|||||||
if (err) return cb(err)
|
if (err) return cb(err)
|
||||||
// load identities before returning...
|
// load identities before returning...
|
||||||
this._loadIdentities()
|
this._loadIdentities()
|
||||||
cb()
|
cb(null, configManager.getSelectedAccount())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ describe('#recoverFromSeed(password, seed)', function() {
|
|||||||
|
|
||||||
// stub out account manager
|
// stub out account manager
|
||||||
actions._setAccountManager({
|
actions._setAccountManager({
|
||||||
recoverFromSeed(pw, seed, cb) { cb() },
|
recoverFromSeed(pw, seed, cb) { cb(null, [{}, {}]) },
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets metamask.isUnlocked to true', function() {
|
it('sets metamask.isUnlocked to true', function() {
|
||||||
|
@ -10,12 +10,11 @@ const transactionList = require('./components/transaction-list')
|
|||||||
module.exports = connect(mapStateToProps)(AccountDetailScreen)
|
module.exports = connect(mapStateToProps)(AccountDetailScreen)
|
||||||
|
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps(state) {
|
||||||
var accountDetail = state.appState.accountDetail
|
|
||||||
return {
|
return {
|
||||||
identities: state.metamask.identities,
|
identities: state.metamask.identities,
|
||||||
accounts: state.metamask.accounts,
|
accounts: state.metamask.accounts,
|
||||||
address: state.appState.currentView.context,
|
address: state.appState.currentView.context,
|
||||||
accountDetail: accountDetail,
|
accountDetail: state.appState.accountDetail,
|
||||||
transactions: state.metamask.transactions,
|
transactions: state.metamask.transactions,
|
||||||
networkVersion: state.networkVersion,
|
networkVersion: state.networkVersion,
|
||||||
}
|
}
|
||||||
@ -26,7 +25,6 @@ function AccountDetailScreen() {
|
|||||||
Component.call(this)
|
Component.call(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AccountDetailScreen.prototype.render = function() {
|
AccountDetailScreen.prototype.render = function() {
|
||||||
var state = this.props
|
var state = this.props
|
||||||
var identity = state.identities[state.address]
|
var identity = state.identities[state.address]
|
||||||
@ -40,9 +38,6 @@ AccountDetailScreen.prototype.render = function() {
|
|||||||
|
|
||||||
// subtitle and nav
|
// subtitle and nav
|
||||||
h('.section-title.flex-row.flex-center', [
|
h('.section-title.flex-row.flex-center', [
|
||||||
h('i.fa.fa-arrow-left.fa-lg.cursor-pointer', {
|
|
||||||
onClick: this.navigateToAccounts.bind(this),
|
|
||||||
}),
|
|
||||||
h('h2.page-subtitle', 'Account Detail'),
|
h('h2.page-subtitle', 'Account Detail'),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
@ -51,28 +46,35 @@ AccountDetailScreen.prototype.render = function() {
|
|||||||
showFullAddress: true,
|
showFullAddress: true,
|
||||||
identity: identity,
|
identity: identity,
|
||||||
account: account,
|
account: account,
|
||||||
|
}, []),
|
||||||
|
|
||||||
|
h('div', {
|
||||||
|
style: {
|
||||||
|
display: 'flex',
|
||||||
|
}
|
||||||
}, [
|
}, [
|
||||||
h('.flex-row.flex-space-around', [
|
|
||||||
// h('button', 'GET ETH'), DISABLED UNTIL WORKING
|
|
||||||
|
|
||||||
h('button', {
|
h('button', {
|
||||||
onClick: () => {
|
onClick: this.navigateToAccounts.bind(this),
|
||||||
copyToClipboard(identity.address)
|
}, 'CHANGE ACCT'),
|
||||||
},
|
|
||||||
}, 'COPY ADDR'),
|
|
||||||
|
|
||||||
h('button', {
|
h('button', {
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
this.props.dispatch(actions.showSendPage())
|
copyToClipboard(identity.address)
|
||||||
},
|
},
|
||||||
}, 'SEND'),
|
}, 'COPY ADDR'),
|
||||||
|
|
||||||
h('button', {
|
h('button', {
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
this.requestAccountExport(identity.address)
|
this.props.dispatch(actions.showSendPage())
|
||||||
},
|
},
|
||||||
}, 'EXPORT'),
|
}, 'SEND'),
|
||||||
]),
|
|
||||||
|
h('button', {
|
||||||
|
onClick: () => {
|
||||||
|
this.requestAccountExport(identity.address)
|
||||||
|
},
|
||||||
|
}, 'EXPORT'),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
transactionList(transactions
|
transactionList(transactions
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
var actions = {
|
var actions = {
|
||||||
|
GO_HOME: 'GO_HOME',
|
||||||
|
goHome: goHome,
|
||||||
// remote state
|
// remote state
|
||||||
UPDATE_METAMASK_STATE: 'UPDATE_METAMASK_STATE',
|
UPDATE_METAMASK_STATE: 'UPDATE_METAMASK_STATE',
|
||||||
updateMetamaskState: updateMetamaskState,
|
updateMetamaskState: updateMetamaskState,
|
||||||
@ -87,24 +89,29 @@ var actions = {
|
|||||||
|
|
||||||
module.exports = actions
|
module.exports = actions
|
||||||
|
|
||||||
|
|
||||||
var _accountManager = null
|
var _accountManager = null
|
||||||
function _setAccountManager(accountManager){
|
function _setAccountManager(accountManager){
|
||||||
_accountManager = accountManager
|
_accountManager = accountManager
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function goHome() {
|
||||||
|
return {
|
||||||
|
type: this.GO_HOME,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// async actions
|
// async actions
|
||||||
|
|
||||||
function tryUnlockMetamask(password) {
|
function tryUnlockMetamask(password) {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
dispatch(this.unlockInProgress())
|
dispatch(this.unlockInProgress())
|
||||||
_accountManager.submitPassword(password, (err) => {
|
_accountManager.submitPassword(password, (err, selectedAccount) => {
|
||||||
dispatch(this.hideLoadingIndication())
|
dispatch(this.hideLoadingIndication())
|
||||||
if (err) {
|
if (err) {
|
||||||
dispatch(this.unlockFailed())
|
dispatch(this.unlockFailed())
|
||||||
} else {
|
} else {
|
||||||
dispatch(this.unlockMetamask())
|
dispatch(this.unlockMetamask())
|
||||||
dispatch(this.setSelectedAddress())
|
dispatch(this.showAccountDetail(selectedAccount))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -123,7 +130,7 @@ function recoverFromSeed(password, seed) {
|
|||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
// dispatch(this.createNewVaultInProgress())
|
// dispatch(this.createNewVaultInProgress())
|
||||||
dispatch(this.showLoadingIndication())
|
dispatch(this.showLoadingIndication())
|
||||||
_accountManager.recoverFromSeed(password, seed, (err, result) => {
|
_accountManager.recoverFromSeed(password, seed, (err, selectedAccount) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
dispatch(this.hideLoadingIndication())
|
dispatch(this.hideLoadingIndication())
|
||||||
var message = err.message
|
var message = err.message
|
||||||
@ -131,11 +138,9 @@ function recoverFromSeed(password, seed) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dispatch(this.unlockMetamask())
|
dispatch(this.unlockMetamask())
|
||||||
dispatch(this.setSelectedAddress())
|
dispatch(this.showAccountDetail(selectedAccount))
|
||||||
dispatch(this.updateMetamaskState(result))
|
|
||||||
dispatch(this.hideLoadingIndication())
|
dispatch(this.hideLoadingIndication())
|
||||||
dispatch(this.showAccountsPage())
|
})
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,9 +281,13 @@ function lockMetamask() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function showAccountDetail(address) {
|
function showAccountDetail(address) {
|
||||||
return {
|
return (dispatch) => {
|
||||||
type: this.SHOW_ACCOUNT_DETAIL,
|
_accountManager.setSelectedAddress(address)
|
||||||
value: address,
|
|
||||||
|
dispatch({
|
||||||
|
type: this.SHOW_ACCOUNT_DETAIL,
|
||||||
|
value: address,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,10 +306,10 @@ function clearSeedWordCache() {
|
|||||||
function confirmSeedWords() {
|
function confirmSeedWords() {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
dispatch(this.showLoadingIndication())
|
dispatch(this.showLoadingIndication())
|
||||||
_accountManager.clearSeedWordCache((err) => {
|
_accountManager.clearSeedWordCache((err, accounts) => {
|
||||||
dispatch(this.clearSeedWordCache())
|
dispatch(this.clearSeedWordCache())
|
||||||
console.log('Seed word cache cleared.')
|
console.log('Seed word cache cleared.')
|
||||||
dispatch(this.setSelectedAddress())
|
dispatch(this.showAccountDetail(accounts[0].address))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ AccountPanel.prototype.render = function() {
|
|||||||
style: {
|
style: {
|
||||||
flex: '1 0 auto',
|
flex: '1 0 auto',
|
||||||
},
|
},
|
||||||
onClick: state.onSelect && state.onSelect.bind(null, identity.address),
|
onClick: (event) => state.onShowDetail(identity.address, event),
|
||||||
}, [
|
}, [
|
||||||
|
|
||||||
// account identicon
|
// account identicon
|
||||||
@ -53,9 +53,7 @@ AccountPanel.prototype.render = function() {
|
|||||||
|
|
||||||
// navigate to account detail
|
// navigate to account detail
|
||||||
!state.onShowDetail ? null :
|
!state.onShowDetail ? null :
|
||||||
h('.arrow-right.cursor-pointer', {
|
h('.arrow-right.cursor-pointer', [
|
||||||
onClick: state.onShowDetail && state.onShowDetail.bind(null, identity.address),
|
|
||||||
}, [
|
|
||||||
h('i.fa.fa-chevron-right.fa-lg'),
|
h('i.fa.fa-chevron-right.fa-lg'),
|
||||||
]),
|
]),
|
||||||
])
|
])
|
||||||
|
@ -31,7 +31,7 @@ ConfigScreen.prototype.render = function() {
|
|||||||
h('.section-title.flex-row.flex-center', [
|
h('.section-title.flex-row.flex-center', [
|
||||||
h('i.fa.fa-arrow-left.fa-lg.cursor-pointer', {
|
h('i.fa.fa-arrow-left.fa-lg.cursor-pointer', {
|
||||||
onClick: (event) => {
|
onClick: (event) => {
|
||||||
state.dispatch(actions.showAccountsPage())
|
state.dispatch(actions.goHome())
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
h('h2.page-subtitle', 'Configuration'),
|
h('h2.page-subtitle', 'Configuration'),
|
||||||
|
@ -26,7 +26,7 @@ InfoScreen.prototype.render = function() {
|
|||||||
h('.section-title.flex-row.flex-center', [
|
h('.section-title.flex-row.flex-center', [
|
||||||
h('i.fa.fa-arrow-left.fa-lg.cursor-pointer', {
|
h('i.fa.fa-arrow-left.fa-lg.cursor-pointer', {
|
||||||
onClick: (event) => {
|
onClick: (event) => {
|
||||||
state.dispatch(actions.showAccountsPage())
|
state.dispatch(actions.goHome())
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
h('h2.page-subtitle', 'Info'),
|
h('h2.page-subtitle', 'Info'),
|
||||||
|
@ -19,7 +19,6 @@ function LoadingIndicator() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LoadingIndicator.prototype.render = function() {
|
LoadingIndicator.prototype.render = function() {
|
||||||
console.dir(this.props)
|
|
||||||
var isLoading = this.props.isLoading
|
var isLoading = this.props.isLoading
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -44,7 +43,6 @@ LoadingIndicator.prototype.render = function() {
|
|||||||
src: 'images/loading.svg',
|
src: 'images/loading.svg',
|
||||||
}),
|
}),
|
||||||
]) : null,
|
]) : null,
|
||||||
|
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
const extend = require('xtend')
|
const extend = require('xtend')
|
||||||
const actions = require('../actions')
|
const actions = require('../actions')
|
||||||
|
const valuesFor = require('../util').valuesFor
|
||||||
|
|
||||||
module.exports = reduceApp
|
module.exports = reduceApp
|
||||||
|
|
||||||
@ -7,8 +8,9 @@ function reduceApp(state, action) {
|
|||||||
|
|
||||||
// clone and defaults
|
// clone and defaults
|
||||||
var defaultView = {
|
var defaultView = {
|
||||||
name: 'accounts',
|
name: 'accountDetail',
|
||||||
detailView: null,
|
detailView: null,
|
||||||
|
context: state.metamask.selectedAccount,
|
||||||
}
|
}
|
||||||
|
|
||||||
// confirm seed words
|
// confirm seed words
|
||||||
@ -56,6 +58,7 @@ function reduceApp(state, action) {
|
|||||||
return extend(appState, {
|
return extend(appState, {
|
||||||
currentView: {
|
currentView: {
|
||||||
name: 'config',
|
name: 'config',
|
||||||
|
context: appState.currentView.context,
|
||||||
},
|
},
|
||||||
transForward: true,
|
transForward: true,
|
||||||
})
|
})
|
||||||
@ -64,6 +67,7 @@ function reduceApp(state, action) {
|
|||||||
return extend(appState, {
|
return extend(appState, {
|
||||||
currentView: {
|
currentView: {
|
||||||
name: 'info',
|
name: 'info',
|
||||||
|
context: appState.currentView.context,
|
||||||
},
|
},
|
||||||
transForward: true,
|
transForward: true,
|
||||||
})
|
})
|
||||||
@ -120,11 +124,24 @@ function reduceApp(state, action) {
|
|||||||
activeAddress: action.value,
|
activeAddress: action.value,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
case actions.GO_HOME:
|
||||||
|
return extend(appState, {
|
||||||
|
currentView: {
|
||||||
|
name: 'accountDetail',
|
||||||
|
context: appState.currentView.context,
|
||||||
|
},
|
||||||
|
accountDetail: {
|
||||||
|
accountExport: 'none',
|
||||||
|
privateKey: '',
|
||||||
|
},
|
||||||
|
transForward: false,
|
||||||
|
})
|
||||||
|
|
||||||
case actions.SHOW_ACCOUNT_DETAIL:
|
case actions.SHOW_ACCOUNT_DETAIL:
|
||||||
return extend(appState, {
|
return extend(appState, {
|
||||||
currentView: {
|
currentView: {
|
||||||
name: 'accountDetail',
|
name: 'accountDetail',
|
||||||
context: action.value,
|
context: action.value || account,
|
||||||
},
|
},
|
||||||
accountDetail: {
|
accountDetail: {
|
||||||
accountExport: 'none',
|
accountExport: 'none',
|
||||||
|
Loading…
Reference in New Issue
Block a user