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

Show a "LOOSE" warning on accounts not belonging to HD Seed phrase

This commit is contained in:
Dan Finlay 2016-12-22 17:17:20 -08:00
parent a10fe6b6f4
commit 1f15499046
3 changed files with 42 additions and 7 deletions

View File

@ -15,19 +15,21 @@ function AccountListItem () {
} }
AccountListItem.prototype.render = function () { AccountListItem.prototype.render = function () {
const identity = this.props.identity const { identity, selectedAccount, accounts, onShowDetail } = this.props
var isSelected = this.props.selectedAccount === identity.address
var account = this.props.accounts[identity.address] const isSelected = selectedAccount === identity.address
const account = accounts[identity.address]
const selectedClass = isSelected ? '.selected' : '' const selectedClass = isSelected ? '.selected' : ''
return ( return (
h(`.accounts-list-option.flex-row.flex-space-between.pointer.hover-white${selectedClass}`, { h(`.accounts-list-option.flex-row.flex-space-between.pointer.hover-white${selectedClass}`, {
key: `account-panel-${identity.address}`, key: `account-panel-${identity.address}`,
onClick: (event) => this.props.onShowDetail(identity.address, event), onClick: (event) => onShowDetail(identity.address, event),
}, [ }, [
h('.identicon-wrapper.flex-column.flex-center.select-none', [ h('.identicon-wrapper.flex-column.flex-center.select-none', [
this.pendingOrNot(), this.pendingOrNot(),
this.indicateIfLoose(),
h(Identicon, { h(Identicon, {
address: identity.address, address: identity.address,
imageify: true, imageify: true,
@ -70,6 +72,14 @@ AccountListItem.prototype.render = function () {
) )
} }
AccountListItem.prototype.indicateIfLoose = function () {
try { // Sometimes keyrings aren't loaded yet:
const type = this.props.keyring.type
const isLoose = type !== 'HD Key Tree'
return isLoose ? h('.pending-dot', 'LOOSE') : null
} catch (e) { return }
}
AccountListItem.prototype.pendingOrNot = function () { AccountListItem.prototype.pendingOrNot = function () {
const pending = this.props.pending const pending = this.props.pending
if (pending.length === 0) return null if (pending.length === 0) return null

View File

@ -22,6 +22,7 @@ function mapStateToProps (state) {
selectedAccount: state.metamask.selectedAccount, selectedAccount: state.metamask.selectedAccount,
scrollToBottom: state.appState.scrollToBottom, scrollToBottom: state.appState.scrollToBottom,
pending, pending,
keyrings: state.metamask.keyrings,
} }
} }
@ -31,9 +32,10 @@ function AccountsScreen () {
} }
AccountsScreen.prototype.render = function () { AccountsScreen.prototype.render = function () {
var state = this.props const props = this.props
var identityList = valuesFor(state.identities) const { keyrings } = props
var unconfTxList = valuesFor(state.unconfTxs) const identityList = valuesFor(props.identities)
const unconfTxList = valuesFor(props.unconfTxs)
return ( return (
@ -69,6 +71,11 @@ AccountsScreen.prototype.render = function () {
} }
}) })
const simpleAddress = identity.address.substring(2).toLowerCase()
const keyring = keyrings.find((kr) => {
return kr.accounts.includes(simpleAddress)
})
return h(AccountListItem, { return h(AccountListItem, {
key: `acct-panel-${identity.address}`, key: `acct-panel-${identity.address}`,
identity, identity,
@ -76,6 +83,7 @@ AccountsScreen.prototype.render = function () {
accounts: this.props.accounts, accounts: this.props.accounts,
onShowDetail: this.onShowDetail.bind(this), onShowDetail: this.onShowDetail.bind(this),
pending, pending,
keyring,
}) })
}), }),

View File

@ -196,6 +196,23 @@ hr.horizontal-line {
align-items: center; align-items: center;
justify-content: center; justify-content: center;
padding: 4px; padding: 4px;
z-index: 1;
}
.keyring-label {
z-index: 1;
font-size: 11px;
background: rgba(255,0,0,0.8);
bottom: -47px;
color: white;
border-radius: 10px;
height: 20px;
min-width: 20px;
position: relative;
display: flex;
align-items: center;
justify-content: center;
padding: 4px;
} }
.ether-balance { .ether-balance {