Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
danjm committed Nov 8, 2019
1 parent 9a7cc82 commit b1bf8ba
Show file tree
Hide file tree
Showing 55 changed files with 1,615 additions and 126 deletions.
46 changes: 46 additions & 0 deletions app/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
"confirmClear": {
"message": "Are you sure you want to remove all dapp/website permissions?"
},
"connectedSites": {
"message": "Connected Sites"
},
"connectingWithMetaMask": {
"message": "Connecting With MetaMask..."
},
"connections": {
"message": "Connections"
},
Expand All @@ -29,6 +35,10 @@
"addSiteDescription": {
"message": "Manually add a site to allow it access to your accounts, useful for older dapps"
},
"chooseAnAcount": {
"message": "Choose and account"
},

"connected": {
"message": "Connected"
},
Expand Down Expand Up @@ -95,6 +105,9 @@
"reject": {
"message": "Reject"
},
"redirectingBackToDapp": {
"message": "Redirecting back to dapp..."
},
"providerRequest": {
"message": "$1 would like to connect to your account"
},
Expand Down Expand Up @@ -456,6 +469,18 @@
"details": {
"message": "Details"
},
"disconnectAccount": {
"message": "Disconnect account"
},
"disconnectAccountModalDescription": {
"message": "Are you sure? You will no longer be able to interact with this site."
},
"disconnectAccountQuestion": {
"message": "Disconnect account?"
},
"disconnectFromThisAccount": {
"message": "Disconnect from this account?"
},
"directDepositEther": {
"message": "Directly Deposit Ether"
},
Expand All @@ -465,6 +490,9 @@
"dismiss": {
"message": "Dismiss"
},
"domainLastConnect": {
"message": "Last Connected: $1"
},
"done": {
"message": "Done"
},
Expand Down Expand Up @@ -749,6 +777,9 @@
"learnMore": {
"message": "Learn more"
},
"learnAboutRisks": {
"message": "Learn about the risks here."
},
"ledgerAccountRestriction": {
"message": "You need to make use your last account before you can add a new one."
},
Expand All @@ -762,6 +793,9 @@
"likeToAddTokens": {
"message": "Would you like to add these tokens?"
},
"likeToConnect": {
"message": "$1 would like to connect to your Metamask account"
},
"links": {
"message": "Links"
},
Expand Down Expand Up @@ -890,6 +924,9 @@
"rpcUrl": {
"message": "New RPC URL"
},
"onlyConnectTrust": {
"message": "Only connect with sites you trust."
},
"optionalChainId": {
"message": "ChainID (optional)"
},
Expand Down Expand Up @@ -1094,6 +1131,9 @@
"readyToConnect": {
"message": "Ready to Connect?"
},
"revokeInPermissions": {
"message": "* You can view and revoke permissions in MetaMask settings."
},
"rinkeby": {
"message": "Rinkeby Test Network"
},
Expand Down Expand Up @@ -1337,6 +1377,9 @@
"testFaucet": {
"message": "Test Faucet"
},
"thisWillAllow": {
"message": "This will allow $1 to:"
},
"thisWillCreate": {
"message": "This will create a new wallet and seed phrase"
},
Expand All @@ -1346,6 +1389,9 @@
"to": {
"message": "To"
},
"toConnectWith": {
"message": "To connect with $1"
},
"toETHviaShapeShift": {
"message": "$1 to ETH via ShapeShift",
"description": "system will fill in deposit type in start of message"
Expand Down
3 changes: 3 additions & 0 deletions app/images/broken-line.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions app/images/icons/retweet.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 3 additions & 4 deletions app/scripts/controllers/permissions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class PermissionsController {

constructor (
{
openPopup, closePopup, notifyDomain, notifyAllDomains, keyringController,
platform, closePopup, notifyDomain, notifyAllDomains, keyringController,
} = {},
restoredPermissions = {},
restoredState = {}) {
Expand All @@ -36,9 +36,8 @@ class PermissionsController {
})
this.notifyDomain = notifyDomain
this.notifyAllDomains = notifyAllDomains
this._openPopup = openPopup
this._closePopup = closePopup
this.keyringController = keyringController
this._platform = platform
this._restrictedMethods = getRestrictedMethods(this)
this._initializePermissions(restoredPermissions)
}
Expand Down Expand Up @@ -315,7 +314,7 @@ class PermissionsController {
requestUserApproval: async (req) => {
const { metadata: { id } } = req

this._openPopup && this._openPopup()
this._platform.openExtensionInBrowser('connect')

return new Promise((resolve, reject) => {
this.pendingApprovals[id] = { resolve, reject }
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ module.exports = class MetamaskController extends EventEmitter {

this.permissionsController = new PermissionsController({
keyringController: this.keyringController,
openPopup: opts.openPopup,
platform: opts.platform,
closePopup: opts.closePopup,
notifyDomain: this.notifyConnections.bind(this),
notifyAllDomains: this.notifyAllConnections.bind(this),
Expand Down
6 changes: 6 additions & 0 deletions app/scripts/platforms/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ class ExtensionPlatform {
}
}

queryTabs (cb) {
extension.tabs.query({}, tabs => {
cb(tabs)
})
}

_showConfirmedTransaction (txMeta) {

this._subscribeToNotificationClicked()
Expand Down
21 changes: 21 additions & 0 deletions ui/app/components/app/account-menu/account-menu.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default class AccountMenu extends PureComponent {
showAccountDetail: PropTypes.func,
showRemoveAccountConfirmationModal: PropTypes.func,
toggleAccountMenu: PropTypes.func,
addressConnectedIconMap: PropTypes.object,
}

state = {
Expand Down Expand Up @@ -79,6 +80,7 @@ export default class AccountMenu extends PureComponent {
selectedAddress,
keyrings,
showAccountDetail,
addressConnectedIconMap,
} = this.props

const accountOrder = keyrings.reduce((list, keyring) => list.concat(keyring.accounts), [])
Expand All @@ -94,6 +96,8 @@ export default class AccountMenu extends PureComponent {
return kr.accounts.includes(simpleAddress) || kr.accounts.includes(identity.address)
})

const addressIconArray = addressConnectedIconMap[identity.address]

return (
<div
className="account-menu__account menu__item--clickable"
Expand Down Expand Up @@ -126,6 +130,23 @@ export default class AccountMenu extends PureComponent {
type={PRIMARY}
/>
</div>
{ addressIconArray
? <div className="account-menu__icon-list">{ addressIconArray.map((addressIcon, index) => {
return (<div className="connected-sites-list__identicon-container" style={{ zIndex: index + 1 }}>
<div className="connected-sites-list__identicon-border" />
{ addressIcon.icon
? <img
className="connected-sites-list__identicon"
src={addressIcon.icon}
/>
: <i className="connected-sites-list__identicon--default">
{addressIcon.name.charAt(0).toUpperCase()}
</i>
}
</div>)
}) }</div>
: null
}
{ this.renderKeyringType(keyring) }
{ this.renderRemoveAccount(keyring, identity) }
</div>
Expand Down
3 changes: 2 additions & 1 deletion ui/app/components/app/account-menu/account-menu.container.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
showInfoPage,
showModal,
} from '../../../store/actions'
import { getMetaMaskAccounts, getActiveTab } from '../../../selectors/selectors'
import { getMetaMaskAccounts, getActiveTab, getAddressConnectedIconMap } from '../../../selectors/selectors'
import AccountMenu from './account-menu.component'

function mapStateToProps (state) {
Expand All @@ -28,6 +28,7 @@ function mapStateToProps (state) {
isUnlocked,
keyrings,
selectedAddress,
addressConnectedIconMap: getAddressConnectedIconMap(state),
}
}

Expand Down
4 changes: 4 additions & 0 deletions ui/app/components/app/account-menu/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,8 @@
opacity: 1;
}
}

&__icon-list {
display: flex;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'

export default class ConnectedSitesList extends Component {
static contextTypes = {
t: PropTypes.func,
}

static propTypes = {
disconnectAccount: PropTypes.func.isRequired,
renderableDomains: PropTypes.arrayOf(PropTypes.shape({
name: PropTypes.string,
icon: PropTypes.string,
key: PropTypes.string,
lastConnectedTime: PropTypes.string,
permissionDescriptions: PropTypes.array,
})).isRequired,
domains: PropTypes.object.isRequired,
}

state = {
expandedDomain: '',
iconError: '',
}

handleDomainItemClick (domainKey) {
if (this.state.expandedDomain === domainKey) {
this.setState({ expandedDomain: '' })
} else {
this.setState({ expandedDomain: domainKey })
}
}

render () {
const { renderableDomains, domains, showDisconnectAccountModal } = this.props
const { expandedDomain } = this.state
const { t } = this.context

return (
<div className="connected-sites-list">
{
renderableDomains.map((domain, domainIndex) => {
const domainIsExpanded = expandedDomain === domain.key
return (
<div
className={classnames("connected-sites-list__domain", {
'connected-sites-list__domain--expanded': domainIsExpanded,
})}
key={`connected-domain-${domainIndex}`}
>
<div className="connected-sites-list__domain-item" onClick={ () => this.handleDomainItemClick(domain.key) }>
<div className="connected-sites-list__domain-item-info-container">
<div className="connected-sites-list__identicon-container">
<div className="connected-sites-list__identicon-border" />
{!this.state.iconError && domain.icon ? (
<img
className="connected-sites-list__identicon"
src={domain.icon}
onError={() => this.setState({ iconError: true })}
/>
) : (
<i className="connected-sites-list__identicon--default">
{domain.name.charAt(0).toUpperCase()}
</i>
)}
</div>
<div className="connected-sites-list__domain-info">
<div className="connected-sites-list__domain-names">
<div className="connected-sites-list__domain-name">
{ domain.name }
</div>
<div className="connected-sites-list__domain-origin">
{ domain.key }
</div>
</div>
<div className="connected-sites-list__domain-last-connected">
{ t('domainLastConnect', [domain.lastConnectedTime]) }
</div>
</div>
</div>
<div className="connected-sites-list__expand-arrow">
{ domainIsExpanded ? <i className="fa fa-chevron-left fa-sm" /> : <i className="fa fa-chevron-down fa-sm" /> }
</div>
</div>
{ domainIsExpanded
? <div className="connected-sites-list__permissions">
<div className="connected-sites-list__permission-list">
{
domain.permissionDescriptions.map((description, pdIndex) => {
return (
<div className="connected-sites-list__permission" key={`permissionDescription-${pdIndex}`}>
<i className="fa fa-check-square fa-sm" />
<div className="connected-sites-list__permission-description">
{ description }
</div>
</div>
)
})
}
</div>
<div
className="connected-sites-list__disconnect"
onClick={ () => showDisconnectAccountModal(domain.key, domains[domain.key]) }
>
{ t('disconnectAccount') }
</div>
</div>
: null
}
</div>
)
})
}
</div>
)
}
}
Loading

0 comments on commit b1bf8ba

Please sign in to comment.