|
|
@ -2,7 +2,9 @@ import React, {Component, PropTypes} from 'react' |
|
|
|
import classnames from 'classnames' |
|
|
|
import classnames from 'classnames' |
|
|
|
import {connect} from 'react-redux' |
|
|
|
import {connect} from 'react-redux' |
|
|
|
import {qrcode} from 'qrcode-npm' |
|
|
|
import {qrcode} from 'qrcode-npm' |
|
|
|
|
|
|
|
import copyToClipboard from 'copy-to-clipboard' |
|
|
|
import Identicon from '../../../../ui/app/components/identicon' |
|
|
|
import Identicon from '../../../../ui/app/components/identicon' |
|
|
|
|
|
|
|
import {buyEth, showAccountDetail} from '../../../../ui/app/actions' |
|
|
|
|
|
|
|
|
|
|
|
class BuyEtherScreen extends Component { |
|
|
|
class BuyEtherScreen extends Component { |
|
|
|
static OPTION_VALUES = { |
|
|
|
static OPTION_VALUES = { |
|
|
@ -28,10 +30,34 @@ class BuyEtherScreen extends Component { |
|
|
|
|
|
|
|
|
|
|
|
static propTypes = { |
|
|
|
static propTypes = { |
|
|
|
address: PropTypes.string, |
|
|
|
address: PropTypes.string, |
|
|
|
|
|
|
|
goToCoinbase: PropTypes.func.isRequired, |
|
|
|
|
|
|
|
showAccountDetail: PropTypes.func.isRequired, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
state = { |
|
|
|
state = { |
|
|
|
selectedOption: BuyEtherScreen.OPTION_VALUES.COINBASE, |
|
|
|
selectedOption: BuyEtherScreen.OPTION_VALUES.COINBASE, |
|
|
|
|
|
|
|
justCopied: false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
copyToClipboard = () => { |
|
|
|
|
|
|
|
const { address } = this.props; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.setState({ justCopied: true }, () => copyToClipboard(address)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setTimeout(() => this.setState({ justCopied: false }), 1000) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
renderSkipStep() { |
|
|
|
|
|
|
|
const {showAccountDetail, address} = this.props |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
|
|
<button |
|
|
|
|
|
|
|
className="first-time-flow__button--tertiary" |
|
|
|
|
|
|
|
onClick={() => showAccountDetail(address)} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
Skip this step |
|
|
|
|
|
|
|
</button> |
|
|
|
|
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
renderCoinbaseLogo() { |
|
|
|
renderCoinbaseLogo() { |
|
|
@ -59,32 +85,34 @@ class BuyEtherScreen extends Component { |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
renderCoinbaseForm() { |
|
|
|
|
|
|
|
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={() => this.goToCoinbase(address)} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
Buy |
|
|
|
|
|
|
|
</button> |
|
|
|
|
|
|
|
<div className="buy-ether__button-separator-text">or</div> |
|
|
|
|
|
|
|
{this.renderSkipStep()} |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
renderContent() { |
|
|
|
renderContent() { |
|
|
|
const { OPTION_VALUES } = BuyEtherScreen; |
|
|
|
const { OPTION_VALUES } = BuyEtherScreen |
|
|
|
const { address } = this.props; |
|
|
|
const { address, goToCoinbase } = this.props |
|
|
|
|
|
|
|
const { justCopied } = this.state |
|
|
|
|
|
|
|
|
|
|
|
switch (this.state.selectedOption) { |
|
|
|
switch (this.state.selectedOption) { |
|
|
|
case OPTION_VALUES.COINBASE: |
|
|
|
case OPTION_VALUES.COINBASE: |
|
|
|
return ( |
|
|
|
return this.renderCoinbaseForm() |
|
|
|
<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" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
Buy |
|
|
|
|
|
|
|
</button> |
|
|
|
|
|
|
|
<div className="buy-ether__button-separator-text">or</div> |
|
|
|
|
|
|
|
<button |
|
|
|
|
|
|
|
className="first-time-flow__button--tertiary" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
Skip this step |
|
|
|
|
|
|
|
</button> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
case OPTION_VALUES.SHAPESHIFT: |
|
|
|
case OPTION_VALUES.SHAPESHIFT: |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div className="buy-ether__action-content-wrapper"> |
|
|
|
<div className="buy-ether__action-content-wrapper"> |
|
|
@ -97,11 +125,7 @@ class BuyEtherScreen extends Component { |
|
|
|
Buy |
|
|
|
Buy |
|
|
|
</button> |
|
|
|
</button> |
|
|
|
<div className="buy-ether__button-separator-text">or</div> |
|
|
|
<div className="buy-ether__button-separator-text">or</div> |
|
|
|
<button |
|
|
|
{this.renderSkipStep()} |
|
|
|
className="first-time-flow__button--tertiary" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
Skip this step |
|
|
|
|
|
|
|
</button> |
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
) |
|
|
|
) |
|
|
@ -113,19 +137,17 @@ class BuyEtherScreen extends Component { |
|
|
|
<div className="buy-ether__action-content-wrapper"> |
|
|
|
<div className="buy-ether__action-content-wrapper"> |
|
|
|
<div dangerouslySetInnerHTML={{ __html: qrImage.createTableTag(4) }} /> |
|
|
|
<div dangerouslySetInnerHTML={{ __html: qrImage.createTableTag(4) }} /> |
|
|
|
<div className="buy-ether__body-text">Deposit Ether directly into your account.</div> |
|
|
|
<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__small-body-text">(This is the account address that MetaMask created for you to recieve funds.)</div> |
|
|
|
<div className="buy-ether__buttons"> |
|
|
|
<div className="buy-ether__buttons"> |
|
|
|
<button |
|
|
|
<button |
|
|
|
className="first-time-flow__button" |
|
|
|
className="first-time-flow__button" |
|
|
|
|
|
|
|
onClick={this.copyToClipboard} |
|
|
|
|
|
|
|
disabled={justCopied} |
|
|
|
> |
|
|
|
> |
|
|
|
Copy |
|
|
|
{ justCopied ? 'Copied' : 'Copy' } |
|
|
|
</button> |
|
|
|
</button> |
|
|
|
<div className="buy-ether__button-separator-text">or</div> |
|
|
|
<div className="buy-ether__button-separator-text">or</div> |
|
|
|
<button |
|
|
|
{this.renderSkipStep()} |
|
|
|
className="first-time-flow__button--tertiary" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
Skip this step |
|
|
|
|
|
|
|
</button> |
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
) |
|
|
|
) |
|
|
@ -177,8 +199,11 @@ class BuyEtherScreen extends Component { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export default connect( |
|
|
|
export default connect( |
|
|
|
({ metamask: { identities } }) => ({ |
|
|
|
({ metamask: { selectedAddress } }) => ({ |
|
|
|
address: Object.entries(identities) |
|
|
|
address: selectedAddress |
|
|
|
.map(([key]) => key)[0] |
|
|
|
}), |
|
|
|
|
|
|
|
dispatch => ({ |
|
|
|
|
|
|
|
goToCoinbase: address => dispatch(buyEth({ network: '1', address, amount: 0 })), |
|
|
|
|
|
|
|
showAccountDetail: address => dispatch(showAccountDetail(address)), |
|
|
|
}) |
|
|
|
}) |
|
|
|
)(BuyEtherScreen) |
|
|
|
)(BuyEtherScreen) |
|
|
|