1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 18:00:18 +01:00

Fix lint errors

This commit is contained in:
Alexander Tseung 2018-04-02 16:24:37 -07:00
parent 92f8157dfe
commit 516c1869b0
13 changed files with 21 additions and 414 deletions

View File

@ -9,7 +9,7 @@ import Identicon from '../../../../ui/app/components/identicon'
import { confirmSeedWords } from '../../../../ui/app/actions'
import Breadcrumbs from './breadcrumbs'
import LoadingScreen from './loading-screen'
import { INITIALIZE_ROUTE, DEFAULT_ROUTE } from '../../../../ui/app/routes'
import { DEFAULT_ROUTE } from '../../../../ui/app/routes'
class ConfirmSeedScreen extends Component {
static propTypes = {
@ -35,21 +35,21 @@ class ConfirmSeedScreen extends Component {
componentWillMount () {
const { seedWords, history } = this.props
if (!seedWords) {
history.push(INITIALIZE_ROUTE)
history.push(DEFAULT_ROUTE)
}
}
handleClick () {
this.props.confirmSeedWords()
.then(() => {
console.log('FINISHED')
this.props.history.push(DEFAULT_ROUTE)
})
const { confirmSeedWords, history } = this.props
confirmSeedWords()
.then(() => history.push(DEFAULT_ROUTE))
}
render () {
const { seedWords, confirmSeedWords, history } = this.props
const { seedWords } = this.props
const { selectedSeeds, shuffledSeeds } = this.state
const isValid = seedWords === selectedSeeds.map(([_, seed]) => seed).join(' ')

View File

@ -1,19 +1,16 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import {connect} from 'react-redux'
import { withRouter, Redirect } from 'react-router-dom'
import { withRouter } from 'react-router-dom'
import { compose } from 'recompose'
import { createNewVaultAndKeychain } from '../../../../ui/app/actions'
import LoadingScreen from './loading-screen'
import Breadcrumbs from './breadcrumbs'
import EventEmitter from 'events'
import Mascot from '../../../../ui/app/components/mascot'
import classnames from 'classnames'
import {
DEFAULT_ROUTE,
INITIALIZE_UNIQUE_IMAGE_ROUTE,
INITIALIZE_IMPORT_WITH_SEED_PHRASE_ROUTE,
// INITIALIZE_IMPORT_ACCOUNT_ROUTE,
INITIALIZE_NOTICE_ROUTE,
} from '../../../../ui/app/routes'
@ -30,19 +27,17 @@ class CreatePasswordScreen extends Component {
state = {
password: '',
confirmPassword: '',
isLoading: false,
}
constructor () {
super()
constructor (props) {
super(props)
this.animationEventEmitter = new EventEmitter()
}
componentWillMount () {
const { isInitialized, isUnlocked, history, noActiveNotices } = this.props
const { isInitialized, history } = this.props
if (isInitialized) {
console.log('%c IM already initialized', 'background: #222; color: #bada55')
history.push(INITIALIZE_NOTICE_ROUTE)
}
}
@ -71,16 +66,11 @@ class CreatePasswordScreen extends Component {
this.setState({ isLoading: true })
createAccount(password)
.then(() => {
// this.setState({ isLoading: false })
history.push(INITIALIZE_UNIQUE_IMAGE_ROUTE)
})
.catch(() => this.setState({ isLoading: false}))
.then(() => history.push(INITIALIZE_UNIQUE_IMAGE_ROUTE))
}
renderFields () {
const { isMascara, history } = this.props
const { isLoading } = this.state
return (
<div className={classnames({ 'first-view-main-wrapper': !isMascara })}>
@ -154,20 +144,7 @@ class CreatePasswordScreen extends Component {
}
render () {
const { isInitialized, isUnlocked, history, noActiveNotices, isMascara } = this.props
// if (isInitialized) {
// console.log('%c IM already initialized', 'background: #222; color: #bada55')
// if (!noActiveNotices) {
// console.log('%c GOING TO NOTICES', 'background: #222; color: #bada55')
// // history.replace(INITIALIZE_NOTICE_ROUTE)
// return <Redirect to={INITIALIZE_NOTICE_ROUTE} />
// } else {
// console.log('%c GOING TO DEFAULT', 'background: #222; color: #bada55')
// // history.replace(DEFAULT_ROUTE)
// return <Redirect to={DEFAULT_ROUTE} />
// }
// }
const { history, isMascara } = this.props
return (
<div className={classnames({ 'first-view-main-wrapper': !isMascara })}>

View File

@ -142,7 +142,6 @@ class ImportAccountScreen extends Component {
render () {
const { OPTIONS } = ImportAccountScreen
const { selectedOption } = this.state
console.log('RENDER IMPORT')
return this.props.isLoading
? <LoadingScreen loadingMessage="Creating your new account" />

View File

@ -1,7 +1,7 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import {connect} from 'react-redux'
import { withRouter, Switch, Route, Redirect } from 'react-router-dom'
import { withRouter, Switch, Route } from 'react-router-dom'
import { compose } from 'recompose'
import CreatePasswordScreen from './create-password-screen'
import UniqueImageScreen from './unique-image-screen'
@ -11,13 +11,6 @@ import ImportAccountScreen from './import-account-screen'
import ImportSeedPhraseScreen from './import-seed-phrase-screen'
import ConfirmSeed from './confirm-seed-screen'
import {
onboardingBuyEthView,
unMarkPasswordForgotten,
showModal,
} from '../../../../ui/app/actions'
import {
DEFAULT_ROUTE,
WELCOME_ROUTE,
INITIALIZE_ROUTE,
INITIALIZE_IMPORT_ACCOUNT_ROUTE,
INITIALIZE_UNIQUE_IMAGE_ROUTE,
@ -48,131 +41,6 @@ class FirstTimeFlow extends Component {
noActiveNotices: false,
};
static SCREEN_TYPE = {
CREATE_PASSWORD: 'create_password',
IMPORT_ACCOUNT: 'import_account',
IMPORT_SEED_PHRASE: 'import_seed_phrase',
UNIQUE_IMAGE: 'unique_image',
NOTICE: 'notice',
BACK_UP_PHRASE: 'back_up_phrase',
CONFIRM_BACK_UP_PHRASE: 'confirm_back_up_phrase',
LOADING: 'loading',
};
constructor (props) {
super(props)
this.state = {
screenType: this.getScreenType(),
}
}
componentDidMount () {
const { isInitialized, isUnlocked, history, noActiveNotices } = this.props
// if (isInitialized || isUnlocked) {
// history.push(DEFAULT_ROUTE)
// }
// if (!noActiveNotices) {
// console.log('INITIALIZE ACTIVE NOTICES')
// history.push(INITIALIZE_NOTICE_ROUTE)
// }
}
setScreenType (screenType) {
this.setState({ screenType })
}
getScreenType () {
const {
isInitialized,
seedWords,
noActiveNotices,
forgottenPassword,
} = this.props
const {SCREEN_TYPE} = FirstTimeFlow
// return SCREEN_TYPE.NOTICE
if (forgottenPassword) {
return SCREEN_TYPE.IMPORT_SEED_PHRASE
}
if (!isInitialized) {
return SCREEN_TYPE.CREATE_PASSWORD
}
if (!noActiveNotices) {
return SCREEN_TYPE.NOTICE
}
if (seedWords) {
return SCREEN_TYPE.BACK_UP_PHRASE
}
};
renderScreen () {
const {SCREEN_TYPE} = FirstTimeFlow
const {
openBuyEtherModal,
address,
restoreCreatePasswordScreen,
forgottenPassword,
leaveImportSeedScreenState,
} = this.props
switch (this.state.screenType) {
case SCREEN_TYPE.CREATE_PASSWORD:
return (
<CreatePasswordScreen
next={() => this.setScreenType(SCREEN_TYPE.UNIQUE_IMAGE)}
goToImportAccount={() => this.setScreenType(SCREEN_TYPE.IMPORT_ACCOUNT)}
goToImportWithSeedPhrase={() => this.setScreenType(SCREEN_TYPE.IMPORT_SEED_PHRASE)}
/>
)
case SCREEN_TYPE.IMPORT_ACCOUNT:
return (
<ImportAccountScreen
back={() => this.setScreenType(SCREEN_TYPE.CREATE_PASSWORD)}
next={() => this.setScreenType(SCREEN_TYPE.NOTICE)}
/>
)
case SCREEN_TYPE.IMPORT_SEED_PHRASE:
return (
<ImportSeedPhraseScreen
back={() => {
leaveImportSeedScreenState()
this.setScreenType(SCREEN_TYPE.CREATE_PASSWORD)
}}
next={() => {
const newScreenType = forgottenPassword ? null : SCREEN_TYPE.NOTICE
this.setScreenType(newScreenType)
}}
/>
)
case SCREEN_TYPE.UNIQUE_IMAGE:
return (
<UniqueImageScreen
next={() => this.setScreenType(SCREEN_TYPE.NOTICE)}
/>
)
case SCREEN_TYPE.NOTICE:
return (
<NoticeScreen
next={() => this.setScreenType(SCREEN_TYPE.BACK_UP_PHRASE)}
/>
)
case SCREEN_TYPE.BACK_UP_PHRASE:
return (
<BackupPhraseScreen
next={() => openBuyEtherModal()}
/>
)
default:
return <noscript />
}
}
render () {
return (
<div className="first-time-flow">
@ -219,12 +87,7 @@ const mapStateToProps = ({ metamask }) => {
}
}
const mapDispatchToProps = dispatch => ({
leaveImportSeedScreenState: () => dispatch(unMarkPasswordForgotten()),
openBuyEtherModal: () => dispatch(showModal({ name: 'DEPOSIT_ETHER'})),
})
export default compose(
withRouter,
connect(mapStateToProps, mapDispatchToProps)
connect(mapStateToProps)
)(FirstTimeFlow)

View File

@ -8,11 +8,7 @@ import debounce from 'lodash.debounce'
import { markNoticeRead } from '../../../../ui/app/actions'
import Identicon from '../../../../ui/app/components/identicon'
import Breadcrumbs from './breadcrumbs'
import {
INITIALIZE_ROUTE,
DEFAULT_ROUTE,
INITIALIZE_BACKUP_PHRASE_ROUTE,
} from '../../../../ui/app/routes'
import { INITIALIZE_BACKUP_PHRASE_ROUTE } from '../../../../ui/app/routes'
import LoadingScreen from './loading-screen'
class NoticeScreen extends Component {
@ -42,9 +38,8 @@ class NoticeScreen extends Component {
atBottom: false,
}
componentWillMount () {
componentDidMount () {
if (this.props.noActiveNotices) {
console.log('%c NOTICESCREEN NOACTIVENOTICES', 'background: #222; color: #bada55')
this.props.history.push(INITIALIZE_BACKUP_PHRASE_ROUTE)
}
@ -55,7 +50,6 @@ class NoticeScreen extends Component {
const { markNoticeRead, lastUnreadNotice, history } = this.props
markNoticeRead(lastUnreadNotice)
.then(hasActiveNotices => {
console.log('ACCEPT TERMS, NO ACTIVE NOTICES', hasActiveNotices, 'background: #222; color: #bada55')
if (!hasActiveNotices) {
history.push(INITIALIZE_BACKUP_PHRASE_ROUTE)
} else {

View File

@ -59,6 +59,7 @@ class BackupPhraseScreen extends Component {
componentWillMount () {
const { seedWords, history } = this.props
if (!seedWords) {
history.push(DEFAULT_ROUTE)
}

View File

@ -1,7 +1,7 @@
const { Component } = require('react')
const PropTypes = require('prop-types')
const connect = require('react-redux').connect
const { Route, Switch, Redirect, withRouter } = require('react-router-dom')
const { Route, Switch, withRouter } = require('react-router-dom')
const { compose } = require('recompose')
const h = require('react-hyperscript')
const actions = require('./actions')
@ -9,17 +9,10 @@ const classnames = require('classnames')
// init
const InitializeScreen = require('../../mascara/src/app/first-time').default
const WelcomeScreen = require('./welcome-screen').default
const NewKeyChainScreen = require('./new-keychain')
// mascara
const MascaraCreatePassword = require('../../mascara/src/app/first-time/create-password-screen').default
const MascaraBuyEtherScreen = require('../../mascara/src/app/first-time/buy-ether-screen').default
const MascaraNoticeScreen = require('../../mascara/src/app/first-time/notice-screen').default
const MascaraSeedScreen = require('../../mascara/src/app/first-time/seed-screen').default
const MascaraConfirmSeedScreen = require('../../mascara/src/app/first-time/confirm-seed-screen').default
// accounts
const MainContainer = require('./main-container')
const SendTransactionScreen2 = require('./components/send/send-v2-container')
const ConfirmTxScreen = require('./conf-tx')
@ -41,11 +34,9 @@ const NoticeScreen = require('./components/pages/notice')
const Loading = require('./components/loading')
const NetworkIndicator = require('./components/network')
const Identicon = require('./components/identicon')
const BuyView = require('./components/buy-button-subview')
const ReactCSSTransitionGroup = require('react-addons-css-transition-group')
const NetworkDropdown = require('./components/dropdowns/network-dropdown')
const AccountMenu = require('./components/account-menu')
const QrView = require('./components/qr-code')
// Global Modals
const Modal = require('./components/modals/index').Modal
@ -56,7 +47,6 @@ const {
UNLOCK_ROUTE,
SETTINGS_ROUTE,
REVEAL_SEED_ROUTE,
CONFIRM_SEED_ROUTE,
RESTORE_VAULT_ROUTE,
ADD_TOKEN_ROUTE,
NEW_ACCOUNT_ROUTE,
@ -64,17 +54,9 @@ const {
CONFIRM_TRANSACTION_ROUTE,
INITIALIZE_ROUTE,
NOTICE_ROUTE,
SIGNATURE_REQUEST_ROUTE,
WELCOME_ROUTE,
} = require('./routes')
class App extends Component {
// constructor (props) {
// super(props)
// this.renderPrimary = this.renderPrimary.bind(this)
// }
componentWillMount () {
const { currentCurrency, setCurrentCurrencyToUSD } = this.props
@ -340,206 +322,6 @@ class App extends Component {
})
}
// renderPrimary () {
// log.debug('rendering primary')
// const {
// noActiveNotices,
// lostAccounts,
// forgottenPassword,
// currentView,
// activeAddress,
// unapprovedTxs = {},
// seedWords,
// unapprovedMsgCount = 0,
// unapprovedPersonalMsgCount = 0,
// unapprovedTypedMessagesCount = 0,
// } = this.props
// // seed words
// if (seedWords) {
// log.debug('rendering seed words')
// return h(Redirect, {
// to: {
// pathname: REVEAL_SEED_ROUTE,
// },
// })
// }
// if (forgottenPassword) {
// log.debug('rendering restore vault screen')
// return h(Redirect, {
// to: {
// pathname: RESTORE_VAULT_ROUTE,
// },
// })
// }
// // notices
// if (!noActiveNotices || (lostAccounts && lostAccounts.length > 0)) {
// return h(Redirect, {
// to: {
// pathname: NOTICE_ROUTE,
// },
// })
// }
// // unapprovedTxs and unapproved messages
// if (Object.keys(unapprovedTxs).length ||
// unapprovedTypedMessagesCount + unapprovedMsgCount + unapprovedPersonalMsgCount > 0) {
// return h(Redirect, {
// to: {
// pathname: CONFIRM_TRANSACTION_ROUTE,
// },
// })
// }
// // if (!props.noActiveNotices) {
// // log.debug('rendering notice screen for unread notices.')
// // return h(NoticeScreen, {
// // notice: props.lastUnreadNotice,
// // key: 'NoticeScreen',
// // onConfirm: () => props.dispatch(actions.markNoticeRead(props.lastUnreadNotice)),
// // })
// // } else if (props.lostAccounts && props.lostAccounts.length > 0) {
// // log.debug('rendering notice screen for lost accounts view.')
// // return h(NoticeScreen, {
// // notice: generateLostAccountsNotice(props.lostAccounts),
// // key: 'LostAccountsNotice',
// // onConfirm: () => props.dispatch(actions.markAccountsFound()),
// // })
// // }
// // if (props.seedWords) {
// // log.debug('rendering seed words')
// // return h(HDCreateVaultComplete, {key: 'HDCreateVaultComplete'})
// // }
// // show initialize screen
// // if (!isInitialized || forgottenPassword) {
// // // show current view
// // log.debug('rendering an initialize screen')
// // // switch (props.currentView.name) {
// // // case 'restoreVault':
// // // log.debug('rendering restore vault screen')
// // // return h(HDRestoreVaultScreen, {key: 'HDRestoreVaultScreen'})
// // // default:
// // // log.debug('rendering menu screen')
// // // return h(InitializeScreen, {key: 'menuScreenInit'})
// // // }
// // }
// // // show unlock screen
// // if (!props.isUnlocked) {
// // return h(MainContainer, {
// // currentViewName: props.currentView.name,
// // isUnlocked: props.isUnlocked,
// // })
// // }
// // show current view
// switch (currentView.name) {
// case 'accountDetail':
// log.debug('rendering main container')
// return h(MainContainer, {key: 'account-detail'})
// // case 'sendTransaction':
// // log.debug('rendering send tx screen')
// // // Going to leave this here until we are ready to delete SendTransactionScreen v1
// // // const SendComponentToRender = checkFeatureToggle('send-v2')
// // // ? SendTransactionScreen2
// // // : SendTransactionScreen
// // return h(SendTransactionScreen2, {key: 'send-transaction'})
// // case 'sendToken':
// // log.debug('rendering send token screen')
// // // Going to leave this here until we are ready to delete SendTransactionScreen v1
// // // const SendTokenComponentToRender = checkFeatureToggle('send-v2')
// // // ? SendTransactionScreen2
// // // : SendTokenScreen
// // return h(SendTransactionScreen2, {key: 'sendToken'})
// case 'newKeychain':
// log.debug('rendering new keychain screen')
// return h(NewKeyChainScreen, {key: 'new-keychain'})
// // case 'confTx':
// // log.debug('rendering confirm tx screen')
// // return h(Redirect, {
// // to: {
// // pathname: CONFIRM_TRANSACTION_ROUTE,
// // },
// // })
// // return h(ConfirmTxScreen, {key: 'confirm-tx'})
// // case 'add-token':
// // log.debug('rendering add-token screen from unlock screen.')
// // return h(AddTokenScreen, {key: 'add-token'})
// // case 'config':
// // log.debug('rendering config screen')
// // return h(Settings, {key: 'config'})
// // case 'import-menu':
// // log.debug('rendering import screen')
// // return h(Import, {key: 'import-menu'})
// // case 'reveal-seed-conf':
// // log.debug('rendering reveal seed confirmation screen')
// // return h(RevealSeedConfirmation, {key: 'reveal-seed-conf'})
// // case 'info':
// // log.debug('rendering info screen')
// // return h(Settings, {key: 'info', tab: 'info'})
// case 'buyEth':
// log.debug('rendering buy ether screen')
// return h(BuyView, {key: 'buyEthView'})
// case 'onboardingBuyEth':
// log.debug('rendering onboarding buy ether screen')
// return h(MascaraBuyEtherScreen, {key: 'buyEthView'})
// case 'qr':
// log.debug('rendering show qr screen')
// return h('div', {
// style: {
// position: 'absolute',
// height: '100%',
// top: '0px',
// left: '0px',
// },
// }, [
// h('i.fa.fa-arrow-left.fa-lg.cursor-pointer.color-orange', {
// onClick: () => this.props.dispatch(actions.backToAccountDetail(activeAddress)),
// style: {
// marginLeft: '10px',
// marginTop: '50px',
// },
// }),
// h('div', {
// style: {
// position: 'absolute',
// left: '44px',
// width: '285px',
// },
// }, [
// h(QrView, {key: 'qr'}),
// ]),
// ])
// default:
// log.debug('rendering default, account detail screen')
// return h(MainContainer, {key: 'account-detail'})
// }
// }
toggleMetamaskActive () {
if (!this.props.isUnlocked) {
// currently inactive: redirect to password box

View File

@ -35,8 +35,6 @@ class Home extends Component {
unapprovedTypedMessagesCount = 0,
} = this.props
console.log('HOME MOUNTED')
// unapprovedTxs and unapproved messages
if (Object.keys(unapprovedTxs).length ||
unapprovedTypedMessagesCount + unapprovedMsgCount + unapprovedPersonalMsgCount > 0) {

View File

@ -65,7 +65,6 @@ class RestoreVaultPage extends PersistentForm {
render () {
const { error } = this.state
const { history } = this.props
this.persistentFormParentId = 'restore-vault-form'
return (

View File

@ -131,7 +131,6 @@ class UnlockScreen extends Component {
this.props.markPasswordForgotten()
this.props.history.push(RESTORE_VAULT_ROUTE)
console.log('typeeee', environmentType())
if (environmentType() === 'popup') {
global.platform.openExtensionInBrowser()
}

View File

@ -56,7 +56,6 @@ function ConfirmTxScreen () {
}
ConfirmTxScreen.prototype.componentDidUpdate = function (prevProps) {
console.log('CONFTX COMPONENTDIDUPDATE')
const {
unapprovedTxs,
network,
@ -69,7 +68,6 @@ ConfirmTxScreen.prototype.componentDidUpdate = function (prevProps) {
const unconfTxList = txHelper(unapprovedTxs, {}, {}, {}, network)
if (prevTx.status === 'dropped' && unconfTxList.length === 0) {
console.log('CONFTX REDIRECTINGTODEFAULT')
this.props.history.push(DEFAULT_ROUTE)
}
}
@ -90,7 +88,6 @@ ConfirmTxScreen.prototype.render = function () {
} = props
var unconfTxList = txHelper(unapprovedTxs, unapprovedMsgs, unapprovedPersonalMsgs, unapprovedTypedMessages, network)
console.log('UNCONF', unconfTxList, props.index, props)
var txData = unconfTxList[props.index] || {}
var txParams = txData.params || {}
@ -147,7 +144,6 @@ function currentTxView (opts) {
log.info('rendering current tx view')
const { txData } = opts
const { txParams, msgParams } = txData
console.log('TXPARAMS', txParams, msgParams)
if (txParams) {
log.debug('txParams detected, rendering pending tx')

View File

@ -3,7 +3,6 @@ const { Component } = require('react')
const PropTypes = require('prop-types')
const connect = require('react-redux').connect
const h = require('react-hyperscript')
const PropTypes = require('prop-types')
const Mascot = require('../components/mascot')
const actions = require('../actions')
const Tooltip = require('../components/tooltip')

View File

@ -12,6 +12,7 @@ import { INITIALIZE_CREATE_PASSWORD_ROUTE } from './routes'
class WelcomeScreen extends Component {
static propTypes = {
closeWelcomeScreen: PropTypes.func.isRequired,
welcomeScreenSeen: PropTypes.bool,
history: PropTypes.object,
}
@ -24,7 +25,6 @@ class WelcomeScreen extends Component {
const { history, welcomeScreenSeen } = this.props
if (welcomeScreenSeen) {
console.log('SEENT', welcomeScreenSeen)
history.push(INITIALIZE_CREATE_PASSWORD_ROUTE)
}
}