diff --git a/app/scripts/ui.js b/app/scripts/ui.js index eabc1d37f..e01ec24ef 100644 --- a/app/scripts/ui.js +++ b/app/scripts/ui.js @@ -1,6 +1,5 @@ const injectCss = require('inject-css') const OldMetaMaskUiCss = require('../../old-ui/css') -const NewMetaMaskUiCss = require('../../ui/css') const startPopup = require('./popup-core') const PortStream = require('extension-port-stream') const { getEnvironmentType } = require('./lib/util') @@ -45,25 +44,17 @@ async function start () { // const { isMascara, identities = {}, featureFlags = {} } = store.getState().metamask // const firstTime = Object.keys(identities).length === 0 const { isMascara, featureFlags = {} } = store.getState().metamask - let betaUIState = featureFlags.betaUI // Code commented out until we begin auto adding users to NewUI - // const useBetaCss = isMascara || firstTime || betaUIState - const useBetaCss = isMascara || betaUIState - let css = useBetaCss ? NewMetaMaskUiCss() : OldMetaMaskUiCss() + let css = OldMetaMaskUiCss() let deleteInjectedCss = injectCss(css) - let newBetaUIState store.subscribe(() => { const state = store.getState() - newBetaUIState = state.metamask.featureFlags.betaUI - if (newBetaUIState !== betaUIState) { - deleteInjectedCss() - betaUIState = newBetaUIState - css = betaUIState ? NewMetaMaskUiCss() : OldMetaMaskUiCss() - deleteInjectedCss = injectCss(css) - } + deleteInjectedCss() + css = OldMetaMaskUiCss() + deleteInjectedCss = injectCss(css) }) }) diff --git a/ui/app/accounts/new-account/index.js b/ui/app/accounts/new-account/index.js deleted file mode 100644 index 795bd7ce6..000000000 --- a/ui/app/accounts/new-account/index.js +++ /dev/null @@ -1,87 +0,0 @@ -const Component = require('react').Component -const h = require('react-hyperscript') -const PropTypes = require('prop-types') -const inherits = require('util').inherits -const connect = require('react-redux').connect -const actions = require('../../actions') -const { getCurrentViewContext } = require('../../selectors') -const classnames = require('classnames') - -const NewAccountCreateForm = require('./create-form') -const NewAccountImportForm = require('../import') - -function mapStateToProps (state) { - return { - displayedForm: getCurrentViewContext(state), - } -} - -function mapDispatchToProps (dispatch) { - return { - displayForm: form => dispatch(actions.setNewAccountForm(form)), - showQrView: (selected, identity) => dispatch(actions.showQrView(selected, identity)), - showExportPrivateKeyModal: () => { - dispatch(actions.showModal({ name: 'EXPORT_PRIVATE_KEY' })) - }, - hideModal: () => dispatch(actions.hideModal()), - setAccountLabel: (address, label) => dispatch(actions.setAccountLabel(address, label)), - } -} - -inherits(AccountDetailsModal, Component) -function AccountDetailsModal (props) { - Component.call(this) - - this.state = { - displayedForm: props.displayedForm, - } -} - -AccountDetailsModal.contextTypes = { - t: PropTypes.func, -} - -module.exports = connect(mapStateToProps, mapDispatchToProps)(AccountDetailsModal) - - -AccountDetailsModal.prototype.render = function () { - const { displayedForm, displayForm } = this.props - - return h('div.new-account', {}, [ - - h('div.new-account__header', [ - - h('div.new-account__title', this.context.t('newAccount')), - - h('div.new-account__tabs', [ - - h('div.new-account__tabs__tab', { - className: classnames('new-account__tabs__tab', { - 'new-account__tabs__selected': displayedForm === 'CREATE', - 'new-account__tabs__unselected cursor-pointer': displayedForm !== 'CREATE', - }), - onClick: () => displayForm('CREATE'), - }, this.context.t('createDen')), - - h('div.new-account__tabs__tab', { - className: classnames('new-account__tabs__tab', { - 'new-account__tabs__selected': displayedForm === 'IMPORT', - 'new-account__tabs__unselected cursor-pointer': displayedForm !== 'IMPORT', - }), - onClick: () => displayForm('IMPORT'), - }, this.context.t('import')), - - ]), - - ]), - - h('div.new-account__form', [ - - displayedForm === 'CREATE' - ? h(NewAccountCreateForm) - : h(NewAccountImportForm), - - ]), - - ]) -} diff --git a/ui/app/app.js b/ui/app/app.js deleted file mode 100644 index c9ef197fc..000000000 --- a/ui/app/app.js +++ /dev/null @@ -1,365 +0,0 @@ -const { Component } = require('react') -const PropTypes = require('prop-types') -const connect = require('react-redux').connect -const { Route, Switch, withRouter } = require('react-router-dom') -const { compose } = require('recompose') -const h = require('react-hyperscript') -const actions = require('./actions') -const classnames = require('classnames') -const log = require('loglevel') -const { getMetaMaskAccounts } = require('./selectors') - -// init -const InitializeScreen = require('../../mascara/src/app/first-time').default -// accounts -const SendTransactionScreen = require('./components/send/send.container') -const ConfirmTransaction = require('./components/pages/confirm-transaction') - -// slideout menu -const Sidebar = require('./components/sidebars').default - -// other views -import Home from './components/pages/home' -import Settings from './components/pages/settings' -const Authenticated = require('./components/pages/authenticated') -const Initialized = require('./components/pages/initialized') -const RestoreVaultPage = require('./components/pages/keychains/restore-vault').default -const RevealSeedConfirmation = require('./components/pages/keychains/reveal-seed') -const AddTokenPage = require('./components/pages/add-token') -const ConfirmAddTokenPage = require('./components/pages/confirm-add-token') -const ConfirmAddSuggestedTokenPage = require('./components/pages/confirm-add-suggested-token') -const CreateAccountPage = require('./components/pages/create-account') -const NoticeScreen = require('./components/pages/notice') - -const Loading = require('./components/loading-screen') -const NetworkDropdown = require('./components/dropdowns/network-dropdown') -const AccountMenu = require('./components/account-menu') - -// Global Modals -const Modal = require('./components/modals/index').Modal -// Global Alert -const Alert = require('./components/alert') - -import AppHeader from './components/app-header' -import UnlockPage from './components/pages/unlock-page' - -// Routes -const { - DEFAULT_ROUTE, - UNLOCK_ROUTE, - SETTINGS_ROUTE, - REVEAL_SEED_ROUTE, - RESTORE_VAULT_ROUTE, - ADD_TOKEN_ROUTE, - CONFIRM_ADD_TOKEN_ROUTE, - CONFIRM_ADD_SUGGESTED_TOKEN_ROUTE, - NEW_ACCOUNT_ROUTE, - SEND_ROUTE, - CONFIRM_TRANSACTION_ROUTE, - INITIALIZE_ROUTE, - NOTICE_ROUTE, -} = require('./routes') - -class App extends Component { - componentWillMount () { - const { currentCurrency, setCurrentCurrencyToUSD } = this.props - - if (!currentCurrency) { - setCurrentCurrencyToUSD() - } - } - - renderRoutes () { - const exact = true - - return ( - h(Switch, [ - h(Route, { path: INITIALIZE_ROUTE, component: InitializeScreen }), - h(Initialized, { path: UNLOCK_ROUTE, exact, component: UnlockPage }), - h(Initialized, { path: RESTORE_VAULT_ROUTE, exact, component: RestoreVaultPage }), - h(Authenticated, { path: REVEAL_SEED_ROUTE, exact, component: RevealSeedConfirmation }), - h(Authenticated, { path: SETTINGS_ROUTE, component: Settings }), - h(Authenticated, { path: NOTICE_ROUTE, exact, component: NoticeScreen }), - h(Authenticated, { - path: `${CONFIRM_TRANSACTION_ROUTE}/:id?`, - component: ConfirmTransaction, - }), - h(Authenticated, { path: SEND_ROUTE, exact, component: SendTransactionScreen }), - h(Authenticated, { path: ADD_TOKEN_ROUTE, exact, component: AddTokenPage }), - h(Authenticated, { path: CONFIRM_ADD_TOKEN_ROUTE, exact, component: ConfirmAddTokenPage }), - h(Authenticated, { path: CONFIRM_ADD_SUGGESTED_TOKEN_ROUTE, exact, component: ConfirmAddSuggestedTokenPage }), - h(Authenticated, { path: NEW_ACCOUNT_ROUTE, component: CreateAccountPage }), - h(Authenticated, { path: DEFAULT_ROUTE, exact, component: Home }), - ]) - ) - } - - render () { - const { - isLoading, - alertMessage, - loadingMessage, - network, - isMouseUser, - provider, - frequentRpcList, - currentView, - setMouseUserState, - sidebar, - } = this.props - const isLoadingNetwork = network === 'loading' && currentView.name !== 'config' - const loadMessage = loadingMessage || isLoadingNetwork ? - this.getConnectingLabel(loadingMessage) : null - log.debug('Main ui render function') - - return ( - h('.flex-column.full-height', { - className: classnames({ 'mouse-user-styles': isMouseUser }), - style: { - overflowX: 'hidden', - position: 'relative', - alignItems: 'center', - }, - tabIndex: '0', - onClick: () => setMouseUserState(true), - onKeyDown: (e) => { - if (e.keyCode === 9) { - setMouseUserState(false) - } - }, - }, [ - - // global modal - h(Modal, {}, []), - - // global alert - h(Alert, {visible: this.props.alertOpen, msg: alertMessage}), - - h(AppHeader), - - // sidebar - h(Sidebar, { - sidebarOpen: sidebar.isOpen, - hideSidebar: this.props.hideSidebar, - transitionName: sidebar.transitionName, - type: sidebar.type, - }), - - // network dropdown - h(NetworkDropdown, { - provider, - frequentRpcList, - }, []), - - h(AccountMenu), - - h('div.main-container-wrapper', [ - (isLoading || isLoadingNetwork) && h(Loading, { - loadingMessage: loadMessage, - }), - - // content - this.renderRoutes(), - ]), - ]) - ) - } - - toggleMetamaskActive () { - if (!this.props.isUnlocked) { - // currently inactive: redirect to password box - var passwordBox = document.querySelector('input[type=password]') - if (!passwordBox) return - passwordBox.focus() - } else { - // currently active: deactivate - this.props.dispatch(actions.lockMetamask(false)) - } - } - - getConnectingLabel = function (loadingMessage) { - if (loadingMessage) { - return loadingMessage - } - const { provider } = this.props - const providerName = provider.type - - let name - - if (providerName === 'mainnet') { - name = this.context.t('connectingToMainnet') - } else if (providerName === 'ropsten') { - name = this.context.t('connectingToRopsten') - } else if (providerName === 'kovan') { - name = this.context.t('connectingToKovan') - } else if (providerName === 'rinkeby') { - name = this.context.t('connectingToRinkeby') - } else if (providerName === 'poa') { - name = this.context.t('connectingToPOA') - } else { - name = this.context.t('connectingToUnknown') - } - - return name - } - - getNetworkName () { - const { provider } = this.props - const providerName = provider.type - - let name - - if (providerName === 'mainnet') { - name = this.context.t('mainnet') - } else if (providerName === 'ropsten') { - name = this.context.t('ropsten') - } else if (providerName === 'kovan') { - name = this.context.t('kovan') - } else if (providerName === 'rinkeby') { - name = this.context.t('rinkeby') - } else if (providerName === 'poa') { - name = this.context.t('poa') - } else { - name = this.context.t('unknownNetwork') - } - - return name - } -} - -App.propTypes = { - currentCurrency: PropTypes.string, - setCurrentCurrencyToUSD: PropTypes.func, - isLoading: PropTypes.bool, - loadingMessage: PropTypes.string, - alertMessage: PropTypes.string, - network: PropTypes.string, - provider: PropTypes.object, - frequentRpcList: PropTypes.array, - currentView: PropTypes.object, - sidebar: PropTypes.object, - alertOpen: PropTypes.bool, - hideSidebar: PropTypes.func, - isMascara: PropTypes.bool, - isOnboarding: PropTypes.bool, - isUnlocked: PropTypes.bool, - networkDropdownOpen: PropTypes.bool, - showNetworkDropdown: PropTypes.func, - hideNetworkDropdown: PropTypes.func, - history: PropTypes.object, - location: PropTypes.object, - dispatch: PropTypes.func, - toggleAccountMenu: PropTypes.func, - selectedAddress: PropTypes.string, - noActiveNotices: PropTypes.bool, - lostAccounts: PropTypes.array, - isInitialized: PropTypes.bool, - forgottenPassword: PropTypes.bool, - activeAddress: PropTypes.string, - unapprovedTxs: PropTypes.object, - seedWords: PropTypes.string, - unapprovedMsgCount: PropTypes.number, - unapprovedPersonalMsgCount: PropTypes.number, - unapprovedTypedMessagesCount: PropTypes.number, - welcomeScreenSeen: PropTypes.bool, - isPopup: PropTypes.bool, - betaUI: PropTypes.bool, - isMouseUser: PropTypes.bool, - setMouseUserState: PropTypes.func, - t: PropTypes.func, -} - -function mapStateToProps (state) { - const { appState, metamask } = state - const { - networkDropdownOpen, - sidebar, - alertOpen, - alertMessage, - isLoading, - loadingMessage, - } = appState - - const accounts = getMetaMaskAccounts(state) - - const { - identities, - address, - keyrings, - isInitialized, - noActiveNotices, - seedWords, - unapprovedTxs, - nextUnreadNotice, - lostAccounts, - unapprovedMsgCount, - unapprovedPersonalMsgCount, - unapprovedTypedMessagesCount, - } = metamask - const selected = address || Object.keys(accounts)[0] - - return { - // state from plugin - networkDropdownOpen, - sidebar, - alertOpen, - alertMessage, - isLoading, - loadingMessage, - noActiveNotices, - isInitialized, - isUnlocked: state.metamask.isUnlocked, - selectedAddress: state.metamask.selectedAddress, - currentView: state.appState.currentView, - activeAddress: state.appState.activeAddress, - transForward: state.appState.transForward, - isMascara: state.metamask.isMascara, - isOnboarding: Boolean(!noActiveNotices || seedWords || !isInitialized), - isPopup: state.metamask.isPopup, - seedWords: state.metamask.seedWords, - unapprovedTxs, - unapprovedMsgs: state.metamask.unapprovedMsgs, - unapprovedMsgCount, - unapprovedPersonalMsgCount, - unapprovedTypedMessagesCount, - menuOpen: state.appState.menuOpen, - network: state.metamask.network, - provider: state.metamask.provider, - forgottenPassword: state.appState.forgottenPassword, - nextUnreadNotice, - lostAccounts, - frequentRpcList: state.metamask.frequentRpcList || [], - currentCurrency: state.metamask.currentCurrency, - isMouseUser: state.appState.isMouseUser, - betaUI: state.metamask.featureFlags.betaUI, - isRevealingSeedWords: state.metamask.isRevealingSeedWords, - Qr: state.appState.Qr, - welcomeScreenSeen: state.metamask.welcomeScreenSeen, - - // state needed to get account dropdown temporarily rendering from app bar - identities, - selected, - keyrings, - } -} - -function mapDispatchToProps (dispatch, ownProps) { - return { - dispatch, - hideSidebar: () => dispatch(actions.hideSidebar()), - showNetworkDropdown: () => dispatch(actions.showNetworkDropdown()), - hideNetworkDropdown: () => dispatch(actions.hideNetworkDropdown()), - setCurrentCurrencyToUSD: () => dispatch(actions.setCurrentCurrency('usd')), - toggleAccountMenu: () => dispatch(actions.toggleAccountMenu()), - setMouseUserState: (isMouseUser) => dispatch(actions.setMouseUserState(isMouseUser)), - } -} - -App.contextTypes = { - t: PropTypes.func, -} - -module.exports = compose( - withRouter, - connect(mapStateToProps, mapDispatchToProps) -)(App) diff --git a/ui/app/components/account-menu/index.js b/ui/app/components/account-menu/index.js deleted file mode 100644 index 55c5a2a53..000000000 --- a/ui/app/components/account-menu/index.js +++ /dev/null @@ -1,249 +0,0 @@ -const inherits = require('util').inherits -const Component = require('react').Component -const connect = require('react-redux').connect -const { compose } = require('recompose') -const { withRouter } = require('react-router-dom') -const PropTypes = require('prop-types') -const h = require('react-hyperscript') -const actions = require('../../actions') -const { Menu, Item, Divider, CloseArea } = require('../dropdowns/components/menu') -const Identicon = require('../identicon') -const { ENVIRONMENT_TYPE_POPUP } = require('../../../../app/scripts/lib/enums') -const { getEnvironmentType } = require('../../../../app/scripts/lib/util') -const Tooltip = require('../tooltip') -import UserPreferencedCurrencyDisplay from '../user-preferenced-currency-display' -import { PRIMARY } from '../../constants/common' -import { getMetaMaskAccounts } from '../../selectors' - -const { - SETTINGS_ROUTE, - INFO_ROUTE, - NEW_ACCOUNT_ROUTE, - IMPORT_ACCOUNT_ROUTE, - CONNECT_HARDWARE_ROUTE, - DEFAULT_ROUTE, -} = require('../../routes') - -module.exports = compose( - withRouter, - connect(mapStateToProps, mapDispatchToProps) -)(AccountMenu) - -AccountMenu.contextTypes = { - t: PropTypes.func, -} - -inherits(AccountMenu, Component) -function AccountMenu () { Component.call(this) } - -function mapStateToProps (state) { - return { - selectedAddress: state.metamask.selectedAddress, - isAccountMenuOpen: state.metamask.isAccountMenuOpen, - keyrings: state.metamask.keyrings, - identities: state.metamask.identities, - accounts: getMetaMaskAccounts(state), - } -} - -function mapDispatchToProps (dispatch) { - return { - toggleAccountMenu: () => dispatch(actions.toggleAccountMenu()), - showAccountDetail: address => { - dispatch(actions.showAccountDetail(address)) - dispatch(actions.hideSidebar()) - dispatch(actions.toggleAccountMenu()) - }, - lockMetamask: () => { - dispatch(actions.lockMetamask()) - dispatch(actions.hideWarning()) - dispatch(actions.hideSidebar()) - dispatch(actions.toggleAccountMenu()) - }, - showConfigPage: () => { - dispatch(actions.showConfigPage()) - dispatch(actions.hideSidebar()) - dispatch(actions.toggleAccountMenu()) - }, - showInfoPage: () => { - dispatch(actions.showInfoPage()) - dispatch(actions.hideSidebar()) - dispatch(actions.toggleAccountMenu()) - }, - showRemoveAccountConfirmationModal: (identity) => { - return dispatch(actions.showModal({ name: 'CONFIRM_REMOVE_ACCOUNT', identity })) - }, - } -} - -AccountMenu.prototype.render = function () { - const { - isAccountMenuOpen, - toggleAccountMenu, - lockMetamask, - history, - } = this.props - - return h(Menu, { className: 'account-menu', isShowing: isAccountMenuOpen }, [ - h(CloseArea, { onClick: toggleAccountMenu }), - h(Item, { - className: 'account-menu__header', - }, [ - this.context.t('myAccounts'), - h('button.account-menu__logout-button', { - onClick: () => { - lockMetamask() - history.push(DEFAULT_ROUTE) - }, - }, this.context.t('logout')), - ]), - h(Divider), - h('div.account-menu__accounts', this.renderAccounts()), - h(Divider), - h(Item, { - onClick: () => { - toggleAccountMenu() - history.push(NEW_ACCOUNT_ROUTE) - }, - icon: h('img.account-menu__item-icon', { src: 'images/plus-btn-white.svg' }), - text: this.context.t('createAccount'), - }), - h(Item, { - onClick: () => { - toggleAccountMenu() - history.push(IMPORT_ACCOUNT_ROUTE) - }, - icon: h('img.account-menu__item-icon', { src: 'images/import-account.svg' }), - text: this.context.t('importAccount'), - }), - h(Item, { - onClick: () => { - toggleAccountMenu() - if (getEnvironmentType(window.location.href) === ENVIRONMENT_TYPE_POPUP) { - global.platform.openExtensionInBrowser(CONNECT_HARDWARE_ROUTE) - } else { - history.push(CONNECT_HARDWARE_ROUTE) - } - }, - icon: h('img.account-menu__item-icon', { src: 'images/connect-icon.svg' }), - text: this.context.t('connectHardwareWallet'), - }), - h(Divider), - h(Item, { - onClick: () => { - toggleAccountMenu() - history.push(INFO_ROUTE) - }, - icon: h('img', { src: 'images/mm-info-icon.svg' }), - text: this.context.t('infoHelp'), - }), - h(Item, { - onClick: () => { - toggleAccountMenu() - history.push(SETTINGS_ROUTE) - }, - icon: h('img.account-menu__item-icon', { src: 'images/settings.svg' }), - text: this.context.t('settings'), - }), - ]) -} - -AccountMenu.prototype.renderAccounts = function () { - const { - identities, - accounts, - selectedAddress, - keyrings, - showAccountDetail, - } = this.props - - const accountOrder = keyrings.reduce((list, keyring) => list.concat(keyring.accounts), []) - return accountOrder.filter(address => !!identities[address]).map((address) => { - - const identity = identities[address] - const isSelected = identity.address === selectedAddress - - const balanceValue = accounts[address] ? accounts[address].balance : '' - const simpleAddress = identity.address.substring(2).toLowerCase() - - const keyring = keyrings.find((kr) => { - return kr.accounts.includes(simpleAddress) || - kr.accounts.includes(identity.address) - }) - - return h( - 'div.account-menu__account.menu__item--clickable', - { onClick: () => showAccountDetail(identity.address) }, - [ - h('div.account-menu__check-mark', [ - isSelected ? h('div.account-menu__check-mark-icon') : null, - ]), - - h( - Identicon, - { - address: identity.address, - diameter: 24, - }, - ), - - h('div.account-menu__account-info', [ - h('div.account-menu__name', identity.name || ''), - h(UserPreferencedCurrencyDisplay, { - className: 'account-menu__balance', - value: balanceValue, - type: PRIMARY, - }), - ]), - - this.renderKeyringType(keyring), - this.renderRemoveAccount(keyring, identity), - ], - ) - }) -} - -AccountMenu.prototype.renderRemoveAccount = function (keyring, identity) { - // Any account that's not from the HD wallet Keyring can be removed - const type = keyring.type - const isRemovable = type !== 'HD Key Tree' - if (isRemovable) { - return h(Tooltip, { - title: this.context.t('removeAccount'), - position: 'bottom', - }, [ - h('a.remove-account-icon', { - onClick: (e) => this.removeAccount(e, identity), - }, ''), - ]) - } - return null -} - -AccountMenu.prototype.removeAccount = function (e, identity) { - e.preventDefault() - e.stopPropagation() - const { showRemoveAccountConfirmationModal } = this.props - showRemoveAccountConfirmationModal(identity) -} - -AccountMenu.prototype.renderKeyringType = function (keyring) { - try { // Sometimes keyrings aren't loaded yet: - const type = keyring.type - let label - switch (type) { - case 'Trezor Hardware': - case 'Ledger Hardware': - label = this.context.t('hardware') - break - case 'Simple Key Pair': - label = this.context.t('imported') - break - default: - label = '' - } - - return label !== '' ? h('.keyring-label.allcaps', label) : null - - } catch (e) { return } -} diff --git a/ui/app/components/add-token-button/add-token-button.component.js b/ui/app/components/add-token-button/add-token-button.component.js deleted file mode 100644 index 10887aed8..000000000 --- a/ui/app/components/add-token-button/add-token-button.component.js +++ /dev/null @@ -1,34 +0,0 @@ -import PropTypes from 'prop-types' -import React, {PureComponent} from 'react' - -export default class AddTokenButton extends PureComponent { - static contextTypes = { - t: PropTypes.func.isRequired, - } - - static defaultProps = { - onClick: () => {}, - } - - static propTypes = { - onClick: PropTypes.func, - } - - render () { - const { t } = this.context - const { onClick } = this.props - - return ( -
-

{t('missingYourTokens')}

-

{t('clickToAdd', [t('addToken')])}

-
- {t('addToken')} -
-
- ) - } -} diff --git a/ui/app/components/add-token-button/index.js b/ui/app/components/add-token-button/index.js deleted file mode 100644 index 15c4fe6ca..000000000 --- a/ui/app/components/add-token-button/index.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from './add-token-button.component' diff --git a/ui/app/components/add-token-button/index.scss b/ui/app/components/add-token-button/index.scss deleted file mode 100644 index 39f404716..000000000 --- a/ui/app/components/add-token-button/index.scss +++ /dev/null @@ -1,26 +0,0 @@ -.add-token-button { - display: flex; - flex-direction: column; - color: lighten($scorpion, 25%); - width: 185px; - margin: 36px auto; - text-align: center; - - &__help-header { - font-weight: bold; - font-size: 1rem; - } - - &__help-desc { - font-size: 0.75rem; - margin-top: 1rem; - } - - &__button { - font-size: 0.75rem; - margin: 1rem; - text-transform: uppercase; - color: $curious-blue; - cursor: pointer; - } -} diff --git a/ui/app/components/alert/index.js b/ui/app/components/alert/index.js deleted file mode 100644 index 5620d847a..000000000 --- a/ui/app/components/alert/index.js +++ /dev/null @@ -1,62 +0,0 @@ -const { Component } = require('react') -const PropTypes = require('prop-types') -const h = require('react-hyperscript') - -class Alert extends Component { - - constructor (props) { - super(props) - - this.state = { - visble: false, - msg: false, - className: '', - } - } - - componentWillReceiveProps (nextProps) { - if (!this.props.visible && nextProps.visible) { - this.animateIn(nextProps) - } else if (this.props.visible && !nextProps.visible) { - this.animateOut(nextProps) - } - } - - animateIn (props) { - this.setState({ - msg: props.msg, - visible: true, - className: '.visible', - }) - } - - animateOut (props) { - this.setState({ - msg: null, - className: '.hidden', - }) - - setTimeout(_ => { - this.setState({visible: false}) - }, 500) - - } - - render () { - if (this.state.visible) { - return ( - h(`div.global-alert${this.state.className}`, {}, - h('a.msg', {}, this.state.msg) - ) - ) - } - return null - } -} - -Alert.propTypes = { - visible: PropTypes.bool.isRequired, - msg: PropTypes.string, -} -module.exports = Alert - diff --git a/ui/app/components/app-header/app-header.component.js b/ui/app/components/app-header/app-header.component.js deleted file mode 100644 index b8b002dcc..000000000 --- a/ui/app/components/app-header/app-header.component.js +++ /dev/null @@ -1,136 +0,0 @@ -import React, { PureComponent } from 'react' -import PropTypes from 'prop-types' -import classnames from 'classnames' -import { matchPath } from 'react-router-dom' - -const { - ENVIRONMENT_TYPE_NOTIFICATION, - ENVIRONMENT_TYPE_POPUP, -} = require('../../../../app/scripts/lib/enums') -const { DEFAULT_ROUTE, INITIALIZE_ROUTE, CONFIRM_TRANSACTION_ROUTE } = require('../../routes') -const Identicon = require('../identicon') -const NetworkIndicator = require('../network') - -export default class AppHeader extends PureComponent { - static propTypes = { - history: PropTypes.object, - location: PropTypes.object, - network: PropTypes.string, - provider: PropTypes.object, - networkDropdownOpen: PropTypes.bool, - showNetworkDropdown: PropTypes.func, - hideNetworkDropdown: PropTypes.func, - toggleAccountMenu: PropTypes.func, - selectedAddress: PropTypes.string, - isUnlocked: PropTypes.bool, - } - - static contextTypes = { - t: PropTypes.func, - } - - handleNetworkIndicatorClick (event) { - event.preventDefault() - event.stopPropagation() - - const { networkDropdownOpen, showNetworkDropdown, hideNetworkDropdown } = this.props - - return networkDropdownOpen === false - ? showNetworkDropdown() - : hideNetworkDropdown() - } - - isConfirming () { - const { location } = this.props - - return Boolean(matchPath(location.pathname, { - path: CONFIRM_TRANSACTION_ROUTE, exact: false, - })) - } - - renderAccountMenu () { - const { isUnlocked, toggleAccountMenu, selectedAddress } = this.props - - return isUnlocked && ( -
this.isConfirming() || toggleAccountMenu()} - > - -
- ) - } - - hideAppHeader () { - const { location } = this.props - - const isInitializing = Boolean(matchPath(location.pathname, { - path: INITIALIZE_ROUTE, exact: false, - })) - - if (isInitializing) { - return true - } - - if (window.METAMASK_UI_TYPE === ENVIRONMENT_TYPE_NOTIFICATION) { - return true - } - - if (window.METAMASK_UI_TYPE === ENVIRONMENT_TYPE_POPUP && this.isConfirming()) { - return true - } - } - - render () { - const { - network, - provider, - history, - isUnlocked, - } = this.props - - if (this.hideAppHeader()) { - return null - } - - return ( -
-
-
history.push(DEFAULT_ROUTE)} - > - - -
-
-
- this.handleNetworkIndicatorClick(event)} - disabled={this.isConfirming()} - /> -
- { this.renderAccountMenu() } -
-
-
- ) - } -} diff --git a/ui/app/components/app-header/app-header.container.js b/ui/app/components/app-header/app-header.container.js deleted file mode 100644 index 30d3f8cc4..000000000 --- a/ui/app/components/app-header/app-header.container.js +++ /dev/null @@ -1,38 +0,0 @@ -import { connect } from 'react-redux' -import { withRouter } from 'react-router-dom' -import { compose } from 'recompose' - -import AppHeader from './app-header.component' -const actions = require('../../actions') - -const mapStateToProps = state => { - const { appState, metamask } = state - const { networkDropdownOpen } = appState - const { - network, - provider, - selectedAddress, - isUnlocked, - } = metamask - - return { - networkDropdownOpen, - network, - provider, - selectedAddress, - isUnlocked, - } -} - -const mapDispatchToProps = dispatch => { - return { - showNetworkDropdown: () => dispatch(actions.showNetworkDropdown()), - hideNetworkDropdown: () => dispatch(actions.hideNetworkDropdown()), - toggleAccountMenu: () => dispatch(actions.toggleAccountMenu()), - } -} - -export default compose( - withRouter, - connect(mapStateToProps, mapDispatchToProps) -)(AppHeader) diff --git a/ui/app/components/app-header/index.js b/ui/app/components/app-header/index.js deleted file mode 100644 index 6de2f9c78..000000000 --- a/ui/app/components/app-header/index.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from './app-header.container' diff --git a/ui/app/components/app-header/index.scss b/ui/app/components/app-header/index.scss deleted file mode 100644 index 325844af5..000000000 --- a/ui/app/components/app-header/index.scss +++ /dev/null @@ -1,90 +0,0 @@ -.app-header { - align-items: center; - background: $gallery; - position: relative; - z-index: $header-z-index; - display: flex; - flex-flow: column nowrap; - width: 100%; - flex: 0 0 auto; - - @media screen and (max-width: 575px) { - padding: 12px; - box-shadow: 0 0 0 1px rgba(0, 0, 0, .08); - z-index: $mobile-header-z-index; - } - - @media screen and (min-width: 576px) { - height: 75px; - justify-content: center; - - &--back-drop { - &::after { - content: ''; - position: absolute; - width: 100%; - height: 32px; - background: $gallery; - bottom: -32px; - } - } - } - - &__metafox-logo { - cursor: pointer; - - &--icon { - @media screen and (min-width: $break-large) { - display: none; - } - } - - &--horizontal { - @media screen and (max-width: $break-small) { - display: none; - } - } - } - - &__contents { - display: flex; - justify-content: space-between; - flex-flow: row nowrap; - width: 100%; - - @media screen and (max-width: 575px) { - height: 100%; - } - - @media screen and (min-width: 576px) { - width: 85vw; - } - - @media screen and (min-width: 769px) { - width: 80vw; - } - - @media screen and (min-width: 1281px) { - width: 62vw; - } - } - - &__logo-container { - display: flex; - flex-direction: row; - align-items: center; - cursor: pointer; - } - - &__account-menu-container { - display: flex; - flex-flow: row nowrap; - align-items: center; - } - - &__network-component-wrapper { - display: flex; - flex-direction: row; - align-items: center; - } -} diff --git a/ui/app/components/currency-input/currency-input.component.js b/ui/app/components/currency-input/currency-input.component.js deleted file mode 100644 index 54cd0e1ac..000000000 --- a/ui/app/components/currency-input/currency-input.component.js +++ /dev/null @@ -1,120 +0,0 @@ -import React, { PureComponent } from 'react' -import PropTypes from 'prop-types' -import UnitInput from '../unit-input' -import CurrencyDisplay from '../currency-display' -import { getValueFromWeiHex, getWeiHexFromDecimalValue } from '../../helpers/conversions.util' -import { ETH } from '../../constants/common' - -/** - * Component that allows user to enter currency values as a number, and props receive a converted - * hex value in WEI. props.value, used as a default or forced value, should be a hex value, which - * gets converted into a decimal value depending on the currency (ETH or Fiat). - */ -export default class CurrencyInput extends PureComponent { - static propTypes = { - conversionRate: PropTypes.number, - currentCurrency: PropTypes.string, - onChange: PropTypes.func, - onBlur: PropTypes.func, - suffix: PropTypes.string, - useFiat: PropTypes.bool, - value: PropTypes.string, - } - - constructor (props) { - super(props) - - const { value: hexValue } = props - const decimalValue = hexValue ? this.getDecimalValue(props) : 0 - - this.state = { - decimalValue, - hexValue, - } - } - - componentDidUpdate (prevProps) { - const { value: prevPropsHexValue } = prevProps - const { value: propsHexValue } = this.props - const { hexValue: stateHexValue } = this.state - - if (prevPropsHexValue !== propsHexValue && propsHexValue !== stateHexValue) { - const decimalValue = this.getDecimalValue(this.props) - this.setState({ hexValue: propsHexValue, decimalValue }) - } - } - - getDecimalValue (props) { - const { value: hexValue, useFiat, currentCurrency, conversionRate } = props - const decimalValueString = useFiat - ? getValueFromWeiHex({ - value: hexValue, toCurrency: currentCurrency, conversionRate, numberOfDecimals: 2, - }) - : getValueFromWeiHex({ - value: hexValue, toCurrency: ETH, numberOfDecimals: 6, - }) - - return Number(decimalValueString) || 0 - } - - handleChange = decimalValue => { - const { useFiat, currentCurrency: fromCurrency, conversionRate, onChange } = this.props - - const hexValue = useFiat - ? getWeiHexFromDecimalValue({ - value: decimalValue, fromCurrency, conversionRate, invertConversionRate: true, - }) - : getWeiHexFromDecimalValue({ - value: decimalValue, fromCurrency: ETH, fromDenomination: ETH, conversionRate, - }) - - this.setState({ hexValue, decimalValue }) - onChange(hexValue) - } - - handleBlur = () => { - this.props.onBlur(this.state.hexValue) - } - - renderConversionComponent () { - const { useFiat, currentCurrency } = this.props - const { hexValue } = this.state - let currency, numberOfDecimals - - if (useFiat) { - // Display ETH - currency = ETH - numberOfDecimals = 6 - } else { - // Display Fiat - currency = currentCurrency - numberOfDecimals = 2 - } - - return ( - - ) - } - - render () { - const { suffix, ...restProps } = this.props - const { decimalValue } = this.state - - return ( - - { this.renderConversionComponent() } - - ) - } -} diff --git a/ui/app/components/currency-input/currency-input.container.js b/ui/app/components/currency-input/currency-input.container.js deleted file mode 100644 index 18e5533de..000000000 --- a/ui/app/components/currency-input/currency-input.container.js +++ /dev/null @@ -1,27 +0,0 @@ -import { connect } from 'react-redux' -import CurrencyInput from './currency-input.component' -import { ETH } from '../../constants/common' - -const mapStateToProps = state => { - const { metamask: { currentCurrency, conversionRate } } = state - - return { - currentCurrency, - conversionRate, - } -} - -const mergeProps = (stateProps, dispatchProps, ownProps) => { - const { currentCurrency } = stateProps - const { useFiat } = ownProps - const suffix = useFiat ? currentCurrency.toUpperCase() : ETH - - return { - ...stateProps, - ...dispatchProps, - ...ownProps, - suffix, - } -} - -export default connect(mapStateToProps, null, mergeProps)(CurrencyInput) diff --git a/ui/app/components/currency-input/index.js b/ui/app/components/currency-input/index.js deleted file mode 100644 index d8069fb67..000000000 --- a/ui/app/components/currency-input/index.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from './currency-input.container' diff --git a/ui/app/components/currency-input/index.scss b/ui/app/components/currency-input/index.scss deleted file mode 100644 index fcb2db461..000000000 --- a/ui/app/components/currency-input/index.scss +++ /dev/null @@ -1,7 +0,0 @@ -.currency-input { - &__conversion-component { - font-size: 12px; - line-height: 12px; - padding-left: 1px; - } -} diff --git a/ui/app/components/currency-input/tests/currency-input.component.test.js b/ui/app/components/currency-input/tests/currency-input.component.test.js deleted file mode 100644 index 8de0ef863..000000000 --- a/ui/app/components/currency-input/tests/currency-input.component.test.js +++ /dev/null @@ -1,239 +0,0 @@ -import React from 'react' -import assert from 'assert' -import { shallow, mount } from 'enzyme' -import sinon from 'sinon' -import { Provider } from 'react-redux' -import configureMockStore from 'redux-mock-store' -import CurrencyInput from '../currency-input.component' -import UnitInput from '../../unit-input' -import CurrencyDisplay from '../../currency-display' - -describe('CurrencyInput Component', () => { - describe('rendering', () => { - it('should render properly without a suffix', () => { - const wrapper = shallow( - - ) - - assert.ok(wrapper) - assert.equal(wrapper.find(UnitInput).length, 1) - }) - - it('should render properly with a suffix', () => { - const mockStore = { - metamask: { - currentCurrency: 'usd', - conversionRate: 231.06, - }, - } - const store = configureMockStore()(mockStore) - - const wrapper = mount( - - - - ) - - assert.ok(wrapper) - assert.equal(wrapper.find('.unit-input__suffix').length, 1) - assert.equal(wrapper.find('.unit-input__suffix').text(), 'ETH') - assert.equal(wrapper.find(CurrencyDisplay).length, 1) - }) - - it('should render properly with an ETH value', () => { - const mockStore = { - metamask: { - currentCurrency: 'usd', - conversionRate: 231.06, - }, - } - const store = configureMockStore()(mockStore) - - const wrapper = mount( - - - - ) - - assert.ok(wrapper) - const currencyInputInstance = wrapper.find(CurrencyInput).at(0).instance() - assert.equal(currencyInputInstance.state.decimalValue, 1) - assert.equal(currencyInputInstance.state.hexValue, 'de0b6b3a7640000') - assert.equal(wrapper.find('.unit-input__suffix').length, 1) - assert.equal(wrapper.find('.unit-input__suffix').text(), 'ETH') - assert.equal(wrapper.find('.unit-input__input').props().value, '1') - assert.equal(wrapper.find('.currency-display-component').text(), '$231.06 USD') - }) - - it('should render properly with a fiat value', () => { - const mockStore = { - metamask: { - currentCurrency: 'usd', - conversionRate: 231.06, - }, - } - const store = configureMockStore()(mockStore) - - const wrapper = mount( - - - - ) - - assert.ok(wrapper) - const currencyInputInstance = wrapper.find(CurrencyInput).at(0).instance() - assert.equal(currencyInputInstance.state.decimalValue, 1) - assert.equal(currencyInputInstance.state.hexValue, 'f602f2234d0ea') - assert.equal(wrapper.find('.unit-input__suffix').length, 1) - assert.equal(wrapper.find('.unit-input__suffix').text(), 'USD') - assert.equal(wrapper.find('.unit-input__input').props().value, '1') - assert.equal(wrapper.find('.currency-display-component').text(), '0.004328 ETH') - }) - }) - - describe('handling actions', () => { - const handleChangeSpy = sinon.spy() - const handleBlurSpy = sinon.spy() - - afterEach(() => { - handleChangeSpy.resetHistory() - handleBlurSpy.resetHistory() - }) - - it('should call onChange and onBlur on input changes with the hex value for ETH', () => { - const mockStore = { - metamask: { - currentCurrency: 'usd', - conversionRate: 231.06, - }, - } - const store = configureMockStore()(mockStore) - const wrapper = mount( - - - - ) - - assert.ok(wrapper) - assert.equal(handleChangeSpy.callCount, 0) - assert.equal(handleBlurSpy.callCount, 0) - - const currencyInputInstance = wrapper.find(CurrencyInput).at(0).instance() - assert.equal(currencyInputInstance.state.decimalValue, 0) - assert.equal(currencyInputInstance.state.hexValue, undefined) - assert.equal(wrapper.find('.currency-display-component').text(), '$0.00 USD') - const input = wrapper.find('input') - assert.equal(input.props().value, 0) - - input.simulate('change', { target: { value: 1 } }) - assert.equal(handleChangeSpy.callCount, 1) - assert.ok(handleChangeSpy.calledWith('de0b6b3a7640000')) - assert.equal(wrapper.find('.currency-display-component').text(), '$231.06 USD') - assert.equal(currencyInputInstance.state.decimalValue, 1) - assert.equal(currencyInputInstance.state.hexValue, 'de0b6b3a7640000') - - assert.equal(handleBlurSpy.callCount, 0) - input.simulate('blur') - assert.equal(handleBlurSpy.callCount, 1) - assert.ok(handleBlurSpy.calledWith('de0b6b3a7640000')) - }) - - it('should call onChange and onBlur on input changes with the hex value for fiat', () => { - const mockStore = { - metamask: { - currentCurrency: 'usd', - conversionRate: 231.06, - }, - } - const store = configureMockStore()(mockStore) - const wrapper = mount( - - - - ) - - assert.ok(wrapper) - assert.equal(handleChangeSpy.callCount, 0) - assert.equal(handleBlurSpy.callCount, 0) - - const currencyInputInstance = wrapper.find(CurrencyInput).at(0).instance() - assert.equal(currencyInputInstance.state.decimalValue, 0) - assert.equal(currencyInputInstance.state.hexValue, undefined) - assert.equal(wrapper.find('.currency-display-component').text(), '0 ETH') - const input = wrapper.find('input') - assert.equal(input.props().value, 0) - - input.simulate('change', { target: { value: 1 } }) - assert.equal(handleChangeSpy.callCount, 1) - assert.ok(handleChangeSpy.calledWith('f602f2234d0ea')) - assert.equal(wrapper.find('.currency-display-component').text(), '0.004328 ETH') - assert.equal(currencyInputInstance.state.decimalValue, 1) - assert.equal(currencyInputInstance.state.hexValue, 'f602f2234d0ea') - - assert.equal(handleBlurSpy.callCount, 0) - input.simulate('blur') - assert.equal(handleBlurSpy.callCount, 1) - assert.ok(handleBlurSpy.calledWith('f602f2234d0ea')) - }) - - it('should change the state and pass in a new decimalValue when props.value changes', () => { - const mockStore = { - metamask: { - currentCurrency: 'usd', - conversionRate: 231.06, - }, - } - const store = configureMockStore()(mockStore) - const wrapper = shallow( - - - - ) - - assert.ok(wrapper) - const currencyInputInstance = wrapper.find(CurrencyInput).dive() - assert.equal(currencyInputInstance.state('decimalValue'), 0) - assert.equal(currencyInputInstance.state('hexValue'), undefined) - assert.equal(currencyInputInstance.find(UnitInput).props().value, 0) - - currencyInputInstance.setProps({ value: '1ec05e43e72400' }) - currencyInputInstance.update() - assert.equal(currencyInputInstance.state('decimalValue'), 2) - assert.equal(currencyInputInstance.state('hexValue'), '1ec05e43e72400') - assert.equal(currencyInputInstance.find(UnitInput).props().value, 2) - }) - }) -}) diff --git a/ui/app/components/currency-input/tests/currency-input.container.test.js b/ui/app/components/currency-input/tests/currency-input.container.test.js deleted file mode 100644 index e77945e4d..000000000 --- a/ui/app/components/currency-input/tests/currency-input.container.test.js +++ /dev/null @@ -1,55 +0,0 @@ -import assert from 'assert' -import proxyquire from 'proxyquire' - -let mapStateToProps, mergeProps - -proxyquire('../currency-input.container.js', { - 'react-redux': { - connect: (ms, md, mp) => { - mapStateToProps = ms - mergeProps = mp - return () => ({}) - }, - }, -}) - -describe('CurrencyInput container', () => { - describe('mapStateToProps()', () => { - it('should return the correct props', () => { - const mockState = { - metamask: { - conversionRate: 280.45, - currentCurrency: 'usd', - }, - } - - assert.deepEqual(mapStateToProps(mockState), { - conversionRate: 280.45, - currentCurrency: 'usd', - }) - }) - }) - - describe('mergeProps()', () => { - it('should return the correct props', () => { - const mockStateProps = { - conversionRate: 280.45, - currentCurrency: 'usd', - } - const mockDispatchProps = {} - - assert.deepEqual(mergeProps(mockStateProps, mockDispatchProps, { useFiat: true }), { - conversionRate: 280.45, - currentCurrency: 'usd', - useFiat: true, - suffix: 'USD', - }) - - assert.deepEqual(mergeProps(mockStateProps, mockDispatchProps, {}), { - conversionRate: 280.45, - currentCurrency: 'usd', - suffix: 'ETH', - }) - }) - }) -}) diff --git a/ui/app/components/index.scss b/ui/app/components/index.scss deleted file mode 100644 index beffdb221..000000000 --- a/ui/app/components/index.scss +++ /dev/null @@ -1,59 +0,0 @@ -@import './app-header/index'; - -@import './add-token-button/index'; - -@import './button-group/index'; - -@import './card/index'; - -@import './confirm-page-container/index'; - -@import './currency-input/index'; - -@import './currency-display/index'; - -@import './error-message/index'; - -@import './export-text-container/index'; - -@import './info-box/index'; - -@import './menu-bar/index'; - -@import './modal/index'; - -@import './modals/index'; - -@import './network-display/index'; - -@import './page-container/index'; - -@import './pages/index'; - -@import './selected-account/index'; - -@import './sender-to-recipient/index'; - -@import './tabs/index'; - -@import './transaction-activity-log/index'; - -@import './transaction-breakdown/index'; - -@import './transaction-view/index'; - -@import './transaction-view-balance/index'; - -@import './transaction-list/index'; - -@import './transaction-list-item/index'; - -@import './transaction-list-item-details/index'; - -@import './transaction-status/index'; - -@import './app-header/index'; - -@import './sidebars/index'; - -@import './unit-input/index'; diff --git a/ui/app/components/menu-bar/index.js b/ui/app/components/menu-bar/index.js deleted file mode 100644 index c5760847f..000000000 --- a/ui/app/components/menu-bar/index.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from './menu-bar.container' diff --git a/ui/app/components/menu-bar/index.scss b/ui/app/components/menu-bar/index.scss deleted file mode 100644 index f699f4090..000000000 --- a/ui/app/components/menu-bar/index.scss +++ /dev/null @@ -1,23 +0,0 @@ -.menu-bar { - display: flex; - flex-direction: row; - justify-content: center; - align-items: center; - flex: 0 0 auto; - margin-bottom: 16px; - padding: 5px; - border-bottom: 1px solid #e5e5e5; - - &__sidebar-button { - font-size: 1.25rem; - cursor: pointer; - padding: 10px; - } - - &__open-in-browser { - cursor: pointer; - display: flex; - justify-content: center; - padding: 10px; - } -} diff --git a/ui/app/components/menu-bar/menu-bar.component.js b/ui/app/components/menu-bar/menu-bar.component.js deleted file mode 100644 index e64809f3f..000000000 --- a/ui/app/components/menu-bar/menu-bar.component.js +++ /dev/null @@ -1,63 +0,0 @@ -import React, { PureComponent } from 'react' -import PropTypes from 'prop-types' -import Tooltip from '../tooltip' -import SelectedAccount from '../selected-account' -import AccountDetailsDropdown from '../dropdowns/account-details-dropdown.js' - -export default class MenuBar extends PureComponent { - static contextTypes = { - t: PropTypes.func, - } - - static propTypes = { - hideSidebar: PropTypes.func, - isMascara: PropTypes.bool, - sidebarOpen: PropTypes.bool, - showSidebar: PropTypes.func, - } - - state = { accountDetailsMenuOpen: false } - - render () { - const { t } = this.context - const { isMascara, sidebarOpen, hideSidebar, showSidebar } = this.props - const { accountDetailsMenuOpen } = this.state - - return ( -
- -
sidebarOpen ? hideSidebar() : showSidebar()} - /> - - - { - !isMascara && ( - -
this.setState({ accountDetailsMenuOpen: true })} - > -
-
- ) - } - { - accountDetailsMenuOpen && ( - this.setState({ accountDetailsMenuOpen: false })} - /> - ) - } -
- ) - } -} diff --git a/ui/app/components/menu-bar/menu-bar.container.js b/ui/app/components/menu-bar/menu-bar.container.js deleted file mode 100644 index ae32882ae..000000000 --- a/ui/app/components/menu-bar/menu-bar.container.js +++ /dev/null @@ -1,26 +0,0 @@ -import { connect } from 'react-redux' -import MenuBar from './menu-bar.component' -import { showSidebar, hideSidebar } from '../../actions' - -const mapStateToProps = state => { - const { appState: { sidebar: { isOpen }, isMascara } } = state - - return { - sidebarOpen: isOpen, - isMascara, - } -} - -const mapDispatchToProps = dispatch => { - return { - showSidebar: () => { - dispatch(showSidebar({ - transitionName: 'sidebar-right', - type: 'wallet-view', - })) - }, - hideSidebar: () => dispatch(hideSidebar()), - } -} - -export default connect(mapStateToProps, mapDispatchToProps)(MenuBar) diff --git a/ui/app/components/network.js b/ui/app/components/network.js deleted file mode 100644 index 7ae342d8e..000000000 --- a/ui/app/components/network.js +++ /dev/null @@ -1,154 +0,0 @@ -const Component = require('react').Component -const PropTypes = require('prop-types') -const h = require('react-hyperscript') -const connect = require('react-redux').connect -const classnames = require('classnames') -const inherits = require('util').inherits -const NetworkDropdownIcon = require('./dropdowns/components/network-dropdown-icon') - -Network.contextTypes = { - t: PropTypes.func, -} - -module.exports = connect()(Network) - - -inherits(Network, Component) - -function Network () { - Component.call(this) -} - -Network.prototype.render = function () { - const props = this.props - const context = this.context - const networkNumber = props.network - let providerName - try { - providerName = props.provider.type - } catch (e) { - providerName = null - } - let iconName, hoverText - - if (networkNumber === 'loading') { - return h('span.pointer.network-indicator', { - style: { - display: 'flex', - alignItems: 'center', - flexDirection: 'row', - }, - onClick: (event) => this.props.onClick(event), - }, [ - h('img', { - title: context.t('attemptingConnect'), - style: { - width: '27px', - }, - src: 'images/loading.svg', - }), - ]) - } else if (providerName === 'mainnet') { - hoverText = context.t('mainnet') - iconName = 'ethereum-network' - } else if (providerName === 'ropsten') { - hoverText = context.t('ropsten') - iconName = 'ropsten-test-network' - } else if (parseInt(networkNumber) === 3) { - hoverText = context.t('ropsten') - iconName = 'ropsten-test-network' - } else if (providerName === 'kovan') { - hoverText = context.t('kovan') - iconName = 'kovan-test-network' - } else if (providerName === 'rinkeby') { - hoverText = context.t('rinkeby') - iconName = 'rinkeby-test-network' - } else if (providerName === 'poa') { - hoverText = context.t('poa') - iconName = 'poa-network' - } else { - hoverText = context.t('unknownNetwork') - iconName = 'unknown-private-network' - } - - return ( - h('div.network-component.pointer', { - className: classnames({ - 'network-component--disabled': this.props.disabled, - 'ethereum-network': providerName === 'mainnet', - 'ropsten-test-network': providerName === 'ropsten' || parseInt(networkNumber) === 3, - 'kovan-test-network': providerName === 'kovan', - 'rinkeby-test-network': providerName === 'rinkeby', - 'poa-network': providerName === 'poa', - }), - title: hoverText, - onClick: (event) => { - if (!this.props.disabled) { - this.props.onClick(event) - } - }, - }, [ - (function () { - switch (iconName) { - case 'ethereum-network': - return h('.network-indicator', [ - h(NetworkDropdownIcon, { - backgroundColor: '#038789', // $blue-lagoon - nonSelectBackgroundColor: '#15afb2', - }), - h('.network-name', context.t('mainnet')), - h('i.fa.fa-chevron-down.fa-lg.network-caret'), - ]) - case 'ropsten-test-network': - return h('.network-indicator', [ - h(NetworkDropdownIcon, { - backgroundColor: '#e91550', // $crimson - nonSelectBackgroundColor: '#ec2c50', - }), - h('.network-name', context.t('ropsten')), - h('i.fa.fa-chevron-down.fa-lg.network-caret'), - ]) - case 'kovan-test-network': - return h('.network-indicator', [ - h(NetworkDropdownIcon, { - backgroundColor: '#690496', // $purple - nonSelectBackgroundColor: '#b039f3', - }), - h('.network-name', context.t('kovan')), - h('i.fa.fa-chevron-down.fa-lg.network-caret'), - ]) - case 'rinkeby-test-network': - return h('.network-indicator', [ - h(NetworkDropdownIcon, { - backgroundColor: '#ebb33f', // $tulip-tree - nonSelectBackgroundColor: '#ecb23e', - }), - h('.network-name', context.t('rinkeby')), - h('i.fa.fa-chevron-down.fa-lg.network-caret'), - ]) - case 'poa-network': - return h('.network-indicator', [ - h(NetworkDropdownIcon, { - backgroundColor: '#5c34a2', // $tulip-tree - nonSelectBackgroundColor: '#5c34a2', - }), - h('.network-name', context.t('poa')), - h('i.fa.fa-chevron-down.fa-lg.network-caret'), - ]) - default: - return h('.network-indicator', [ - h('i.fa.fa-question-circle.fa-lg', { - style: { - margin: '10px', - color: 'rgb(125, 128, 130)', - }, - }), - - h('.network-name', context.t('privateNetwork')), - h('i.fa.fa-chevron-down.fa-lg.network-caret'), - ]) - } - })(), - ]) - ) -} diff --git a/ui/app/components/pages/settings/index.js b/ui/app/components/pages/settings/index.js deleted file mode 100644 index 44a9ffa63..000000000 --- a/ui/app/components/pages/settings/index.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from './settings.component' diff --git a/ui/app/components/pages/settings/index.scss b/ui/app/components/pages/settings/index.scss deleted file mode 100644 index 138ebcfc5..000000000 --- a/ui/app/components/pages/settings/index.scss +++ /dev/null @@ -1,80 +0,0 @@ -@import './info-tab/index'; - -@import './settings-tab/index'; - -.settings-page { - position: relative; - background: $white; - display: flex; - flex-flow: column nowrap; - - &__header { - padding: 25px 25px 0; - } - - &__close-button::after { - content: '\00D7'; - font-size: 40px; - color: $dusty-gray; - position: absolute; - top: 25px; - right: 30px; - cursor: pointer; - } - - &__content { - padding: 25px; - height: auto; - overflow: auto; - } - - &__content-row { - display: flex; - flex-direction: row; - padding: 10px 0 20px; - - @media screen and (max-width: 575px) { - flex-direction: column; - padding: 10px 0; - } - } - - &__content-item { - flex: 1; - min-width: 0; - display: flex; - flex-direction: column; - padding: 0 5px; - min-height: 71px; - - @media screen and (max-width: 575px) { - height: initial; - padding: 5px 0; - } - - &--without-height { - height: initial; - } - } - - &__content-label { - text-transform: capitalize; - } - - &__content-description { - font-size: 14px; - color: $dusty-gray; - padding-top: 5px; - } - - &__content-item-col { - max-width: 300px; - display: flex; - flex-direction: column; - - @media screen and (max-width: 575px) { - max-width: 100%; - width: 100%; - } - } -} diff --git a/ui/app/components/pages/settings/info-tab/index.js b/ui/app/components/pages/settings/info-tab/index.js deleted file mode 100644 index 7556a258d..000000000 --- a/ui/app/components/pages/settings/info-tab/index.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from './info-tab.component' diff --git a/ui/app/components/pages/settings/info-tab/index.scss b/ui/app/components/pages/settings/info-tab/index.scss deleted file mode 100644 index 43ad6f652..000000000 --- a/ui/app/components/pages/settings/info-tab/index.scss +++ /dev/null @@ -1,56 +0,0 @@ -.info-tab { - &__logo-wrapper { - height: 80px; - margin-bottom: 20px; - } - - &__logo { - max-height: 100%; - max-width: 100%; - } - - &__item { - padding: 10px 0; - } - - &__link-header { - padding-bottom: 15px; - - @media screen and (max-width: 575px) { - padding-bottom: 5px; - } - } - - &__link-item { - padding: 15px 0; - - @media screen and (max-width: 575px) { - padding: 5px 0; - } - } - - &__link-text { - color: $curious-blue; - } - - &__version-number { - padding-top: 5px; - font-size: 13px; - color: $dusty-gray; - } - - &__separator { - margin: 15px 0; - width: 80px; - border-color: $alto; - border: none; - height: 1px; - background-color: $alto; - color: $alto; - } - - &__about { - color: $dusty-gray; - margin-bottom: 15px; - } -} diff --git a/ui/app/components/pages/settings/info-tab/info-tab.component.js b/ui/app/components/pages/settings/info-tab/info-tab.component.js deleted file mode 100644 index 72f7d835e..000000000 --- a/ui/app/components/pages/settings/info-tab/info-tab.component.js +++ /dev/null @@ -1,136 +0,0 @@ -import React, { PureComponent } from 'react' -import PropTypes from 'prop-types' - -export default class InfoTab extends PureComponent { - state = { - version: global.platform.getVersion(), - } - - static propTypes = { - tab: PropTypes.string, - metamask: PropTypes.object, - setCurrentCurrency: PropTypes.func, - setRpcTarget: PropTypes.func, - displayWarning: PropTypes.func, - revealSeedConfirmation: PropTypes.func, - warning: PropTypes.string, - location: PropTypes.object, - history: PropTypes.object, - } - - static contextTypes = { - t: PropTypes.func, - } - - renderInfoLinks () { - const { t } = this.context - - return ( -
-
- { t('links') } -
- - - -
- - - -
- ) - } - - render () { - const { t } = this.context - - return ( -
-
-
-
- -
-
-
- { t('metamaskVersion') } -
-
- { this.state.version } -
-
-
-
- { t('builtInCalifornia') } -
-
-
- { this.renderInfoLinks() } -
-
- ) - } -} diff --git a/ui/app/components/pages/settings/settings-tab/index.js b/ui/app/components/pages/settings/settings-tab/index.js deleted file mode 100644 index 9fdaafd3f..000000000 --- a/ui/app/components/pages/settings/settings-tab/index.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from './settings-tab.container' diff --git a/ui/app/components/pages/settings/settings-tab/index.scss b/ui/app/components/pages/settings/settings-tab/index.scss deleted file mode 100644 index 3bf840c86..000000000 --- a/ui/app/components/pages/settings/settings-tab/index.scss +++ /dev/null @@ -1,69 +0,0 @@ -.settings-tab { - &__error { - padding-bottom: 20px; - text-align: center; - color: $crimson; - } - - &__rpc-save-button { - align-self: flex-end; - padding: 5px; - text-transform: uppercase; - color: $dusty-gray; - cursor: pointer; - } - - &__rpc-save-button { - align-self: flex-end; - padding: 5px; - text-transform: uppercase; - color: $dusty-gray; - cursor: pointer; - } - - &__button--red { - border-color: lighten($monzo, 10%); - color: $monzo; - - &:active { - background: lighten($monzo, 55%); - border-color: $monzo; - } - - &:hover { - border-color: $monzo; - } - } - - &__button--orange { - border-color: lighten($ecstasy, 20%); - color: $ecstasy; - - &:active { - background: lighten($ecstasy, 40%); - border-color: $ecstasy; - } - - &:hover { - border-color: $ecstasy; - } - } - - &__radio-buttons { - display: flex; - align-items: center; - } - - &__radio-button { - display: flex; - align-items: center; - - &:not(:last-child) { - margin-right: 16px; - } - } - - &__radio-label { - padding-left: 4px; - } -} diff --git a/ui/app/components/pages/settings/settings-tab/settings-tab.component.js b/ui/app/components/pages/settings/settings-tab/settings-tab.component.js deleted file mode 100644 index a9e2a723e..000000000 --- a/ui/app/components/pages/settings/settings-tab/settings-tab.component.js +++ /dev/null @@ -1,413 +0,0 @@ -import React, { PureComponent } from 'react' -import PropTypes from 'prop-types' -import infuraCurrencies from '../../../../infura-conversion.json' -import validUrl from 'valid-url' -import { exportAsFile } from '../../../../util' -import SimpleDropdown from '../../../dropdowns/simple-dropdown' -import ToggleButton from 'react-toggle-button' -import { REVEAL_SEED_ROUTE } from '../../../../routes' -import locales from '../../../../../../app/_locales/index.json' -import TextField from '../../../text-field' -import Button from '../../../button' - -const sortedCurrencies = infuraCurrencies.objects.sort((a, b) => { - return a.quote.name.toLocaleLowerCase().localeCompare(b.quote.name.toLocaleLowerCase()) -}) - -const infuraCurrencyOptions = sortedCurrencies.map(({ quote: { code, name } }) => { - return { - displayValue: `${code.toUpperCase()} - ${name}`, - key: code, - value: code, - } -}) - -const localeOptions = locales.map(locale => { - return { - displayValue: `${locale.name}`, - key: locale.code, - value: locale.code, - } -}) - -export default class SettingsTab extends PureComponent { - static contextTypes = { - t: PropTypes.func, - } - - static propTypes = { - metamask: PropTypes.object, - setUseBlockie: PropTypes.func, - setHexDataFeatureFlag: PropTypes.func, - setCurrentCurrency: PropTypes.func, - setRpcTarget: PropTypes.func, - delRpcTarget: PropTypes.func, - displayWarning: PropTypes.func, - revealSeedConfirmation: PropTypes.func, - setFeatureFlagToBeta: PropTypes.func, - showResetAccountConfirmationModal: PropTypes.func, - warning: PropTypes.string, - history: PropTypes.object, - isMascara: PropTypes.bool, - updateCurrentLocale: PropTypes.func, - currentLocale: PropTypes.string, - useBlockie: PropTypes.bool, - sendHexData: PropTypes.bool, - currentCurrency: PropTypes.string, - conversionDate: PropTypes.number, - useETHAsPrimaryCurrency: PropTypes.bool, - setUseETHAsPrimaryCurrencyPreference: PropTypes.func, - } - - state = { - newRpc: '', - } - - renderCurrentConversion () { - const { t } = this.context - const { currentCurrency, conversionDate, setCurrentCurrency } = this.props - - return ( -
-
- { t('currentConversion') } - - { t('updatedWithDate', [Date(conversionDate)]) } - -
-
-
- setCurrentCurrency(newCurrency)} - /> -
-
-
- ) - } - - renderCurrentLocale () { - const { t } = this.context - const { updateCurrentLocale, currentLocale } = this.props - const currentLocaleMeta = locales.find(locale => locale.code === currentLocale) - const currentLocaleName = currentLocaleMeta ? currentLocaleMeta.name : '' - - return ( -
-
- - { t('currentLanguage') } - - - { currentLocaleName } - -
-
-
- updateCurrentLocale(newLocale)} - /> -
-
-
- ) - } - - renderNewRpcUrl () { - const { t } = this.context - const { newRpc } = this.state - - return ( -
-
- { t('newRPC') } -
-
-
- this.setState({ newRpc: e.target.value })} - onKeyPress={e => { - if (e.key === 'Enter') { - this.validateRpc(newRpc) - } - }} - fullWidth - margin="none" - /> -
{ - e.preventDefault() - this.validateRpc(newRpc) - }} - > - { t('save') } -
-
-
-
- ) - } - - validateRpc (newRpc) { - const { setRpcTarget, displayWarning } = this.props - - if (validUrl.isWebUri(newRpc)) { - setRpcTarget(newRpc) - } else { - const appendedRpc = `http://${newRpc}` - - if (validUrl.isWebUri(appendedRpc)) { - displayWarning(this.context.t('uriErrorMsg')) - } else { - displayWarning(this.context.t('invalidRPC')) - } - } - } - - renderStateLogs () { - const { t } = this.context - const { displayWarning } = this.props - - return ( -
-
- { t('stateLogs') } - - { t('stateLogsDescription') } - -
-
-
- -
-
-
- ) - } - - renderSeedWords () { - const { t } = this.context - const { history } = this.props - - return ( -
-
- { t('revealSeedWords') } -
-
-
- -
-
-
- ) - } - - renderOldUI () { - const { t } = this.context - const { setFeatureFlagToBeta } = this.props - - return ( -
-
- { t('useOldUI') } -
-
-
- -
-
-
- ) - } - - renderResetAccount () { - const { t } = this.context - const { showResetAccountConfirmationModal } = this.props - - return ( -
-
- { t('resetAccount') } -
-
-
- -
-
-
- ) - } - - renderBlockieOptIn () { - const { useBlockie, setUseBlockie } = this.props - - return ( -
-
- { this.context.t('blockiesIdenticon') } -
-
-
- setUseBlockie(!value)} - activeLabel="" - inactiveLabel="" - /> -
-
-
- ) - } - - renderHexDataOptIn () { - const { t } = this.context - const { sendHexData, setHexDataFeatureFlag } = this.props - - return ( -
-
- { t('showHexData') } -
- { t('showHexDataDescription') } -
-
-
-
- setHexDataFeatureFlag(!value)} - activeLabel="" - inactiveLabel="" - /> -
-
-
- ) - } - - renderUseEthAsPrimaryCurrency () { - const { t } = this.context - const { useETHAsPrimaryCurrency, setUseETHAsPrimaryCurrencyPreference } = this.props - - return ( -
-
- { t('primaryCurrencySetting') } -
- { t('primaryCurrencySettingDescription') } -
-
-
-
-
-
- setUseETHAsPrimaryCurrencyPreference(true)} - checked={Boolean(useETHAsPrimaryCurrency)} - /> - -
-
- setUseETHAsPrimaryCurrencyPreference(false)} - checked={!useETHAsPrimaryCurrency} - /> - -
-
-
-
-
- ) - } - - render () { - const { warning, isMascara } = this.props - - return ( -
- { warning &&
{ warning }
} - { this.renderCurrentConversion() } - { this.renderUseEthAsPrimaryCurrency() } - { this.renderCurrentLocale() } - { this.renderNewRpcUrl() } - { this.renderStateLogs() } - { this.renderSeedWords() } - { !isMascara && this.renderOldUI() } - { this.renderResetAccount() } - { this.renderBlockieOptIn() } - { this.renderHexDataOptIn() } -
- ) - } -} diff --git a/ui/app/components/pages/settings/settings-tab/settings-tab.container.js b/ui/app/components/pages/settings/settings-tab/settings-tab.container.js deleted file mode 100644 index de30f309c..000000000 --- a/ui/app/components/pages/settings/settings-tab/settings-tab.container.js +++ /dev/null @@ -1,66 +0,0 @@ -import SettingsTab from './settings-tab.component' -import { compose } from 'recompose' -import { connect } from 'react-redux' -import { withRouter } from 'react-router-dom' -import { - setCurrentCurrency, - setRpcTarget, - displayWarning, - revealSeedConfirmation, - setUseBlockie, - updateCurrentLocale, - setFeatureFlag, - showModal, - setUseETHAsPrimaryCurrencyPreference, -} from '../../../../actions' -import { preferencesSelector } from '../../../../selectors' - -const mapStateToProps = state => { - const { appState: { warning }, metamask } = state - const { - currentCurrency, - conversionDate, - useBlockie, - featureFlags: { sendHexData } = {}, - provider = {}, - isMascara, - currentLocale, - } = metamask - const { useETHAsPrimaryCurrency } = preferencesSelector(state) - - return { - warning, - isMascara, - currentLocale, - currentCurrency, - conversionDate, - useBlockie, - sendHexData, - provider, - useETHAsPrimaryCurrency, - } -} - -const mapDispatchToProps = dispatch => { - return { - setCurrentCurrency: currency => dispatch(setCurrentCurrency(currency)), - setRpcTarget: newRpc => dispatch(setRpcTarget(newRpc)), - displayWarning: warning => dispatch(displayWarning(warning)), - revealSeedConfirmation: () => dispatch(revealSeedConfirmation()), - setUseBlockie: value => dispatch(setUseBlockie(value)), - updateCurrentLocale: key => dispatch(updateCurrentLocale(key)), - setFeatureFlagToBeta: () => { - return dispatch(setFeatureFlag('betaUI', false, 'OLD_UI_NOTIFICATION_MODAL')) - }, - setHexDataFeatureFlag: shouldShow => dispatch(setFeatureFlag('sendHexData', shouldShow)), - showResetAccountConfirmationModal: () => dispatch(showModal({ name: 'CONFIRM_RESET_ACCOUNT' })), - setUseETHAsPrimaryCurrencyPreference: value => { - return dispatch(setUseETHAsPrimaryCurrencyPreference(value)) - }, - } -} - -export default compose( - withRouter, - connect(mapStateToProps, mapDispatchToProps) -)(SettingsTab) diff --git a/ui/app/components/pages/settings/settings.component.js b/ui/app/components/pages/settings/settings.component.js deleted file mode 100644 index 94a97bba1..000000000 --- a/ui/app/components/pages/settings/settings.component.js +++ /dev/null @@ -1,54 +0,0 @@ -import React, { PureComponent } from 'react' -import PropTypes from 'prop-types' -import { Switch, Route, matchPath } from 'react-router-dom' -import TabBar from '../../tab-bar' -import SettingsTab from './settings-tab' -import InfoTab from './info-tab' -import { DEFAULT_ROUTE, SETTINGS_ROUTE, INFO_ROUTE } from '../../../routes' - -export default class SettingsPage extends PureComponent { - static propTypes = { - location: PropTypes.object, - history: PropTypes.object, - t: PropTypes.func, - } - - static contextTypes = { - t: PropTypes.func, - } - - render () { - const { history, location } = this.props - - return ( -
-
-
history.push(DEFAULT_ROUTE)} - /> - matchPath(location.pathname, { path: key, exact: true })} - onSelect={key => history.push(key)} - /> -
- - - - -
- ) - } -} diff --git a/ui/app/components/signature-request.js b/ui/app/components/signature-request.js deleted file mode 100644 index d76eb5ef8..000000000 --- a/ui/app/components/signature-request.js +++ /dev/null @@ -1,307 +0,0 @@ -const Component = require('react').Component -const PropTypes = require('prop-types') -const h = require('react-hyperscript') -const inherits = require('util').inherits -const Identicon = require('./identicon') -const connect = require('react-redux').connect -const ethUtil = require('ethereumjs-util') -const classnames = require('classnames') -const { compose } = require('recompose') -const { withRouter } = require('react-router-dom') -const { ObjectInspector } = require('react-inspector') - -const AccountDropdownMini = require('./dropdowns/account-dropdown-mini') - -const actions = require('../actions') -const { conversionUtil } = require('../conversion-util') - -const { - getSelectedAccount, - getCurrentAccountWithSendEtherInfo, - getSelectedAddress, - accountsWithSendEtherInfoSelector, - conversionRateSelector, -} = require('../selectors.js') - -import { clearConfirmTransaction } from '../ducks/confirm-transaction.duck' -import Button from './button' - -const { DEFAULT_ROUTE } = require('../routes') - -function mapStateToProps (state) { - return { - balance: getSelectedAccount(state).balance, - selectedAccount: getCurrentAccountWithSendEtherInfo(state), - selectedAddress: getSelectedAddress(state), - requester: null, - requesterAddress: null, - accounts: accountsWithSendEtherInfoSelector(state), - conversionRate: conversionRateSelector(state), - } -} - -function mapDispatchToProps (dispatch) { - return { - goHome: () => dispatch(actions.goHome()), - clearConfirmTransaction: () => dispatch(clearConfirmTransaction()), - } -} - -SignatureRequest.contextTypes = { - t: PropTypes.func, -} - -module.exports = compose( - withRouter, - connect(mapStateToProps, mapDispatchToProps) -)(SignatureRequest) - - -inherits(SignatureRequest, Component) -function SignatureRequest (props) { - Component.call(this) - - this.state = { - selectedAccount: props.selectedAccount, - accountDropdownOpen: false, - } -} - -SignatureRequest.prototype.renderHeader = function () { - return h('div.request-signature__header', [ - - h('div.request-signature__header-background'), - - h('div.request-signature__header__text', this.context.t('sigRequest')), - - h('div.request-signature__header__tip-container', [ - h('div.request-signature__header__tip'), - ]), - - ]) -} - -SignatureRequest.prototype.renderAccountDropdown = function () { - const { - selectedAccount, - accountDropdownOpen, - } = this.state - - const { - accounts, - } = this.props - - return h('div.request-signature__account', [ - - h('div.request-signature__account-text', [this.context.t('account') + ':']), - - h(AccountDropdownMini, { - selectedAccount, - accounts, - onSelect: selectedAccount => this.setState({ selectedAccount }), - dropdownOpen: accountDropdownOpen, - openDropdown: () => this.setState({ accountDropdownOpen: true }), - closeDropdown: () => this.setState({ accountDropdownOpen: false }), - }), - - ]) -} - -SignatureRequest.prototype.renderBalance = function () { - const { balance, conversionRate } = this.props - - const balanceInEther = conversionUtil(balance, { - fromNumericBase: 'hex', - toNumericBase: 'dec', - fromDenomination: 'WEI', - numberOfDecimals: 6, - conversionRate, - }) - - return h('div.request-signature__balance', [ - - h('div.request-signature__balance-text', `${this.context.t('balance')}:`), - - h('div.request-signature__balance-value', `${balanceInEther} ETH`), - - ]) -} - -SignatureRequest.prototype.renderAccountInfo = function () { - return h('div.request-signature__account-info', [ - - this.renderAccountDropdown(), - - this.renderRequestIcon(), - - this.renderBalance(), - - ]) -} - -SignatureRequest.prototype.renderRequestIcon = function () { - const { requesterAddress } = this.props - - return h('div.request-signature__request-icon', [ - h(Identicon, { - diameter: 40, - address: requesterAddress, - }), - ]) -} - -SignatureRequest.prototype.renderRequestInfo = function () { - return h('div.request-signature__request-info', [ - - h('div.request-signature__headline', [ - this.context.t('yourSigRequested'), - ]), - - ]) -} - -SignatureRequest.prototype.msgHexToText = function (hex) { - try { - const stripped = ethUtil.stripHexPrefix(hex) - const buff = Buffer.from(stripped, 'hex') - return buff.toString('utf8') - } catch (e) { - return hex - } -} - -// eslint-disable-next-line react/display-name -SignatureRequest.prototype.renderTypedDataV3 = function (data) { - const { domain, message } = JSON.parse(data) - return [ - h('div.request-signature__typed-container', [ - domain ? h('div', [ - h('h1', 'Domain'), - h(ObjectInspector, { data: domain, expandLevel: 1, name: 'domain' }), - ]) : '', - message ? h('div', [ - h('h1', 'Message'), - h(ObjectInspector, { data: message, expandLevel: 1, name: 'message' }), - ]) : '', - ]), - ] -} - -SignatureRequest.prototype.renderBody = function () { - let rows - let notice = this.context.t('youSign') + ':' - - const { txData } = this.props - const { type, msgParams: { data, version } } = txData - - if (type === 'personal_sign') { - rows = [{ name: this.context.t('message'), value: this.msgHexToText(data) }] - } else if (type === 'eth_signTypedData') { - rows = data - } else if (type === 'eth_sign') { - rows = [{ name: this.context.t('message'), value: data }] - notice = [this.context.t('signNotice'), - h('span.request-signature__help-link', { - onClick: () => { - global.platform.openWindow({ - url: 'https://metamask.zendesk.com/hc/en-us/articles/360015488751', - }) - }, - }, this.context.t('learnMore'))] - } - - return h('div.request-signature__body', {}, [ - - this.renderAccountInfo(), - - this.renderRequestInfo(), - - h('div.request-signature__notice', { - className: classnames({ - 'request-signature__notice': type === 'personal_sign' || type === 'eth_signTypedData', - 'request-signature__warning': type === 'eth_sign', - }), - }, [notice]), - - h('div.request-signature__rows', type === 'eth_signTypedData' && version === 'V3' ? - this.renderTypedDataV3(data) : - rows.map(({ name, value }) => { - if (typeof value === 'boolean') { - value = value.toString() - } - return h('div.request-signature__row', [ - h('div.request-signature__row-title', [`${name}:`]), - h('div.request-signature__row-value', value), - ]) - }), - ), - ]) -} - -SignatureRequest.prototype.renderFooter = function () { - const { - signPersonalMessage, - signTypedMessage, - cancelPersonalMessage, - cancelTypedMessage, - signMessage, - cancelMessage, - } = this.props - - const { txData } = this.props - const { type } = txData - - let cancel - let sign - if (type === 'personal_sign') { - cancel = cancelPersonalMessage - sign = signPersonalMessage - } else if (type === 'eth_signTypedData') { - cancel = cancelTypedMessage - sign = signTypedMessage - } else if (type === 'eth_sign') { - cancel = cancelMessage - sign = signMessage - } - - return h('div.request-signature__footer', [ - h(Button, { - type: 'default', - large: true, - className: 'request-signature__footer__cancel-button', - onClick: event => { - cancel(event).then(() => { - this.props.clearConfirmTransaction() - this.props.history.push(DEFAULT_ROUTE) - }) - }, - }, this.context.t('cancel')), - h(Button, { - type: 'primary', - large: true, - onClick: event => { - sign(event).then(() => { - this.props.clearConfirmTransaction() - this.props.history.push(DEFAULT_ROUTE) - }) - }, - }, this.context.t('sign')), - ]) -} - -SignatureRequest.prototype.render = function () { - return ( - - h('div.request-signature__container', [ - - this.renderHeader(), - - this.renderBody(), - - this.renderFooter(), - - ]) - - ) - -} diff --git a/ui/app/components/wallet-view.js b/ui/app/components/wallet-view.js deleted file mode 100644 index 7eceda760..000000000 --- a/ui/app/components/wallet-view.js +++ /dev/null @@ -1,230 +0,0 @@ -const Component = require('react').Component -const PropTypes = require('prop-types') -const connect = require('react-redux').connect -const h = require('react-hyperscript') -const { withRouter } = require('react-router-dom') -const { compose } = require('recompose') -const inherits = require('util').inherits -const classnames = require('classnames') -const { checksumAddress } = require('../util') -const Identicon = require('./identicon') -// const AccountDropdowns = require('./dropdowns/index.js').AccountDropdowns -const Tooltip = require('./tooltip-v2.js').default -const copyToClipboard = require('copy-to-clipboard') -const actions = require('../actions') -const BalanceComponent = require('./balance-component') -const TokenList = require('./token-list') -const selectors = require('../selectors') -const { ADD_TOKEN_ROUTE } = require('../routes') - -import AddTokenButton from './add-token-button' - -module.exports = compose( - withRouter, - connect(mapStateToProps, mapDispatchToProps) -)(WalletView) - -WalletView.contextTypes = { - t: PropTypes.func, -} - -WalletView.defaultProps = { - responsiveDisplayClassname: '', -} - -function mapStateToProps (state) { - - return { - network: state.metamask.network, - sidebarOpen: state.appState.sidebar.isOpen, - identities: state.metamask.identities, - accounts: selectors.getMetaMaskAccounts(state), - tokens: state.metamask.tokens, - keyrings: state.metamask.keyrings, - selectedAddress: selectors.getSelectedAddress(state), - selectedAccount: selectors.getSelectedAccount(state), - selectedTokenAddress: state.metamask.selectedTokenAddress, - } -} - -function mapDispatchToProps (dispatch) { - return { - showSendPage: () => dispatch(actions.showSendPage()), - hideSidebar: () => dispatch(actions.hideSidebar()), - unsetSelectedToken: () => dispatch(actions.setSelectedToken()), - showAccountDetailModal: () => { - dispatch(actions.showModal({ name: 'ACCOUNT_DETAILS' })) - }, - showAddTokenPage: () => dispatch(actions.showAddTokenPage()), - } -} - -inherits(WalletView, Component) -function WalletView () { - Component.call(this) - this.state = { - hasCopied: false, - copyToClipboardPressed: false, - } -} - -WalletView.prototype.renderWalletBalance = function () { - const { - selectedTokenAddress, - selectedAccount, - unsetSelectedToken, - hideSidebar, - sidebarOpen, - } = this.props - - const selectedClass = selectedTokenAddress - ? '' - : 'wallet-balance-wrapper--active' - const className = `flex-column wallet-balance-wrapper ${selectedClass}` - - return h('div', { className }, [ - h('div.wallet-balance', - { - onClick: () => { - unsetSelectedToken() - selectedTokenAddress && sidebarOpen && hideSidebar() - }, - }, - [ - h(BalanceComponent, { - balanceValue: selectedAccount ? selectedAccount.balance : '', - style: {}, - }), - ] - ), - ]) -} - -WalletView.prototype.renderAddToken = function () { - const { - sidebarOpen, - hideSidebar, - history, - } = this.props - - return h(AddTokenButton, { - onClick () { - history.push(ADD_TOKEN_ROUTE) - if (sidebarOpen) { - hideSidebar() - } - }, - }) -} - -WalletView.prototype.render = function () { - const { - responsiveDisplayClassname, - selectedAddress, - keyrings, - showAccountDetailModal, - hideSidebar, - identities, - } = this.props - // temporary logs + fake extra wallets - - const checksummedAddress = checksumAddress(selectedAddress) - - if (!selectedAddress) { - throw new Error('selectedAddress should not be ' + String(selectedAddress)) - } - - const keyring = keyrings.find((kr) => { - return kr.accounts.includes(selectedAddress) - }) - - let label = '' - let type - if (keyring) { - type = keyring.type - if (type !== 'HD Key Tree') { - if (type.toLowerCase().search('hardware') !== -1) { - label = this.context.t('hardware') - } else { - label = this.context.t('imported') - } - } - } - - return h('div.wallet-view.flex-column', { - style: {}, - className: responsiveDisplayClassname, - }, [ - - // TODO: Separate component: wallet account details - h('div.flex-column.wallet-view-account-details', { - style: {}, - }, [ - h('div.wallet-view__sidebar-close', { - onClick: hideSidebar, - }), - - h('div.wallet-view__keyring-label.allcaps', label), - - h('div.flex-column.flex-center.wallet-view__name-container', { - style: { margin: '0 auto' }, - onClick: showAccountDetailModal, - }, [ - h(Identicon, { - diameter: 54, - address: checksummedAddress, - }), - - h('span.account-name', { - style: {}, - }, [ - identities[selectedAddress].name, - ]), - - h('button.btn-clear.wallet-view__details-button.allcaps', this.context.t('details')), - ]), - ]), - - h(Tooltip, { - position: 'bottom', - title: this.state.hasCopied ? this.context.t('copiedExclamation') : this.context.t('copyToClipboard'), - wrapperClassName: 'wallet-view__tooltip', - }, [ - h('button.wallet-view__address', { - className: classnames({ - 'wallet-view__address__pressed': this.state.copyToClipboardPressed, - }), - onClick: () => { - copyToClipboard(checksummedAddress) - this.setState({ hasCopied: true }) - setTimeout(() => this.setState({ hasCopied: false }), 3000) - }, - onMouseDown: () => { - this.setState({ copyToClipboardPressed: true }) - }, - onMouseUp: () => { - this.setState({ copyToClipboardPressed: false }) - }, - }, [ - `${checksummedAddress.slice(0, 6)}...${checksummedAddress.slice(-4)}`, - h('i.fa.fa-clipboard', { style: { marginLeft: '8px' } }), - ]), - ]), - - this.renderWalletBalance(), - - h(TokenList), - - this.renderAddToken(), - ]) -} - -// TODO: Extra wallets, for dev testing. Remove when PRing to master. -// const extraWallet = h('div.flex-column.wallet-balance-wrapper', {}, [ -// h('div.wallet-balance', {}, [ -// h(BalanceComponent, { -// balanceValue: selectedAccount.balance, -// style: {}, -// }), -// ]), -// ]) diff --git a/ui/app/first-time/init-menu.js b/ui/app/first-time/init-menu.js deleted file mode 100644 index c8bba123f..000000000 --- a/ui/app/first-time/init-menu.js +++ /dev/null @@ -1,207 +0,0 @@ -const { EventEmitter } = require('events') -const { Component } = require('react') -const PropTypes = require('prop-types') -const connect = require('react-redux').connect -const h = require('react-hyperscript') -const actions = require('../actions') -const Tooltip = require('../components/tooltip') -const { RESTORE_VAULT_ROUTE, DEFAULT_ROUTE } = require('../routes') -const { getEnvironmentType } = require('../../../app/scripts/lib/util') -const { ENVIRONMENT_TYPE_POPUP } = require('../../../app/scripts/lib/enums') - -class InitializeMenuScreen extends Component { - constructor (props) { - super(props) - - this.animationEventEmitter = new EventEmitter() - this.state = { - warning: null, - } - } - - componentWillMount () { - const { isInitialized, isUnlocked, history } = this.props - if (isInitialized || isUnlocked) { - history.push(DEFAULT_ROUTE) - } - } - - componentDidMount () { - document.getElementById('password-box').focus() - } - - render () { - const { warning } = this.state - - return ( - h('.initialize-screen.flex-column.flex-center', [ - - h('h1', { - style: { - fontSize: '1.3em', - textTransform: 'uppercase', - color: '#7F8082', - marginBottom: 10, - }, - }, this.context.t('appName')), - - h('div', [ - h('h3', { - style: { - fontSize: '0.8em', - color: '#7F8082', - display: 'inline', - }, - }, this.context.t('encryptNewDen')), - - h(Tooltip, { - title: this.context.t('denExplainer'), - }, [ - h('i.fa.fa-question-circle.pointer', { - style: { - fontSize: '18px', - position: 'relative', - color: 'rgb(247, 134, 28)', - top: '2px', - marginLeft: '4px', - }, - }), - ]), - ]), - - h('span.error.in-progress-notification', warning), - - // password - h('input.large-input.letter-spacey', { - type: 'password', - id: 'password-box', - placeholder: this.context.t('newPassword'), - onInput: this.inputChanged.bind(this), - style: { - width: 260, - marginTop: 12, - }, - }), - - // confirm password - h('input.large-input.letter-spacey', { - type: 'password', - id: 'password-box-confirm', - placeholder: this.context.t('confirmPassword'), - onKeyPress: this.createVaultOnEnter.bind(this), - onInput: this.inputChanged.bind(this), - style: { - width: 260, - marginTop: 16, - }, - }), - - - h('button.primary', { - onClick: this.createNewVaultAndKeychain.bind(this), - style: { - margin: 12, - }, - }, this.context.t('createDen')), - - h('.flex-row.flex-center.flex-grow', [ - h('p.pointer', { - onClick: () => this.showRestoreVault(), - style: { - fontSize: '0.8em', - color: 'rgb(247, 134, 28)', - textDecoration: 'underline', - }, - }, this.context.t('importDen')), - ]), - - h('.flex-row.flex-center.flex-grow', [ - h('p.pointer', { - onClick: this.showOldUI.bind(this), - style: { - fontSize: '0.8em', - color: '#aeaeae', - textDecoration: 'underline', - marginTop: '32px', - }, - }, this.context.t('classicInterface')), - ]), - - ]) - ) - } - - createVaultOnEnter (event) { - if (event.key === 'Enter') { - event.preventDefault() - this.createNewVaultAndKeychain() - } - } - - createNewVaultAndKeychain () { - const { history } = this.props - var passwordBox = document.getElementById('password-box') - var password = passwordBox.value - var passwordConfirmBox = document.getElementById('password-box-confirm') - var passwordConfirm = passwordConfirmBox.value - - this.setState({ warning: null }) - - if (password.length < 8) { - this.setState({ warning: this.context.t('passwordShort') }) - return - } - - if (password !== passwordConfirm) { - this.setState({ warning: this.context.t('passwordMismatch') }) - return - } - - this.props.createNewVaultAndKeychain(password) - .then(() => history.push(DEFAULT_ROUTE)) - } - - showRestoreVault () { - this.props.markPasswordForgotten() - if (getEnvironmentType(window.location.href) === ENVIRONMENT_TYPE_POPUP) { - global.platform.openExtensionInBrowser() - } - - this.props.history.push(RESTORE_VAULT_ROUTE) - } - - showOldUI () { - this.props.dispatch(actions.setFeatureFlag('betaUI', false, 'OLD_UI_NOTIFICATION_MODAL')) - } -} - -InitializeMenuScreen.propTypes = { - history: PropTypes.object, - isInitialized: PropTypes.bool, - isUnlocked: PropTypes.bool, - createNewVaultAndKeychain: PropTypes.func, - markPasswordForgotten: PropTypes.func, - dispatch: PropTypes.func, -} - -InitializeMenuScreen.contextTypes = { - t: PropTypes.func, -} - -const mapStateToProps = state => { - const { metamask: { isInitialized, isUnlocked } } = state - - return { - isInitialized, - isUnlocked, - } -} - -const mapDispatchToProps = dispatch => { - return { - createNewVaultAndKeychain: password => dispatch(actions.createNewVaultAndKeychain(password)), - markPasswordForgotten: () => dispatch(actions.markPasswordForgotten()), - } -} - -module.exports = connect(mapStateToProps, mapDispatchToProps)(InitializeMenuScreen) diff --git a/ui/app/select-app.js b/ui/app/select-app.js index 7fcc6af3f..47d0dd75f 100644 --- a/ui/app/select-app.js +++ b/ui/app/select-app.js @@ -3,7 +3,6 @@ const Component = require('react').Component const connect = require('react-redux').connect const h = require('react-hyperscript') const { HashRouter } = require('react-router-dom') -const App = require('./app') const OldApp = require('../../old-ui/app/app') const { autoAddToBetaUI } = require('./selectors') const { setFeatureFlag } = require('./actions') @@ -11,7 +10,6 @@ const I18nProvider = require('./i18n-provider') function mapStateToProps (state) { return { - betaUI: state.metamask.featureFlags.betaUI, autoAdd: autoAddToBetaUI(state), isUnlocked: state.metamask.isUnlocked, isMascara: state.metamask.isMascara, @@ -60,17 +58,9 @@ SelectedApp.prototype.render = function () { // const { betaUI, isMascara, firstTime } = this.props // const Selected = betaUI || isMascara || firstTime ? App : OldApp - const { betaUI, isMascara } = this.props - - return betaUI || isMascara - ? h(HashRouter, { - hashType: 'noslash', - }, [ - h(I18nProvider, [ h(App) ]), - ]) - : h(HashRouter, { - hashType: 'noslash', - }, [ - h(I18nProvider, [ h(OldApp) ]), - ]) + return h(HashRouter, { + hashType: 'noslash', + }, [ + h(I18nProvider, [ h(OldApp) ]), + ]) } diff --git a/ui/example.js b/ui/example.js deleted file mode 100644 index 4627c0e9c..000000000 --- a/ui/example.js +++ /dev/null @@ -1,123 +0,0 @@ -const injectCss = require('inject-css') -const MetaMaskUi = require('./index.js') -const MetaMaskUiCss = require('./css.js') -const EventEmitter = require('events').EventEmitter - -// account management - -var identities = { - '0x1113462427bcc9133bb46e88bcbe39cd7ef0e111': { - name: 'Walrus', - img: 'QmW6hcwYzXrNkuHrpvo58YeZvbZxUddv69ATSHY3BHpPdd', - address: '0x1113462427bcc9133bb46e88bcbe39cd7ef0e111', - balance: 220, - txCount: 4, - }, - '0x222462427bcc9133bb46e88bcbe39cd7ef0e7222': { - name: 'Tardus', - img: 'QmQYaRdrf2EhRhJWaHnts8Meu1mZiXrNib5W1P6cYmXWRL', - address: '0x222462427bcc9133bb46e88bcbe39cd7ef0e7222', - balance: 10.005, - txCount: 16, - }, - '0x333462427bcc9133bb46e88bcbe39cd7ef0e7333': { - name: 'Gambler', - img: 'QmW6hcwYzXrNkuHrpvo58YeZvbZxUddv69ATSHY3BHpPdd', - address: '0x333462427bcc9133bb46e88bcbe39cd7ef0e7333', - balance: 0.000001, - txCount: 1, - }, -} - -var unapprovedTxs = {} -addUnconfTx({ - from: '0x222462427bcc9133bb46e88bcbe39cd7ef0e7222', - to: '0x1113462427bcc9133bb46e88bcbe39cd7ef0e111', - value: '0x123', -}) -addUnconfTx({ - from: '0x1113462427bcc9133bb46e88bcbe39cd7ef0e111', - to: '0x333462427bcc9133bb46e88bcbe39cd7ef0e7333', - value: '0x0000', - data: '0x000462427bcc9133bb46e88bcbe39cd7ef0e7000', -}) - -function addUnconfTx (txParams) { - var time = (new Date()).getTime() - var id = createRandomId() - unapprovedTxs[id] = { - id: id, - txParams: txParams, - time: time, - } -} - -var isUnlocked = false -var selectedAccount = null - -function getState () { - return { - isUnlocked: isUnlocked, - identities: isUnlocked ? identities : {}, - unapprovedTxs: isUnlocked ? unapprovedTxs : {}, - selectedAccount: selectedAccount, - } -} - -var accountManager = new EventEmitter() - -accountManager.getState = function (cb) { - cb(null, getState()) -} - -accountManager.setLocked = function () { - isUnlocked = false - this._didUpdate() -} - -accountManager.submitPassword = function (password, cb) { - if (password === 'test') { - isUnlocked = true - cb(null, getState()) - this._didUpdate() - } else { - cb(new Error('Bad password -- try "test"')) - } -} - -accountManager.setSelectedAccount = function (address, cb) { - selectedAccount = address - cb(null, getState()) - this._didUpdate() -} - -accountManager.signTransaction = function (txParams, cb) { - alert('signing tx....') -} - -accountManager._didUpdate = function () { - this.emit('update', getState()) -} - -// start app - -var container = document.getElementById('app-content') - -var css = MetaMaskUiCss() -injectCss(css) - -MetaMaskUi({ - container: container, - accountManager: accountManager, -}) - -// util - -function createRandomId () { - // 13 time digits - var datePart = new Date().getTime() * Math.pow(10, 3) - // 3 random digits - var extraPart = Math.floor(Math.random() * Math.pow(10, 3)) - // 16 digits - return datePart + extraPart -} diff --git a/ui/index.html b/ui/index.html deleted file mode 100644 index b86fb2f32..000000000 --- a/ui/index.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - Nifty Wallet - - - - -
- - - - -
- -
- - -