commit
1e9c0a9db2
@ -1,4 +1,4 @@ |
|||||||
{ |
{ |
||||||
"presets": ["es2015", "stage-0"], |
"presets": ["es2015", "stage-0", "react"], |
||||||
"plugins": ["transform-runtime", "transform-async-to-generator"] |
"plugins": ["transform-runtime", "transform-async-to-generator"] |
||||||
} |
} |
||||||
|
After Width: | Height: | Size: 2.1 KiB |
@ -0,0 +1,254 @@ |
|||||||
|
import React, {Component, PropTypes} from 'react' |
||||||
|
import {connect} from 'react-redux'; |
||||||
|
import classnames from 'classnames' |
||||||
|
import shuffle from 'lodash.shuffle' |
||||||
|
import {compose, onlyUpdateForPropTypes} from 'recompose' |
||||||
|
import Identicon from '../../../../ui/app/components/identicon' |
||||||
|
import {confirmSeedWords} from '../../../../ui/app/actions' |
||||||
|
import Breadcrumbs from './breadcrumbs' |
||||||
|
import LoadingScreen from './loading-screen' |
||||||
|
|
||||||
|
const LockIcon = props => ( |
||||||
|
<svg |
||||||
|
version="1.1" |
||||||
|
id="Capa_1" |
||||||
|
xmlns="http://www.w3.org/2000/svg" |
||||||
|
xmlnsXlink="http://www.w3.org/1999/xlink" |
||||||
|
x="0px" |
||||||
|
y="0px" |
||||||
|
width="401.998px" |
||||||
|
height="401.998px" |
||||||
|
viewBox="0 0 401.998 401.998" |
||||||
|
style={{enableBackground: 'new 0 0 401.998 401.998'}} |
||||||
|
xmlSpace="preserve" |
||||||
|
{...props} |
||||||
|
> |
||||||
|
<g> |
||||||
|
<path |
||||||
|
d="M357.45,190.721c-5.331-5.33-11.8-7.993-19.417-7.993h-9.131v-54.821c0-35.022-12.559-65.093-37.685-90.218 |
||||||
|
C266.093,12.563,236.025,0,200.998,0c-35.026,0-65.1,12.563-90.222,37.688C85.65,62.814,73.091,92.884,73.091,127.907v54.821 |
||||||
|
h-9.135c-7.611,0-14.084,2.663-19.414,7.993c-5.33,5.326-7.994,11.799-7.994,19.417V374.59c0,7.611,2.665,14.086,7.994,19.417 |
||||||
|
c5.33,5.325,11.803,7.991,19.414,7.991H338.04c7.617,0,14.085-2.663,19.417-7.991c5.325-5.331,7.994-11.806,7.994-19.417V210.135 |
||||||
|
C365.455,202.523,362.782,196.051,357.45,190.721z M274.087,182.728H127.909v-54.821c0-20.175,7.139-37.402,21.414-51.675 |
||||||
|
c14.277-14.275,31.501-21.411,51.678-21.411c20.179,0,37.399,7.135,51.677,21.411c14.271,14.272,21.409,31.5,21.409,51.675V182.728 |
||||||
|
z" |
||||||
|
/> |
||||||
|
</g> |
||||||
|
</svg> |
||||||
|
); |
||||||
|
|
||||||
|
class BackupPhraseScreen extends Component { |
||||||
|
static propTypes = { |
||||||
|
isLoading: PropTypes.bool.isRequired, |
||||||
|
address: PropTypes.string.isRequired, |
||||||
|
seedWords: PropTypes.string.isRequired, |
||||||
|
next: PropTypes.func.isRequired, |
||||||
|
confirmSeedWords: PropTypes.func.isRequired, |
||||||
|
}; |
||||||
|
|
||||||
|
static defaultProps = { |
||||||
|
seedWords: '' |
||||||
|
}; |
||||||
|
|
||||||
|
static PAGE = { |
||||||
|
SECRET: 'secret', |
||||||
|
CONFIRM: 'confirm' |
||||||
|
}; |
||||||
|
|
||||||
|
constructor(props) { |
||||||
|
const {seedWords} = props |
||||||
|
super(props) |
||||||
|
this.state = { |
||||||
|
isShowingSecret: false, |
||||||
|
page: BackupPhraseScreen.PAGE.SECRET, |
||||||
|
selectedSeeds: [], |
||||||
|
shuffledSeeds: seedWords && shuffle(seedWords.split(' ')), |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
renderSecretWordsContainer () { |
||||||
|
const { isShowingSecret } = this.state |
||||||
|
|
||||||
|
return ( |
||||||
|
<div className="backup-phrase__secret"> |
||||||
|
<div className={classnames('backup-phrase__secret-words', { |
||||||
|
'backup-phrase__secret-words--hidden': !isShowingSecret |
||||||
|
})}> |
||||||
|
{this.props.seedWords} |
||||||
|
</div> |
||||||
|
{!isShowingSecret && ( |
||||||
|
<div className="backup-phrase__secret-blocker"> |
||||||
|
<LockIcon width="28px" height="35px" fill="#FFFFFF" /> |
||||||
|
<button |
||||||
|
className="backup-phrase__reveal-button" |
||||||
|
onClick={() => this.setState({ isShowingSecret: true })} |
||||||
|
> |
||||||
|
Click here to reveal secret words |
||||||
|
</button> |
||||||
|
</div> |
||||||
|
)} |
||||||
|
</div> |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
renderSecretScreen() { |
||||||
|
const { isShowingSecret } = this.state |
||||||
|
|
||||||
|
return ( |
||||||
|
<div className="backup-phrase__content-wrapper"> |
||||||
|
<div> |
||||||
|
<div className="backup-phrase__title">Secret Backup Phrase</div> |
||||||
|
<div className="backup-phrase__body-text"> |
||||||
|
Your secret backup phrase makes it easy to back up and restore your account. |
||||||
|
</div> |
||||||
|
<div className="backup-phrase__body-text"> |
||||||
|
WARNING: Never disclose your backup phrase. Anyone with this phrase can take your Ether forever. |
||||||
|
</div> |
||||||
|
{this.renderSecretWordsContainer()} |
||||||
|
<button |
||||||
|
className="first-time-flow__button" |
||||||
|
onClick={() => isShowingSecret && this.setState({ |
||||||
|
isShowingSecret: false, |
||||||
|
page: BackupPhraseScreen.PAGE.CONFIRM |
||||||
|
})} |
||||||
|
disabled={!isShowingSecret} |
||||||
|
> |
||||||
|
Next |
||||||
|
</button> |
||||||
|
<Breadcrumbs total={3} currentIndex={1} /> |
||||||
|
</div> |
||||||
|
<div className="backup-phrase__tips"> |
||||||
|
<div className="backup-phrase__tips-text">Tips:</div> |
||||||
|
<div className="backup-phrase__tips-text"> |
||||||
|
Store this phrase in a password manager like 1password. |
||||||
|
</div> |
||||||
|
<div className="backup-phrase__tips-text"> |
||||||
|
Write this phrase on a piece of paper and store in a secure location. If you want even more security, write it down on multiple pieces of paper and store each in 2 - 3 different locations. |
||||||
|
</div> |
||||||
|
<div className="backup-phrase__tips-text"> |
||||||
|
Memorize this phrase. |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
) |
||||||
|
} |
||||||
|
|
||||||
|
renderConfirmationScreen() { |
||||||
|
const { seedWords, confirmSeedWords, next } = this.props; |
||||||
|
const { selectedSeeds, shuffledSeeds } = this.state; |
||||||
|
const isValid = seedWords === selectedSeeds.map(([_, seed]) => seed).join(' ') |
||||||
|
|
||||||
|
return ( |
||||||
|
<div className="backup-phrase__content-wrapper"> |
||||||
|
<div> |
||||||
|
<div className="backup-phrase__title">Confirm your Secret Backup Phrase</div> |
||||||
|
<div className="backup-phrase__body-text"> |
||||||
|
Please select each phrase in order to make sure it is correct. |
||||||
|
</div> |
||||||
|
<div className="backup-phrase__confirm-secret"> |
||||||
|
{selectedSeeds.map(([_, word], i) => ( |
||||||
|
<button |
||||||
|
key={i} |
||||||
|
className="backup-phrase__confirm-seed-option" |
||||||
|
> |
||||||
|
{word} |
||||||
|
</button> |
||||||
|
))} |
||||||
|
</div> |
||||||
|
<div className="backup-phrase__confirm-seed-options"> |
||||||
|
{shuffledSeeds.map((word, i) => { |
||||||
|
const isSelected = selectedSeeds |
||||||
|
.filter(([index, seed]) => seed === word && index === i) |
||||||
|
.length |
||||||
|
|
||||||
|
return ( |
||||||
|
<button |
||||||
|
key={i} |
||||||
|
className={classnames('backup-phrase__confirm-seed-option', { |
||||||
|
'backup-phrase__confirm-seed-option--selected': isSelected |
||||||
|
})} |
||||||
|
onClick={() => { |
||||||
|
if (!isSelected) { |
||||||
|
this.setState({ |
||||||
|
selectedSeeds: [...selectedSeeds, [i, word]] |
||||||
|
}) |
||||||
|
} else { |
||||||
|
this.setState({ |
||||||
|
selectedSeeds: selectedSeeds |
||||||
|
.filter(([index, seed]) => !(seed === word && index === i)) |
||||||
|
}) |
||||||
|
} |
||||||
|
}} |
||||||
|
> |
||||||
|
{word} |
||||||
|
</button> |
||||||
|
) |
||||||
|
})} |
||||||
|
</div> |
||||||
|
<button |
||||||
|
className="first-time-flow__button" |
||||||
|
onClick={() => isValid && confirmSeedWords().then(next)} |
||||||
|
disabled={!isValid} |
||||||
|
> |
||||||
|
Confirm |
||||||
|
</button> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
)
|
||||||
|
} |
||||||
|
|
||||||
|
renderBack () { |
||||||
|
return this.state.page === BackupPhraseScreen.PAGE.CONFIRM |
||||||
|
? ( |
||||||
|
<a |
||||||
|
className="backup-phrase__back-button" |
||||||
|
onClick={e => { |
||||||
|
e.preventDefault() |
||||||
|
this.setState({ |
||||||
|
page: BackupPhraseScreen.PAGE.SECRET |
||||||
|
}) |
||||||
|
}} |
||||||
|
href="#" |
||||||
|
> |
||||||
|
{`< Back`} |
||||||
|
</a> |
||||||
|
) |
||||||
|
: null |
||||||
|
} |
||||||
|
|
||||||
|
renderContent () { |
||||||
|
switch (this.state.page) { |
||||||
|
case BackupPhraseScreen.PAGE.CONFIRM: |
||||||
|
return this.renderConfirmationScreen() |
||||||
|
case BackupPhraseScreen.PAGE.SECRET: |
||||||
|
default: |
||||||
|
return this.renderSecretScreen() |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
render () { |
||||||
|
return this.props.isLoading |
||||||
|
? <LoadingScreen loadingMessage="Creating your new account" /> |
||||||
|
: ( |
||||||
|
<div className="backup-phrase"> |
||||||
|
{this.renderBack()} |
||||||
|
<Identicon address={this.props.address} diameter={70} /> |
||||||
|
{this.renderContent()} |
||||||
|
</div> |
||||||
|
) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
export default compose( |
||||||
|
onlyUpdateForPropTypes, |
||||||
|
connect( |
||||||
|
({ metamask: { selectedAddress, seedWords }, appState: { isLoading } }) => ({ |
||||||
|
seedWords, |
||||||
|
isLoading, |
||||||
|
address: selectedAddress, |
||||||
|
}), |
||||||
|
dispatch => ({ |
||||||
|
confirmSeedWords: () => dispatch(confirmSeedWords()), |
||||||
|
}) |
||||||
|
) |
||||||
|
)(BackupPhraseScreen) |
@ -0,0 +1,25 @@ |
|||||||
|
import React, {Component, PropTypes} from 'react' |
||||||
|
|
||||||
|
export default class Breadcrumbs extends Component { |
||||||
|
|
||||||
|
static propTypes = { |
||||||
|
total: PropTypes.number, |
||||||
|
currentIndex: PropTypes.number |
||||||
|
}; |
||||||
|
|
||||||
|
render() { |
||||||
|
const {total, currentIndex} = this.props |
||||||
|
return ( |
||||||
|
<div className="breadcrumbs"> |
||||||
|
{Array(total).fill().map((_, i) => ( |
||||||
|
<div |
||||||
|
key={i} |
||||||
|
className="breadcrumb" |
||||||
|
style={{backgroundColor: i === currentIndex ? '#D8D8D8' : '#FFFFFF'}} |
||||||
|
/> |
||||||
|
))} |
||||||
|
</div> |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,199 @@ |
|||||||
|
import React, {Component, PropTypes} from 'react' |
||||||
|
import classnames from 'classnames' |
||||||
|
import {connect} from 'react-redux' |
||||||
|
import {qrcode} from 'qrcode-npm' |
||||||
|
import copyToClipboard from 'copy-to-clipboard' |
||||||
|
import ShapeShiftForm from '../shapeshift-form' |
||||||
|
import Identicon from '../../../../ui/app/components/identicon' |
||||||
|
import {buyEth, showAccountDetail} from '../../../../ui/app/actions' |
||||||
|
|
||||||
|
class BuyEtherScreen extends Component { |
||||||
|
static OPTION_VALUES = { |
||||||
|
COINBASE: 'coinbase', |
||||||
|
SHAPESHIFT: 'shapeshift', |
||||||
|
QR_CODE: 'qr_code', |
||||||
|
}; |
||||||
|
|
||||||
|
static OPTIONS = [ |
||||||
|
{ |
||||||
|
name: 'Direct Deposit', |
||||||
|
value: BuyEtherScreen.OPTION_VALUES.QR_CODE, |
||||||
|
}, |
||||||
|
{ |
||||||
|
name: 'Buy with Dollars', |
||||||
|
value: BuyEtherScreen.OPTION_VALUES.COINBASE, |
||||||
|
}, |
||||||
|
{ |
||||||
|
name: 'Buy with Cryptos', |
||||||
|
value: BuyEtherScreen.OPTION_VALUES.SHAPESHIFT, |
||||||
|
}, |
||||||
|
]; |
||||||
|
|
||||||
|
static propTypes = { |
||||||
|
address: PropTypes.string, |
||||||
|
goToCoinbase: PropTypes.func.isRequired, |
||||||
|
showAccountDetail: PropTypes.func.isRequired, |
||||||
|
} |
||||||
|
|
||||||
|
state = { |
||||||
|
selectedOption: BuyEtherScreen.OPTION_VALUES.QR_CODE, |
||||||
|
justCopied: false, |
||||||
|
} |
||||||
|
|
||||||
|
copyToClipboard = () => { |
||||||
|
const { address } = this.props |
||||||
|
|
||||||
|
this.setState({ justCopied: true }, () => copyToClipboard(address)) |
||||||
|
|
||||||
|
setTimeout(() => this.setState({ justCopied: false }), 1000) |
||||||
|
} |
||||||
|
|
||||||
|
renderSkip () { |
||||||
|
const {showAccountDetail, address} = this.props |
||||||
|
|
||||||
|
return ( |
||||||
|
<div |
||||||
|
className='buy-ether__do-it-later' |
||||||
|
onClick={() => showAccountDetail(address)} |
||||||
|
> |
||||||
|
Do it later |
||||||
|
</div> |
||||||
|
) |
||||||
|
} |
||||||
|
|
||||||
|
renderCoinbaseLogo () { |
||||||
|
return ( |
||||||
|
<svg width='140px' height='49px' viewBox='0 0 579 126' version='1.1'> |
||||||
|
<g id='Page-1' stroke='none' strokeWidth={1} fill='none' fillRule='evenodd'> |
||||||
|
<g id='Imported-Layers' fill='#0081C9'> |
||||||
|
<path d='M37.752,125.873 C18.824,125.873 0.369,112.307 0.369,81.549 C0.369,50.79 18.824,37.382 37.752,37.382 C47.059,37.382 54.315,39.749 59.52,43.219 L53.841,55.68 C50.371,53.156 45.166,51.579 39.961,51.579 C28.604,51.579 18.193,60.57 18.193,81.391 C18.193,102.212 28.919,111.361 39.961,111.361 C45.166,111.361 50.371,109.783 53.841,107.26 L59.52,120.036 C54.157,123.664 47.059,125.873 37.752,125.873' id='Fill-1' /> |
||||||
|
<path d='M102.898,125.873 C78.765,125.873 65.515,106.786 65.515,81.549 C65.515,56.311 78.765,37.382 102.898,37.382 C127.032,37.382 140.282,56.311 140.282,81.549 C140.282,106.786 127.032,125.873 102.898,125.873 L102.898,125.873 Z M102.898,51.105 C89.491,51.105 82.866,63.093 82.866,81.391 C82.866,99.688 89.491,111.834 102.898,111.834 C116.306,111.834 122.931,99.688 122.931,81.391 C122.931,63.093 116.306,51.105 102.898,51.105 L102.898,51.105 Z' id='Fill-2' /> |
||||||
|
<path d='M163.468,23.659 C157.79,23.659 153.215,19.243 153.215,13.88 C153.215,8.517 157.79,4.1 163.468,4.1 C169.146,4.1 173.721,8.517 173.721,13.88 C173.721,19.243 169.146,23.659 163.468,23.659 L163.468,23.659 Z M154.793,39.118 L172.144,39.118 L172.144,124.138 L154.793,124.138 L154.793,39.118 Z' id='Fill-3' /> |
||||||
|
<path d='M240.443,124.137 L240.443,67.352 C240.443,57.415 234.449,51.263 222.619,51.263 C216.31,51.263 210.473,52.367 207.003,53.787 L207.003,124.137 L189.81,124.137 L189.81,43.376 C198.328,39.906 209.212,37.382 222.461,37.382 C246.28,37.382 257.794,47.793 257.794,65.775 L257.794,124.137 L240.443,124.137' id='Fill-4' /> |
||||||
|
<path d='M303.536,125.873 C292.494,125.873 281.611,123.191 274.986,119.879 L274.986,0.314 L292.179,0.314 L292.179,41.326 C296.28,39.433 302.905,37.856 308.741,37.856 C330.667,37.856 345.494,53.629 345.494,79.656 C345.494,111.676 328.931,125.873 303.536,125.873 L303.536,125.873 Z M305.744,51.263 C301.012,51.263 295.491,52.367 292.179,54.103 L292.179,109.941 C294.703,111.045 299.593,112.149 304.482,112.149 C318.205,112.149 328.301,102.685 328.301,80.918 C328.301,62.305 319.467,51.263 305.744,51.263 L305.744,51.263 Z' id='Fill-5' /> |
||||||
|
<path d='M392.341,125.873 C367.892,125.873 355.589,115.935 355.589,99.215 C355.589,75.555 380.826,71.296 406.537,69.876 L406.537,64.513 C406.537,53.787 399.439,50.001 388.555,50.001 C380.511,50.001 370.731,52.525 365.053,55.207 L360.636,43.376 C367.419,40.379 378.933,37.382 390.29,37.382 C410.638,37.382 422.942,45.269 422.942,66.248 L422.942,119.879 C416.79,123.191 404.329,125.873 392.341,125.873 L392.341,125.873 Z M406.537,81.391 C389.186,82.337 371.835,83.757 371.835,98.9 C371.835,107.89 378.776,113.411 391.868,113.411 C397.389,113.411 403.856,112.465 406.537,111.203 L406.537,81.391 L406.537,81.391 Z' id='Fill-6' /> |
||||||
|
<path d='M461.743,125.873 C451.806,125.873 441.395,123.191 435.244,119.879 L441.08,106.629 C445.496,109.31 454.803,112.149 461.27,112.149 C470.576,112.149 476.728,107.575 476.728,100.477 C476.728,92.748 470.261,89.751 461.586,86.596 C450.228,82.337 437.452,77.132 437.452,61.201 C437.452,47.162 448.336,37.382 467.264,37.382 C477.517,37.382 486.035,39.906 492.029,43.376 L486.665,55.364 C482.88,52.998 475.309,50.317 469.157,50.317 C460.166,50.317 455.118,55.049 455.118,61.201 C455.118,68.93 461.428,71.611 469.788,74.766 C481.618,79.183 494.71,84.072 494.71,100.635 C494.71,115.935 483.038,125.873 461.743,125.873' id='Fill-7' /> |
||||||
|
<path d='M578.625,81.233 L522.155,89.12 C523.89,104.42 533.828,112.149 548.182,112.149 C556.699,112.149 565.848,110.099 571.684,106.944 L576.732,119.879 C570.107,123.349 558.75,125.873 547.078,125.873 C520.262,125.873 505.277,108.679 505.277,81.549 C505.277,55.522 519.789,37.382 543.607,37.382 C565.69,37.382 578.782,51.894 578.782,74.766 C578.782,76.816 578.782,79.025 578.625,81.233 L578.625,81.233 Z M543.292,50.001 C530.042,50.001 521.367,60.097 521.051,77.763 L562.22,72.084 C562.062,57.257 554.649,50.001 543.292,50.001 L543.292,50.001 Z' id='Fill-8' /> |
||||||
|
</g> |
||||||
|
</g> |
||||||
|
</svg> |
||||||
|
) |
||||||
|
} |
||||||
|
|
||||||
|
renderCoinbaseForm () { |
||||||
|
const {goToCoinbase, address} = this.props |
||||||
|
|
||||||
|
return ( |
||||||
|
<div className='buy-ether__action-content-wrapper'> |
||||||
|
<div>{this.renderCoinbaseLogo()}</div> |
||||||
|
<div className='buy-ether__body-text'>Coinbase is the world’s most popular way to buy and sell bitcoin, ethereum, and litecoin.</div> |
||||||
|
<a className='first-time-flow__link buy-ether__faq-link'>What is Ethereum?</a> |
||||||
|
<div className='buy-ether__buttons'> |
||||||
|
<button |
||||||
|
className='first-time-flow__button' |
||||||
|
onClick={() => goToCoinbase(address)} |
||||||
|
> |
||||||
|
Buy |
||||||
|
</button> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
) |
||||||
|
} |
||||||
|
|
||||||
|
renderContent () { |
||||||
|
const { OPTION_VALUES } = BuyEtherScreen |
||||||
|
const { address } = this.props |
||||||
|
const { justCopied } = this.state |
||||||
|
const qrImage = qrcode(4, 'M') |
||||||
|
qrImage.addData(address) |
||||||
|
qrImage.make() |
||||||
|
|
||||||
|
switch (this.state.selectedOption) { |
||||||
|
case OPTION_VALUES.COINBASE: |
||||||
|
return this.renderCoinbaseForm() |
||||||
|
case OPTION_VALUES.SHAPESHIFT: |
||||||
|
return ( |
||||||
|
<div className='buy-ether__action-content-wrapper'> |
||||||
|
<div className='shapeshift-logo' /> |
||||||
|
<div className='buy-ether__body-text'> |
||||||
|
Trade any leading blockchain asset for any other. Protection by Design. No Account Needed. |
||||||
|
</div> |
||||||
|
<ShapeShiftForm btnClass='first-time-flow__button' /> |
||||||
|
</div> |
||||||
|
) |
||||||
|
case OPTION_VALUES.QR_CODE: |
||||||
|
return ( |
||||||
|
<div className='buy-ether__action-content-wrapper'> |
||||||
|
<div dangerouslySetInnerHTML={{ __html: qrImage.createTableTag(4) }} /> |
||||||
|
<div className='buy-ether__body-text'>Deposit Ether directly into your account.</div> |
||||||
|
<div className='buy-ether__small-body-text'>(This is the account address that MetaMask created for you to recieve funds.)</div> |
||||||
|
<div className='buy-ether__buttons'> |
||||||
|
<button |
||||||
|
className='first-time-flow__button' |
||||||
|
onClick={this.copyToClipboard} |
||||||
|
disabled={justCopied} |
||||||
|
> |
||||||
|
{ justCopied ? 'Copied' : 'Copy' } |
||||||
|
</button> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
) |
||||||
|
default: |
||||||
|
return null |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
render () { |
||||||
|
const { OPTIONS } = BuyEtherScreen |
||||||
|
const { selectedOption } = this.state |
||||||
|
|
||||||
|
return ( |
||||||
|
<div className='buy-ether'> |
||||||
|
<Identicon address={this.props.address} diameter={70} /> |
||||||
|
<div className='buy-ether__title'>Deposit Ether</div> |
||||||
|
<div className='buy-ether__body-text'> |
||||||
|
MetaMask works best if you have Ether in your account to pay for transaction gas fees and more. To get Ether, choose from one of these methods. |
||||||
|
</div> |
||||||
|
<div className='buy-ether__content-wrapper'> |
||||||
|
<div className='buy-ether__content-headline-wrapper'> |
||||||
|
<div className='buy-ether__content-headline'>Deposit Options</div> |
||||||
|
{this.renderSkip()} |
||||||
|
</div> |
||||||
|
<div className='buy-ether__content'> |
||||||
|
<div className='buy-ether__side-panel'> |
||||||
|
{OPTIONS.map(({ name, value }) => ( |
||||||
|
<div |
||||||
|
key={value} |
||||||
|
className={classnames('buy-ether__side-panel-item', { |
||||||
|
'buy-ether__side-panel-item--selected': value === selectedOption, |
||||||
|
})} |
||||||
|
onClick={() => this.setState({ selectedOption: value })} |
||||||
|
> |
||||||
|
<div className='buy-ether__side-panel-item-name'>{name}</div> |
||||||
|
{value === selectedOption && ( |
||||||
|
<svg viewBox='0 0 574 1024' id='si-ant-right' width='15px' height='15px'> |
||||||
|
<path d='M10 9Q0 19 0 32t10 23l482 457L10 969Q0 979 0 992t10 23q10 9 24 9t24-9l506-480q10-10 10-23t-10-23L58 9Q48 0 34 0T10 9z' /> |
||||||
|
</svg> |
||||||
|
)} |
||||||
|
</div> |
||||||
|
))} |
||||||
|
</div> |
||||||
|
<div className='buy-ether__action-content'> |
||||||
|
{this.renderContent()} |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
export default connect( |
||||||
|
({ metamask: { selectedAddress } }) => ({ |
||||||
|
address: selectedAddress, |
||||||
|
}), |
||||||
|
dispatch => ({ |
||||||
|
goToCoinbase: address => dispatch(buyEth({ network: '1', address, amount: 0 })), |
||||||
|
showAccountDetail: address => dispatch(showAccountDetail(address)), |
||||||
|
}) |
||||||
|
)(BuyEtherScreen) |
@ -0,0 +1,109 @@ |
|||||||
|
import React, {Component, PropTypes} from 'react' |
||||||
|
import {connect} from 'react-redux'; |
||||||
|
import {createNewVaultAndKeychain} from '../../../../ui/app/actions' |
||||||
|
import LoadingScreen from './loading-screen' |
||||||
|
import Breadcrumbs from './breadcrumbs' |
||||||
|
|
||||||
|
class CreatePasswordScreen extends Component { |
||||||
|
static propTypes = { |
||||||
|
isLoading: PropTypes.bool.isRequired, |
||||||
|
createAccount: PropTypes.func.isRequired, |
||||||
|
goToImportWithSeedPhrase: PropTypes.func.isRequired, |
||||||
|
goToImportAccount: PropTypes.func.isRequired, |
||||||
|
next: PropTypes.func.isRequired |
||||||
|
} |
||||||
|
|
||||||
|
state = { |
||||||
|
password: '', |
||||||
|
confirmPassword: '' |
||||||
|
} |
||||||
|
|
||||||
|
isValid() { |
||||||
|
const {password, confirmPassword} = this.state; |
||||||
|
|
||||||
|
if (!password || !confirmPassword) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
if (password.length < 8) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
return password === confirmPassword; |
||||||
|
} |
||||||
|
|
||||||
|
createAccount = () => { |
||||||
|
if (!this.isValid()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
const {password} = this.state; |
||||||
|
const {createAccount, next} = this.props; |
||||||
|
|
||||||
|
createAccount(password) |
||||||
|
.then(next); |
||||||
|
} |
||||||
|
|
||||||
|
render() { |
||||||
|
const { isLoading, goToImportAccount, goToImportWithSeedPhrase } = this.props |
||||||
|
|
||||||
|
return isLoading |
||||||
|
? <LoadingScreen loadingMessage="Creating your new account" /> |
||||||
|
: ( |
||||||
|
<div className="create-password"> |
||||||
|
<div className="create-password__title"> |
||||||
|
Create Password |
||||||
|
</div> |
||||||
|
<input |
||||||
|
className="first-time-flow__input" |
||||||
|
type="password" |
||||||
|
placeholder="New Password (min 8 characters)" |
||||||
|
onChange={e => this.setState({password: e.target.value})} |
||||||
|
/> |
||||||
|
<input |
||||||
|
className="first-time-flow__input create-password__confirm-input" |
||||||
|
type="password" |
||||||
|
placeholder="Confirm Password" |
||||||
|
onChange={e => this.setState({confirmPassword: e.target.value})} |
||||||
|
/> |
||||||
|
<button |
||||||
|
className="first-time-flow__button" |
||||||
|
disabled={!this.isValid()} |
||||||
|
onClick={this.createAccount} |
||||||
|
> |
||||||
|
Create |
||||||
|
</button> |
||||||
|
<a |
||||||
|
href="" |
||||||
|
className="first-time-flow__link create-password__import-link" |
||||||
|
onClick={e => { |
||||||
|
e.preventDefault() |
||||||
|
goToImportWithSeedPhrase() |
||||||
|
}} |
||||||
|
> |
||||||
|
Import with seed phrase |
||||||
|
</a> |
||||||
|
{ /* } |
||||||
|
<a |
||||||
|
href="" |
||||||
|
className="first-time-flow__link create-password__import-link" |
||||||
|
onClick={e => { |
||||||
|
e.preventDefault() |
||||||
|
goToImportAccount() |
||||||
|
}} |
||||||
|
> |
||||||
|
Import an account |
||||||
|
</a> |
||||||
|
{ */ } |
||||||
|
<Breadcrumbs total={3} currentIndex={0} /> |
||||||
|
</div> |
||||||
|
) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
export default connect( |
||||||
|
({ appState: { isLoading } }) => ({ isLoading }), |
||||||
|
dispatch => ({ |
||||||
|
createAccount: password => dispatch(createNewVaultAndKeychain(password)), |
||||||
|
}) |
||||||
|
)(CreatePasswordScreen) |
@ -0,0 +1,203 @@ |
|||||||
|
import React, {Component, PropTypes} from 'react' |
||||||
|
import {connect} from 'react-redux' |
||||||
|
import classnames from 'classnames' |
||||||
|
import LoadingScreen from './loading-screen' |
||||||
|
import {importNewAccount, hideWarning} from '../../../../ui/app/actions' |
||||||
|
|
||||||
|
const Input = ({ label, placeholder, onChange, errorMessage, type = 'text' }) => ( |
||||||
|
<div className="import-account__input-wrapper"> |
||||||
|
<div className="import-account__input-label">{label}</div> |
||||||
|
<input |
||||||
|
type={type} |
||||||
|
placeholder={placeholder} |
||||||
|
className={classnames('first-time-flow__input import-account__input', { |
||||||
|
'first-time-flow__input--error': errorMessage, |
||||||
|
})} |
||||||
|
onChange={onChange} |
||||||
|
/> |
||||||
|
<div className="import-account__input-error-message">{errorMessage}</div> |
||||||
|
</div> |
||||||
|
) |
||||||
|
|
||||||
|
Input.prototype.propTypes = { |
||||||
|
label: PropTypes.string.isRequired, |
||||||
|
placeholder: PropTypes.string.isRequired, |
||||||
|
type: PropTypes.string.isRequired, |
||||||
|
errorMessage: PropTypes.string.isRequired, |
||||||
|
onChange: PropTypes.func.isRequired, |
||||||
|
} |
||||||
|
|
||||||
|
class ImportAccountScreen extends Component { |
||||||
|
static OPTIONS = { |
||||||
|
PRIVATE_KEY: 'private_key', |
||||||
|
JSON_FILE: 'json_file', |
||||||
|
}; |
||||||
|
|
||||||
|
static propTypes = { |
||||||
|
warning: PropTypes.string, |
||||||
|
back: PropTypes.func.isRequired, |
||||||
|
next: PropTypes.func.isRequired, |
||||||
|
importNewAccount: PropTypes.func.isRequired, |
||||||
|
hideWarning: PropTypes.func.isRequired, |
||||||
|
isLoading: PropTypes.bool.isRequired, |
||||||
|
}; |
||||||
|
|
||||||
|
state = { |
||||||
|
selectedOption: ImportAccountScreen.OPTIONS.PRIVATE_KEY, |
||||||
|
privateKey: '', |
||||||
|
jsonFile: {}, |
||||||
|
} |
||||||
|
|
||||||
|
isValid () { |
||||||
|
const { OPTIONS } = ImportAccountScreen |
||||||
|
const { privateKey, jsonFile, password } = this.state |
||||||
|
|
||||||
|
switch (this.state.selectedOption) { |
||||||
|
case OPTIONS.JSON_FILE: |
||||||
|
return Boolean(jsonFile && password) |
||||||
|
case OPTIONS.PRIVATE_KEY: |
||||||
|
default: |
||||||
|
return Boolean(privateKey) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
onClick = () => { |
||||||
|
const { OPTIONS } = ImportAccountScreen |
||||||
|
const { importNewAccount, next } = this.props |
||||||
|
const { privateKey, jsonFile, password } = this.state |
||||||
|
|
||||||
|
switch (this.state.selectedOption) { |
||||||
|
case OPTIONS.JSON_FILE: |
||||||
|
return importNewAccount('JSON File', [ jsonFile, password ]) |
||||||
|
.then(next) |
||||||
|
case OPTIONS.PRIVATE_KEY: |
||||||
|
default: |
||||||
|
return importNewAccount('Private Key', [ privateKey ]) |
||||||
|
.then(next) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
renderPrivateKey () { |
||||||
|
return Input({ |
||||||
|
label: 'Add Private Key String', |
||||||
|
placeholder: 'Enter private key', |
||||||
|
onChange: e => this.setState({ privateKey: e.target.value }), |
||||||
|
errorMessage: this.props.warning && 'Something went wrong. Please make sure your private key is correct.', |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
renderJsonFile () { |
||||||
|
const { jsonFile: { name } } = this.state |
||||||
|
const { warning } = this.props |
||||||
|
|
||||||
|
return ( |
||||||
|
<div className=""> |
||||||
|
<div className="import-account__input-wrapper"> |
||||||
|
<div className="import-account__input-label">Upload File</div> |
||||||
|
<div className="import-account__file-picker-wrapper"> |
||||||
|
<input |
||||||
|
type="file" |
||||||
|
id="file" |
||||||
|
className="import-account__file-input" |
||||||
|
onChange={e => this.setState({ jsonFile: e.target.files[0] })} |
||||||
|
/> |
||||||
|
<label |
||||||
|
htmlFor="file" |
||||||
|
className={classnames('import-account__file-input-label', { |
||||||
|
'import-account__file-input-label--error': warning, |
||||||
|
})} |
||||||
|
> |
||||||
|
Choose File |
||||||
|
</label> |
||||||
|
<div className="import-account__file-name">{name}</div> |
||||||
|
</div> |
||||||
|
<div className="import-account__input-error-message"> |
||||||
|
{warning && 'Something went wrong. Please make sure your JSON file is properly formatted.'} |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
{Input({ |
||||||
|
label: 'Enter Password', |
||||||
|
placeholder: 'Enter Password', |
||||||
|
type: 'password', |
||||||
|
onChange: e => this.setState({ password: e.target.value }), |
||||||
|
errorMessage: warning && 'Please make sure your password is correct.', |
||||||
|
})} |
||||||
|
</div> |
||||||
|
) |
||||||
|
} |
||||||
|
|
||||||
|
renderContent () { |
||||||
|
const { OPTIONS } = ImportAccountScreen |
||||||
|
|
||||||
|
switch (this.state.selectedOption) { |
||||||
|
case OPTIONS.JSON_FILE: |
||||||
|
return this.renderJsonFile() |
||||||
|
case OPTIONS.PRIVATE_KEY: |
||||||
|
default: |
||||||
|
return this.renderPrivateKey() |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
render () { |
||||||
|
const { OPTIONS } = ImportAccountScreen |
||||||
|
const { selectedOption } = this.state |
||||||
|
|
||||||
|
return this.props.isLoading |
||||||
|
? <LoadingScreen loadingMessage="Creating your new account" /> |
||||||
|
: ( |
||||||
|
<div className="import-account"> |
||||||
|
<a |
||||||
|
className="import-account__back-button" |
||||||
|
onClick={e => { |
||||||
|
e.preventDefault() |
||||||
|
this.props.back() |
||||||
|
}} |
||||||
|
href="#" |
||||||
|
> |
||||||
|
{`< Back`} |
||||||
|
</a> |
||||||
|
<div className="import-account__title"> |
||||||
|
Import an Account |
||||||
|
</div> |
||||||
|
<div className="import-account__selector-label"> |
||||||
|
How would you like to import your account? |
||||||
|
</div> |
||||||
|
<select |
||||||
|
className="import-account__dropdown" |
||||||
|
value={selectedOption} |
||||||
|
onChange={e => { |
||||||
|
this.setState({ selectedOption: e.target.value }) |
||||||
|
this.props.hideWarning() |
||||||
|
}} |
||||||
|
> |
||||||
|
<option value={OPTIONS.PRIVATE_KEY}>Private Key</option> |
||||||
|
<option value={OPTIONS.JSON_FILE}>JSON File</option> |
||||||
|
</select> |
||||||
|
{this.renderContent()} |
||||||
|
<button |
||||||
|
className="first-time-flow__button" |
||||||
|
disabled={!this.isValid()} |
||||||
|
onClick={this.onClick} |
||||||
|
> |
||||||
|
Import |
||||||
|
</button> |
||||||
|
<a |
||||||
|
href="https://github.com/MetaMask/faq/blob/master/README.md#q-i-cant-use-the-import-feature-for-uploading-a-json-file-the-window-keeps-closing-when-i-try-to-select-a-file" |
||||||
|
className="first-time-flow__link import-account__faq-link" |
||||||
|
rel="noopener noreferrer" |
||||||
|
target="_blank" |
||||||
|
> |
||||||
|
File import not working? |
||||||
|
</a> |
||||||
|
</div> |
||||||
|
) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
export default connect( |
||||||
|
({ appState: { isLoading, warning } }) => ({ isLoading, warning }), |
||||||
|
dispatch => ({ |
||||||
|
importNewAccount: (strategy, args) => dispatch(importNewAccount(strategy, args)), |
||||||
|
hideWarning: () => dispatch(hideWarning()), |
||||||
|
}) |
||||||
|
)(ImportAccountScreen) |
@ -0,0 +1,109 @@ |
|||||||
|
import React, {Component, PropTypes} from 'react' |
||||||
|
import {connect} from 'react-redux' |
||||||
|
import LoadingScreen from './loading-screen' |
||||||
|
import {createNewVaultAndRestore, hideWarning, displayWarning} from '../../../../ui/app/actions' |
||||||
|
|
||||||
|
class ImportSeedPhraseScreen extends Component { |
||||||
|
static propTypes = { |
||||||
|
warning: PropTypes.string, |
||||||
|
back: PropTypes.func.isRequired, |
||||||
|
next: PropTypes.func.isRequired, |
||||||
|
createNewVaultAndRestore: PropTypes.func.isRequired, |
||||||
|
hideWarning: PropTypes.func.isRequired, |
||||||
|
isLoading: PropTypes.bool.isRequired, |
||||||
|
displayWarning: PropTypes.func, |
||||||
|
}; |
||||||
|
|
||||||
|
state = { |
||||||
|
seedPhrase: '', |
||||||
|
password: '', |
||||||
|
confirmPassword: '', |
||||||
|
} |
||||||
|
|
||||||
|
onClick = () => { |
||||||
|
const { password, seedPhrase, confirmPassword } = this.state |
||||||
|
const { createNewVaultAndRestore, next, displayWarning } = this.props |
||||||
|
|
||||||
|
if (seedPhrase.split(' ').length !== 12) { |
||||||
|
this.warning = 'Seed Phrases are 12 words long' |
||||||
|
displayWarning(this.warning) |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
if (password.length < 8) { |
||||||
|
this.warning = 'Passwords require a mimimum length of 8' |
||||||
|
displayWarning(this.warning) |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
if (password !== confirmPassword) { |
||||||
|
this.warning = 'Confirmed password does not match' |
||||||
|
displayWarning(this.warning) |
||||||
|
return |
||||||
|
} |
||||||
|
this.warning = null |
||||||
|
createNewVaultAndRestore(password, seedPhrase) |
||||||
|
.then(next) |
||||||
|
} |
||||||
|
|
||||||
|
render () { |
||||||
|
return this.props.isLoading |
||||||
|
? <LoadingScreen loadingMessage="Creating your new account" /> |
||||||
|
: ( |
||||||
|
<div className="import-account"> |
||||||
|
<a |
||||||
|
className="import-account__back-button" |
||||||
|
onClick={e => { |
||||||
|
e.preventDefault() |
||||||
|
this.props.back() |
||||||
|
}} |
||||||
|
href="#" |
||||||
|
> |
||||||
|
{`< Back`} |
||||||
|
</a> |
||||||
|
<div className="import-account__title"> |
||||||
|
Import an Account with Seed Phrase |
||||||
|
</div> |
||||||
|
<div className="import-account__selector-label"> |
||||||
|
Enter your secret twelve word phrase here to restore your vault. |
||||||
|
</div> |
||||||
|
<textarea |
||||||
|
className="import-account__secret-phrase" |
||||||
|
onChange={e => this.setState({seedPhrase: e.target.value})} |
||||||
|
/> |
||||||
|
<span |
||||||
|
className="error" |
||||||
|
> |
||||||
|
{this.props.warning} |
||||||
|
</span> |
||||||
|
<input |
||||||
|
className="first-time-flow__input" |
||||||
|
type="password" |
||||||
|
placeholder="New Password (min 8 characters)" |
||||||
|
onChange={e => this.setState({password: e.target.value})} |
||||||
|
/> |
||||||
|
<input |
||||||
|
className="first-time-flow__input create-password__confirm-input" |
||||||
|
type="password" |
||||||
|
placeholder="Confirm Password" |
||||||
|
onChange={e => this.setState({confirmPassword: e.target.value})} |
||||||
|
/> |
||||||
|
<button |
||||||
|
className="first-time-flow__button" |
||||||
|
onClick={this.onClick} |
||||||
|
> |
||||||
|
Import |
||||||
|
</button> |
||||||
|
</div> |
||||||
|
) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
export default connect( |
||||||
|
({ appState: { isLoading, warning } }) => ({ isLoading, warning }), |
||||||
|
dispatch => ({ |
||||||
|
createNewVaultAndRestore: (pw, seed) => dispatch(createNewVaultAndRestore(pw, seed)), |
||||||
|
displayWarning: (warning) => dispatch(displayWarning(warning)), |
||||||
|
hideWarning: () => dispatch(hideWarning()), |
||||||
|
}) |
||||||
|
)(ImportSeedPhraseScreen) |
File diff suppressed because one or more lines are too long
@ -0,0 +1,142 @@ |
|||||||
|
import React, {Component, PropTypes} from 'react' |
||||||
|
import {connect} from 'react-redux' |
||||||
|
import CreatePasswordScreen from './create-password-screen' |
||||||
|
import UniqueImageScreen from './unique-image-screen' |
||||||
|
import NoticeScreen from './notice-screen' |
||||||
|
import BackupPhraseScreen from './backup-phrase-screen' |
||||||
|
import ImportAccountScreen from './import-account-screen' |
||||||
|
import ImportSeedPhraseScreen from './import-seed-phrase-screen' |
||||||
|
import {onboardingBuyEthView} from '../../../../ui/app/actions' |
||||||
|
|
||||||
|
class FirstTimeFlow extends Component { |
||||||
|
|
||||||
|
static propTypes = { |
||||||
|
isInitialized: PropTypes.bool, |
||||||
|
seedWords: PropTypes.string, |
||||||
|
address: PropTypes.string, |
||||||
|
noActiveNotices: PropTypes.bool, |
||||||
|
goToBuyEtherView: PropTypes.func.isRequired, |
||||||
|
}; |
||||||
|
|
||||||
|
static defaultProps = { |
||||||
|
isInitialized: false, |
||||||
|
seedWords: '', |
||||||
|
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', |
||||||
|
}; |
||||||
|
|
||||||
|
constructor (props) { |
||||||
|
super(props) |
||||||
|
this.state = { |
||||||
|
screenType: this.getScreenType(), |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
setScreenType (screenType) { |
||||||
|
this.setState({ screenType }) |
||||||
|
} |
||||||
|
|
||||||
|
getScreenType () { |
||||||
|
const { |
||||||
|
isInitialized, |
||||||
|
seedWords, |
||||||
|
noActiveNotices, |
||||||
|
} = this.props |
||||||
|
const {SCREEN_TYPE} = FirstTimeFlow |
||||||
|
|
||||||
|
// return SCREEN_TYPE.NOTICE
|
||||||
|
|
||||||
|
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 {goToBuyEtherView, address} = 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={() => this.setScreenType(SCREEN_TYPE.CREATE_PASSWORD)} |
||||||
|
next={() => this.setScreenType(SCREEN_TYPE.NOTICE)} |
||||||
|
/> |
||||||
|
) |
||||||
|
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={() => goToBuyEtherView(address)} |
||||||
|
/> |
||||||
|
) |
||||||
|
default: |
||||||
|
return <noscript /> |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
render () { |
||||||
|
return ( |
||||||
|
<div className="first-time-flow"> |
||||||
|
{this.renderScreen()} |
||||||
|
</div> |
||||||
|
) |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
export default connect( |
||||||
|
({ metamask: { isInitialized, seedWords, noActiveNotices, selectedAddress } }) => ({ |
||||||
|
isInitialized, |
||||||
|
seedWords, |
||||||
|
noActiveNotices, |
||||||
|
address: selectedAddress, |
||||||
|
}), |
||||||
|
dispatch => ({ |
||||||
|
goToBuyEtherView: address => dispatch(onboardingBuyEthView(address)), |
||||||
|
}) |
||||||
|
)(FirstTimeFlow) |
||||||
|
|
@ -0,0 +1,11 @@ |
|||||||
|
import React, {Component, PropTypes} from 'react' |
||||||
|
import Spinner from './spinner' |
||||||
|
|
||||||
|
export default function LoadingScreen({ className = '', loadingMessage }) { |
||||||
|
return ( |
||||||
|
<div className={`${className} loading-screen`}> |
||||||
|
<Spinner color="#1B344D" /> |
||||||
|
<div className="loading-screen__message">{loadingMessage}</div> |
||||||
|
</div> |
||||||
|
); |
||||||
|
} |
@ -0,0 +1,92 @@ |
|||||||
|
import React, {Component, PropTypes} from 'react' |
||||||
|
import Markdown from 'react-markdown' |
||||||
|
import {connect} from 'react-redux' |
||||||
|
import debounce from 'lodash.debounce' |
||||||
|
import {markNoticeRead} from '../../../../ui/app/actions' |
||||||
|
import Identicon from '../../../../ui/app/components/identicon' |
||||||
|
import Breadcrumbs from './breadcrumbs' |
||||||
|
|
||||||
|
class NoticeScreen extends Component { |
||||||
|
static propTypes = { |
||||||
|
address: PropTypes.string.isRequired, |
||||||
|
lastUnreadNotice: PropTypes.shape({ |
||||||
|
title: PropTypes.string, |
||||||
|
date: PropTypes.string, |
||||||
|
body: PropTypes.string |
||||||
|
}), |
||||||
|
next: PropTypes.func.isRequired |
||||||
|
}; |
||||||
|
|
||||||
|
static defaultProps = { |
||||||
|
lastUnreadNotice: {} |
||||||
|
}; |
||||||
|
|
||||||
|
state = { |
||||||
|
atBottom: false, |
||||||
|
} |
||||||
|
|
||||||
|
componentDidMount() { |
||||||
|
this.onScroll() |
||||||
|
} |
||||||
|
|
||||||
|
acceptTerms = () => { |
||||||
|
const { markNoticeRead, lastUnreadNotice, next } = this.props; |
||||||
|
const defer = markNoticeRead(lastUnreadNotice) |
||||||
|
.then(() => this.setState({ atBottom: false })) |
||||||
|
|
||||||
|
if ((/terms/gi).test(lastUnreadNotice.title)) { |
||||||
|
defer.then(next) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
onScroll = debounce(() => { |
||||||
|
if (this.state.atBottom) return |
||||||
|
|
||||||
|
const target = document.querySelector('.tou__body') |
||||||
|
const {scrollTop, offsetHeight, scrollHeight} = target; |
||||||
|
const atBottom = scrollTop + offsetHeight >= scrollHeight; |
||||||
|
|
||||||
|
this.setState({atBottom: atBottom}) |
||||||
|
}, 25) |
||||||
|
|
||||||
|
render() { |
||||||
|
const { |
||||||
|
address, |
||||||
|
lastUnreadNotice: { title, body } |
||||||
|
} = this.props; |
||||||
|
const { atBottom } = this.state |
||||||
|
|
||||||
|
return ( |
||||||
|
<div |
||||||
|
className="tou" |
||||||
|
onScroll={this.onScroll} |
||||||
|
> |
||||||
|
<Identicon address={address} diameter={70} /> |
||||||
|
<div className="tou__title">{title}</div> |
||||||
|
<Markdown |
||||||
|
className="tou__body" |
||||||
|
source={body} |
||||||
|
skipHtml |
||||||
|
/> |
||||||
|
<button |
||||||
|
className="first-time-flow__button" |
||||||
|
onClick={atBottom && this.acceptTerms} |
||||||
|
disabled={!atBottom} |
||||||
|
> |
||||||
|
Accept |
||||||
|
</button> |
||||||
|
<Breadcrumbs total={3} currentIndex={2} /> |
||||||
|
</div> |
||||||
|
) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
export default connect( |
||||||
|
({ metamask: { selectedAddress, lastUnreadNotice } }) => ({ |
||||||
|
lastUnreadNotice, |
||||||
|
address: selectedAddress |
||||||
|
}), |
||||||
|
dispatch => ({ |
||||||
|
markNoticeRead: notice => dispatch(markNoticeRead(notice)) |
||||||
|
}) |
||||||
|
)(NoticeScreen) |
@ -0,0 +1,70 @@ |
|||||||
|
import React from 'react'; |
||||||
|
|
||||||
|
export default function Spinner({ className = '', color = "#000000" }) { |
||||||
|
return ( |
||||||
|
<div className={`spinner ${className}`}> |
||||||
|
<svg className="lds-spinner" width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid" style={{background: 'none'}}> |
||||||
|
<g transform="rotate(0 50 50)"> |
||||||
|
<rect x={47} y={16} rx={0} ry={0} width={6} height={20} fill={color}> |
||||||
|
<animate attributeName="opacity" values="1;0" dur="1s" begin="-0.9166666666666666s" repeatCount="indefinite" /> |
||||||
|
</rect> |
||||||
|
</g> |
||||||
|
<g transform="rotate(30 50 50)"> |
||||||
|
<rect x={47} y={16} rx={0} ry={0} width={6} height={20} fill={color}> |
||||||
|
<animate attributeName="opacity" values="1;0" dur="1s" begin="-0.8333333333333334s" repeatCount="indefinite" /> |
||||||
|
</rect> |
||||||
|
</g> |
||||||
|
<g transform="rotate(60 50 50)"> |
||||||
|
<rect x={47} y={16} rx={0} ry={0} width={6} height={20} fill={color}> |
||||||
|
<animate attributeName="opacity" values="1;0" dur="1s" begin="-0.75s" repeatCount="indefinite" /> |
||||||
|
</rect> |
||||||
|
</g> |
||||||
|
<g transform="rotate(90 50 50)"> |
||||||
|
<rect x={47} y={16} rx={0} ry={0} width={6} height={20} fill={color}> |
||||||
|
<animate attributeName="opacity" values="1;0" dur="1s" begin="-0.6666666666666666s" repeatCount="indefinite" /> |
||||||
|
</rect> |
||||||
|
</g> |
||||||
|
<g transform="rotate(120 50 50)"> |
||||||
|
<rect x={47} y={16} rx={0} ry={0} width={6} height={20} fill={color}> |
||||||
|
<animate attributeName="opacity" values="1;0" dur="1s" begin="-0.5833333333333334s" repeatCount="indefinite" /> |
||||||
|
</rect> |
||||||
|
</g> |
||||||
|
<g transform="rotate(150 50 50)"> |
||||||
|
<rect x={47} y={16} rx={0} ry={0} width={6} height={20} fill={color}> |
||||||
|
<animate attributeName="opacity" values="1;0" dur="1s" begin="-0.5s" repeatCount="indefinite" /> |
||||||
|
</rect> |
||||||
|
</g> |
||||||
|
<g transform="rotate(180 50 50)"> |
||||||
|
<rect x={47} y={16} rx={0} ry={0} width={6} height={20} fill={color}> |
||||||
|
<animate attributeName="opacity" values="1;0" dur="1s" begin="-0.4166666666666667s" repeatCount="indefinite" /> |
||||||
|
</rect> |
||||||
|
</g> |
||||||
|
<g transform="rotate(210 50 50)"> |
||||||
|
<rect x={47} y={16} rx={0} ry={0} width={6} height={20} fill={color}> |
||||||
|
<animate attributeName="opacity" values="1;0" dur="1s" begin="-0.3333333333333333s" repeatCount="indefinite" /> |
||||||
|
</rect> |
||||||
|
</g> |
||||||
|
<g transform="rotate(240 50 50)"> |
||||||
|
<rect x={47} y={16} rx={0} ry={0} width={6} height={20} fill={color}> |
||||||
|
<animate attributeName="opacity" values="1;0" dur="1s" begin="-0.25s" repeatCount="indefinite" /> |
||||||
|
</rect> |
||||||
|
</g> |
||||||
|
<g transform="rotate(270 50 50)"> |
||||||
|
<rect x={47} y={16} rx={0} ry={0} width={6} height={20} fill={color}> |
||||||
|
<animate attributeName="opacity" values="1;0" dur="1s" begin="-0.16666666666666666s" repeatCount="indefinite" /> |
||||||
|
</rect> |
||||||
|
</g> |
||||||
|
<g transform="rotate(300 50 50)"> |
||||||
|
<rect x={47} y={16} rx={0} ry={0} width={6} height={20} fill={color}> |
||||||
|
<animate attributeName="opacity" values="1;0" dur="1s" begin="-0.08333333333333333s" repeatCount="indefinite" /> |
||||||
|
</rect> |
||||||
|
</g> |
||||||
|
<g transform="rotate(330 50 50)"> |
||||||
|
<rect x={47} y={16} rx={0} ry={0} width={6} height={20} fill={color}> |
||||||
|
<animate attributeName="opacity" values="1;0" dur="1s" begin="0s" repeatCount="indefinite" /> |
||||||
|
</rect> |
||||||
|
</g> |
||||||
|
</svg> |
||||||
|
</div> |
||||||
|
); |
||||||
|
} |
@ -0,0 +1,39 @@ |
|||||||
|
import React, {Component, PropTypes} from 'react' |
||||||
|
import {connect} from 'react-redux' |
||||||
|
import Identicon from '../../../../ui/app/components/identicon' |
||||||
|
import Breadcrumbs from './breadcrumbs' |
||||||
|
|
||||||
|
class UniqueImageScreen extends Component { |
||||||
|
static propTypes = { |
||||||
|
address: PropTypes.string, |
||||||
|
next: PropTypes.func.isRequired, |
||||||
|
} |
||||||
|
|
||||||
|
render () { |
||||||
|
return ( |
||||||
|
<div className="unique-image"> |
||||||
|
<Identicon address={this.props.address} diameter={70} /> |
||||||
|
<div className="unique-image__title">Your unique account image</div> |
||||||
|
<div className="unique-image__body-text"> |
||||||
|
This image was programmatically generated for you by your new account number. |
||||||
|
</div> |
||||||
|
<div className="unique-image__body-text"> |
||||||
|
You’ll see this image everytime you need to confirm a transaction. |
||||||
|
</div> |
||||||
|
<button |
||||||
|
className="first-time-flow__button" |
||||||
|
onClick={this.props.next} |
||||||
|
> |
||||||
|
Next |
||||||
|
</button> |
||||||
|
<Breadcrumbs total={3} currentIndex={1} /> |
||||||
|
</div> |
||||||
|
) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
export default connect( |
||||||
|
({ metamask: { selectedAddress } }) => ({ |
||||||
|
address: selectedAddress, |
||||||
|
}) |
||||||
|
)(UniqueImageScreen) |
@ -0,0 +1,217 @@ |
|||||||
|
import React, {Component, PropTypes} from 'react' |
||||||
|
import classnames from 'classnames' |
||||||
|
import {qrcode} from 'qrcode-npm' |
||||||
|
import {connect} from 'react-redux' |
||||||
|
import {shapeShiftSubview, pairUpdate, buyWithShapeShift} from '../../../../ui/app/actions' |
||||||
|
import {isValidAddress} from '../../../../ui/app/util' |
||||||
|
|
||||||
|
export class ShapeShiftForm extends Component { |
||||||
|
static propTypes = { |
||||||
|
selectedAddress: PropTypes.string.isRequired, |
||||||
|
btnClass: PropTypes.string.isRequired, |
||||||
|
tokenExchangeRates: PropTypes.object.isRequired, |
||||||
|
coinOptions: PropTypes.object.isRequired, |
||||||
|
shapeShiftSubview: PropTypes.func.isRequired, |
||||||
|
pairUpdate: PropTypes.func.isRequired, |
||||||
|
buyWithShapeShift: PropTypes.func.isRequired, |
||||||
|
}; |
||||||
|
|
||||||
|
state = { |
||||||
|
depositCoin: 'btc', |
||||||
|
refundAddress: '', |
||||||
|
showQrCode: false, |
||||||
|
depositAddress: '', |
||||||
|
errorMessage: '', |
||||||
|
isLoading: false, |
||||||
|
}; |
||||||
|
|
||||||
|
componentWillMount () { |
||||||
|
this.props.shapeShiftSubview() |
||||||
|
} |
||||||
|
|
||||||
|
onCoinChange = e => { |
||||||
|
const coin = e.target.value |
||||||
|
this.setState({ |
||||||
|
depositCoin: coin, |
||||||
|
errorMessage: '', |
||||||
|
}) |
||||||
|
this.props.pairUpdate(coin) |
||||||
|
} |
||||||
|
|
||||||
|
onBuyWithShapeShift = () => { |
||||||
|
this.setState({ |
||||||
|
isLoading: true, |
||||||
|
showQrCode: true, |
||||||
|
}) |
||||||
|
|
||||||
|
const { |
||||||
|
buyWithShapeShift, |
||||||
|
selectedAddress: withdrawal, |
||||||
|
} = this.props |
||||||
|
const { |
||||||
|
refundAddress: returnAddress, |
||||||
|
depositCoin, |
||||||
|
} = this.state |
||||||
|
const pair = `${depositCoin}_eth` |
||||||
|
const data = { |
||||||
|
withdrawal, |
||||||
|
pair, |
||||||
|
returnAddress, |
||||||
|
// Public api key
|
||||||
|
'apiKey': '803d1f5df2ed1b1476e4b9e6bcd089e34d8874595dda6a23b67d93c56ea9cc2445e98a6748b219b2b6ad654d9f075f1f1db139abfa93158c04e825db122c14b6', |
||||||
|
} |
||||||
|
|
||||||
|
if (isValidAddress(withdrawal)) { |
||||||
|
buyWithShapeShift(data) |
||||||
|
.then(d => this.setState({ |
||||||
|
showQrCode: true, |
||||||
|
depositAddress: d.deposit, |
||||||
|
isLoading: false, |
||||||
|
})) |
||||||
|
.catch(() => this.setState({ |
||||||
|
showQrCode: false, |
||||||
|
errorMessage: 'Invalid Request', |
||||||
|
isLoading: false, |
||||||
|
})) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
renderMetadata (label, value) { |
||||||
|
return ( |
||||||
|
<div className='shapeshift-form__metadata-wrapper'> |
||||||
|
<div className='shapeshift-form__metadata-label'> |
||||||
|
{label}: |
||||||
|
</div> |
||||||
|
<div className='shapeshift-form__metadata-value'> |
||||||
|
{value} |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
) |
||||||
|
} |
||||||
|
|
||||||
|
renderMarketInfo () { |
||||||
|
const { depositCoin } = this.state |
||||||
|
const coinPair = `${depositCoin}_eth` |
||||||
|
const { tokenExchangeRates } = this.props |
||||||
|
const { |
||||||
|
limit, |
||||||
|
rate, |
||||||
|
minimum, |
||||||
|
} = tokenExchangeRates[coinPair] || {} |
||||||
|
|
||||||
|
return ( |
||||||
|
<div className='shapeshift-form__metadata'> |
||||||
|
{this.renderMetadata('Status', limit ? 'Available' : 'Unavailable')} |
||||||
|
{this.renderMetadata('Limit', limit)} |
||||||
|
{this.renderMetadata('Exchange Rate', rate)} |
||||||
|
{this.renderMetadata('Minimum', minimum)} |
||||||
|
</div> |
||||||
|
) |
||||||
|
} |
||||||
|
|
||||||
|
renderQrCode () { |
||||||
|
const { depositAddress, isLoading } = this.state |
||||||
|
const qrImage = qrcode(4, 'M') |
||||||
|
qrImage.addData(depositAddress) |
||||||
|
qrImage.make() |
||||||
|
|
||||||
|
return ( |
||||||
|
<div className='shapeshift-form'> |
||||||
|
<div className='shapeshift-form__deposit-instruction'> |
||||||
|
Deposit your BTC to the address bellow: |
||||||
|
</div> |
||||||
|
<div className='shapeshift-form__qr-code'> |
||||||
|
{isLoading |
||||||
|
? <img src='images/loading.svg' style={{ width: '60px' }} /> |
||||||
|
: <div dangerouslySetInnerHTML={{ __html: qrImage.createTableTag(4) }} /> |
||||||
|
} |
||||||
|
</div> |
||||||
|
{this.renderMarketInfo()} |
||||||
|
</div> |
||||||
|
) |
||||||
|
} |
||||||
|
|
||||||
|
render () { |
||||||
|
const { coinOptions, btnClass } = this.props |
||||||
|
const { depositCoin, errorMessage, showQrCode } = this.state |
||||||
|
const coinPair = `${depositCoin}_eth` |
||||||
|
const { tokenExchangeRates } = this.props |
||||||
|
const token = tokenExchangeRates[coinPair] |
||||||
|
|
||||||
|
return showQrCode ? this.renderQrCode() : ( |
||||||
|
<div> |
||||||
|
<div className='shapeshift-form'> |
||||||
|
<div className='shapeshift-form__selectors'> |
||||||
|
<div className='shapeshift-form__selector'> |
||||||
|
<div className='shapeshift-form__selector-label'> |
||||||
|
Deposit |
||||||
|
</div> |
||||||
|
<select |
||||||
|
className='shapeshift-form__selector-input' |
||||||
|
value={this.state.depositCoin} |
||||||
|
onChange={this.onCoinChange} |
||||||
|
> |
||||||
|
{Object.entries(coinOptions).map(([coin]) => ( |
||||||
|
<option key={coin} value={coin.toLowerCase()}> |
||||||
|
{coin} |
||||||
|
</option> |
||||||
|
))} |
||||||
|
</select> |
||||||
|
</div> |
||||||
|
<div |
||||||
|
className='icon shapeshift-form__caret' |
||||||
|
style={{ backgroundImage: 'url(images/caret-right.svg)'}} |
||||||
|
/> |
||||||
|
<div className='shapeshift-form__selector'> |
||||||
|
<div className='shapeshift-form__selector-label'> |
||||||
|
Receive |
||||||
|
</div> |
||||||
|
<div className='shapeshift-form__selector-input'> |
||||||
|
ETH |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<div |
||||||
|
className={classnames('shapeshift-form__address-input-wrapper', { |
||||||
|
'shapeshift-form__address-input-wrapper--error': errorMessage, |
||||||
|
})} |
||||||
|
> |
||||||
|
<div className='shapeshift-form__address-input-label'> |
||||||
|
Your Refund Address |
||||||
|
</div> |
||||||
|
<input |
||||||
|
type='text' |
||||||
|
className='shapeshift-form__address-input' |
||||||
|
onChange={e => this.setState({ |
||||||
|
refundAddress: e.target.value, |
||||||
|
errorMessage: '', |
||||||
|
})} |
||||||
|
/> |
||||||
|
<div className='shapeshift-form__address-input-error-message'> |
||||||
|
{errorMessage} |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
{this.renderMarketInfo()} |
||||||
|
</div> |
||||||
|
<button |
||||||
|
className={btnClass} |
||||||
|
disabled={!token} |
||||||
|
onClick={this.onBuyWithShapeShift} |
||||||
|
> |
||||||
|
Buy |
||||||
|
</button> |
||||||
|
</div> |
||||||
|
) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
export default connect( |
||||||
|
({ metamask: { coinOptions, tokenExchangeRates, selectedAddress } }) => ({ |
||||||
|
coinOptions, tokenExchangeRates, selectedAddress, |
||||||
|
}), |
||||||
|
dispatch => ({ |
||||||
|
shapeShiftSubview: () => dispatch(shapeShiftSubview()), |
||||||
|
pairUpdate: coin => dispatch(pairUpdate(coin)), |
||||||
|
buyWithShapeShift: data => dispatch(buyWithShapeShift(data)), |
||||||
|
}) |
||||||
|
)(ShapeShiftForm) |
@ -0,0 +1,167 @@ |
|||||||
|
const PASSWORD = 'password123' |
||||||
|
const reactTriggerChange = require('react-trigger-change') |
||||||
|
|
||||||
|
async function runFirstTimeUsageTest (assert, done) { |
||||||
|
await timeout(4000) |
||||||
|
|
||||||
|
const app = $('#app-content') |
||||||
|
|
||||||
|
// recurse notices
|
||||||
|
while (true) { |
||||||
|
const button = app.find('button') |
||||||
|
if (button.html() === 'Accept') { |
||||||
|
// still notices to accept
|
||||||
|
const termsPage = app.find('.markdown')[0] |
||||||
|
termsPage.scrollTop = termsPage.scrollHeight |
||||||
|
await timeout() |
||||||
|
console.log('Clearing notice') |
||||||
|
button.click() |
||||||
|
await timeout() |
||||||
|
} else { |
||||||
|
// exit loop
|
||||||
|
console.log('No more notices...') |
||||||
|
break |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
await timeout() |
||||||
|
|
||||||
|
// Scroll through terms
|
||||||
|
const title = app.find('.create-password__title').text() |
||||||
|
assert.equal(title, 'Create Password', 'create password screen') |
||||||
|
|
||||||
|
// enter password
|
||||||
|
const pwBox = app.find('.first-time-flow__input')[0] |
||||||
|
const confBox = app.find('.first-time-flow__input')[1] |
||||||
|
pwBox.value = PASSWORD |
||||||
|
confBox.value = PASSWORD |
||||||
|
reactTriggerChange(pwBox) |
||||||
|
reactTriggerChange(confBox) |
||||||
|
|
||||||
|
|
||||||
|
await timeout() |
||||||
|
|
||||||
|
// Create Password
|
||||||
|
const createButton = app.find('button.first-time-flow__button')[0] |
||||||
|
createButton.click() |
||||||
|
|
||||||
|
await timeout(3000) |
||||||
|
|
||||||
|
const created = app.find('.unique-image__title')[0] |
||||||
|
assert.equal(created.textContent, 'Your unique account image', 'unique image screen') |
||||||
|
|
||||||
|
// Agree button
|
||||||
|
const button = app.find('button')[0] |
||||||
|
assert.ok(button, 'button present') |
||||||
|
button.click() |
||||||
|
|
||||||
|
await timeout(1000) |
||||||
|
|
||||||
|
// Privacy Screen
|
||||||
|
const detail = app.find('.tou__title')[0] |
||||||
|
assert.equal(detail.textContent, 'Privacy Notice', 'privacy notice screen') |
||||||
|
app.find('button').click() |
||||||
|
|
||||||
|
await timeout(1000) |
||||||
|
|
||||||
|
|
||||||
|
// terms of service screen
|
||||||
|
const tou = app.find('.tou__title')[0] |
||||||
|
assert.equal(tou.textContent, 'Terms of Use', 'terms of use screen') |
||||||
|
app.find('.tou__body').scrollTop(100000) |
||||||
|
await timeout(1000) |
||||||
|
|
||||||
|
app.find('.first-time-flow__button').click() |
||||||
|
await timeout(1000) |
||||||
|
|
||||||
|
// secret backup phrase
|
||||||
|
const seedTitle = app.find('.backup-phrase__title')[0] |
||||||
|
assert.equal(seedTitle.textContent, 'Secret Backup Phrase', 'seed phrase screen') |
||||||
|
app.find('.backup-phrase__reveal-button').click() |
||||||
|
|
||||||
|
await timeout(1000) |
||||||
|
const seedPhrase = app.find('.backup-phrase__secret-words').text().split(' ') |
||||||
|
app.find('.first-time-flow__button').click() |
||||||
|
|
||||||
|
const selectPhrase = text => { |
||||||
|
const option = $('.backup-phrase__confirm-seed-option') |
||||||
|
.filter((i, d) => d.textContent === text)[0] |
||||||
|
|
||||||
|
$(option).click() |
||||||
|
} |
||||||
|
|
||||||
|
await timeout(1000) |
||||||
|
|
||||||
|
seedPhrase.forEach(sp => selectPhrase(sp)) |
||||||
|
app.find('.first-time-flow__button').click() |
||||||
|
await timeout(1000) |
||||||
|
|
||||||
|
// Deposit Ether Screen
|
||||||
|
const buyEthTitle = app.find('.buy-ether__title')[0] |
||||||
|
assert.equal(buyEthTitle.textContent, 'Deposit Ether', 'deposit ether screen') |
||||||
|
app.find('.buy-ether__do-it-later').click() |
||||||
|
await timeout(1000) |
||||||
|
|
||||||
|
const sandwich = app.find('.sandwich-expando')[0] |
||||||
|
sandwich.click() |
||||||
|
|
||||||
|
await timeout() |
||||||
|
|
||||||
|
const menu = app.find('.menu-droppo')[0] |
||||||
|
const children = menu.children |
||||||
|
const lock = children[children.length - 2] |
||||||
|
assert.ok(lock, 'Lock menu item found') |
||||||
|
lock.click() |
||||||
|
|
||||||
|
await timeout(1000) |
||||||
|
|
||||||
|
const pwBox2 = app.find('#password-box')[0] |
||||||
|
pwBox2.value = PASSWORD |
||||||
|
|
||||||
|
const createButton2 = app.find('button.primary')[0] |
||||||
|
createButton2.click() |
||||||
|
|
||||||
|
await timeout(1000) |
||||||
|
|
||||||
|
const detail2 = app.find('.account-detail-section')[0] |
||||||
|
assert.ok(detail2, 'Account detail section loaded again.') |
||||||
|
|
||||||
|
await timeout() |
||||||
|
|
||||||
|
// open account settings dropdown
|
||||||
|
const qrButton = app.find('.fa.fa-ellipsis-h')[0] |
||||||
|
qrButton.click() |
||||||
|
|
||||||
|
await timeout(1000) |
||||||
|
|
||||||
|
// qr code item
|
||||||
|
const qrButton2 = app.find('.dropdown-menu-item')[1] |
||||||
|
qrButton2.click() |
||||||
|
|
||||||
|
await timeout(1000) |
||||||
|
|
||||||
|
const qrHeader = app.find('.qr-header')[0] |
||||||
|
const qrContainer = app.find('#qr-container')[0] |
||||||
|
assert.equal(qrHeader.textContent, 'Account 1', 'Should show account label.') |
||||||
|
assert.ok(qrContainer, 'QR Container found') |
||||||
|
|
||||||
|
await timeout() |
||||||
|
|
||||||
|
const networkMenu = app.find('.network-indicator')[0] |
||||||
|
networkMenu.click() |
||||||
|
|
||||||
|
await timeout() |
||||||
|
|
||||||
|
const networkMenu2 = app.find('.network-indicator')[0] |
||||||
|
const children2 = networkMenu2.children |
||||||
|
children2.length[3] |
||||||
|
assert.ok(children2, 'All network options present') |
||||||
|
} |
||||||
|
|
||||||
|
module.exports = runFirstTimeUsageTest |
||||||
|
|
||||||
|
function timeout (time) { |
||||||
|
return new Promise((resolve, reject) => { |
||||||
|
setTimeout(resolve, time || 1500) |
||||||
|
}) |
||||||
|
} |
@ -1,16 +0,0 @@ |
|||||||
var assert = require('assert') |
|
||||||
var linkGen = require('../../ui/lib/account-link') |
|
||||||
|
|
||||||
describe('account-link', function () { |
|
||||||
it('adds ropsten prefix to ropsten test network', function () { |
|
||||||
var result = linkGen('account', '3') |
|
||||||
assert.notEqual(result.indexOf('ropsten'), -1, 'ropsten included') |
|
||||||
assert.notEqual(result.indexOf('account'), -1, 'account included') |
|
||||||
}) |
|
||||||
|
|
||||||
it('adds kovan prefix to kovan test network', function () { |
|
||||||
var result = linkGen('account', '42') |
|
||||||
assert.notEqual(result.indexOf('kovan'), -1, 'kovan included') |
|
||||||
assert.notEqual(result.indexOf('account'), -1, 'account included') |
|
||||||
}) |
|
||||||
}) |
|
@ -1,14 +0,0 @@ |
|||||||
var assert = require('assert') |
|
||||||
var linkGen = require('../../ui/lib/explorer-link') |
|
||||||
|
|
||||||
describe('explorer-link', function () { |
|
||||||
it('adds ropsten prefix to ropsten test network', function () { |
|
||||||
var result = linkGen('hash', '3') |
|
||||||
assert.notEqual(result.indexOf('ropsten'), -1, 'ropsten injected') |
|
||||||
}) |
|
||||||
|
|
||||||
it('adds kovan prefix to kovan test network', function () { |
|
||||||
var result = linkGen('hash', '42') |
|
||||||
assert.notEqual(result.indexOf('kovan'), -1, 'kovan injected') |
|
||||||
}) |
|
||||||
}) |
|
@ -1,26 +0,0 @@ |
|||||||
module.exports = function (address, network) { |
|
||||||
const net = parseInt(network) |
|
||||||
let link |
|
||||||
switch (net) { |
|
||||||
case 1: // main net
|
|
||||||
link = `https://etherscan.io/address/${address}` |
|
||||||
break |
|
||||||
case 2: // morden test net
|
|
||||||
link = `https://morden.etherscan.io/address/${address}` |
|
||||||
break |
|
||||||
case 3: // ropsten test net
|
|
||||||
link = `https://ropsten.etherscan.io/address/${address}` |
|
||||||
break |
|
||||||
case 4: // rinkeby test net
|
|
||||||
link = `https://rinkeby.etherscan.io/address/${address}` |
|
||||||
break |
|
||||||
case 42: // kovan test net
|
|
||||||
link = `https://kovan.etherscan.io/address/${address}` |
|
||||||
break |
|
||||||
default: |
|
||||||
link = '' |
|
||||||
break |
|
||||||
} |
|
||||||
|
|
||||||
return link |
|
||||||
} |
|
@ -1,6 +0,0 @@ |
|||||||
const prefixForNetwork = require('./etherscan-prefix-for-network') |
|
||||||
|
|
||||||
module.exports = function (hash, network) { |
|
||||||
const prefix = prefixForNetwork(network) |
|
||||||
return `http://${prefix}etherscan.io/tx/${hash}` |
|
||||||
} |
|
Loading…
Reference in new issue