2021-02-04 19:15:23 +01:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React, { Component } from 'react';
|
2021-04-28 21:53:59 +02:00
|
|
|
import { NETWORK_TO_NAME_MAP } from '../../../../../shared/constants/network';
|
2021-02-04 19:15:23 +01:00
|
|
|
import Button from '../../../ui/button';
|
2019-11-27 17:14:02 +01:00
|
|
|
|
|
|
|
export default class DepositEtherModal extends Component {
|
|
|
|
static contextTypes = {
|
|
|
|
t: PropTypes.func,
|
2020-05-28 18:24:52 +02:00
|
|
|
metricsEvent: PropTypes.func.isRequired,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-11-27 17:14:02 +01:00
|
|
|
|
|
|
|
static propTypes = {
|
2021-03-12 23:23:26 +01:00
|
|
|
chainId: PropTypes.string.isRequired,
|
2021-02-16 16:31:16 +01:00
|
|
|
isTestnet: PropTypes.bool.isRequired,
|
|
|
|
isMainnet: PropTypes.bool.isRequired,
|
2019-11-27 17:14:02 +01:00
|
|
|
toWyre: PropTypes.func.isRequired,
|
2021-06-25 15:10:24 +02:00
|
|
|
toTransak: PropTypes.func.isRequired,
|
2019-11-27 17:14:02 +01:00
|
|
|
address: PropTypes.string.isRequired,
|
|
|
|
toFaucet: PropTypes.func.isRequired,
|
|
|
|
hideWarning: PropTypes.func.isRequired,
|
|
|
|
hideModal: PropTypes.func.isRequired,
|
|
|
|
showAccountDetailModal: PropTypes.func.isRequired,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-11-27 17:14:02 +01:00
|
|
|
|
|
|
|
goToAccountDetailsModal = () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
this.props.hideWarning();
|
|
|
|
this.props.hideModal();
|
|
|
|
this.props.showAccountDetailModal();
|
|
|
|
};
|
2019-11-27 17:14:02 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
renderRow({
|
2019-11-27 17:14:02 +01:00
|
|
|
logo,
|
|
|
|
title,
|
|
|
|
text,
|
|
|
|
buttonLabel,
|
|
|
|
onButtonClick,
|
|
|
|
hide,
|
|
|
|
className,
|
|
|
|
hideButton,
|
|
|
|
hideTitle,
|
|
|
|
onBackClick,
|
|
|
|
showBackButton,
|
|
|
|
}) {
|
|
|
|
if (hide) {
|
2021-02-04 19:15:23 +01:00
|
|
|
return null;
|
2019-11-27 17:14:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={className || 'deposit-ether-modal__buy-row'}>
|
|
|
|
{onBackClick && showBackButton && (
|
2020-11-03 00:41:28 +01:00
|
|
|
<div
|
|
|
|
className="deposit-ether-modal__buy-row__back"
|
|
|
|
onClick={onBackClick}
|
|
|
|
>
|
2019-11-27 17:14:02 +01:00
|
|
|
<i className="fa fa-arrow-left cursor-pointer" />
|
|
|
|
</div>
|
|
|
|
)}
|
2020-11-03 00:41:28 +01:00
|
|
|
<div className="deposit-ether-modal__buy-row__logo-container">
|
|
|
|
{logo}
|
|
|
|
</div>
|
2019-11-27 17:14:02 +01:00
|
|
|
<div className="deposit-ether-modal__buy-row__description">
|
|
|
|
{!hideTitle && (
|
2020-11-03 00:41:28 +01:00
|
|
|
<div className="deposit-ether-modal__buy-row__description__title">
|
|
|
|
{title}
|
|
|
|
</div>
|
2019-11-27 17:14:02 +01:00
|
|
|
)}
|
2020-11-03 00:41:28 +01:00
|
|
|
<div className="deposit-ether-modal__buy-row__description__text">
|
|
|
|
{text}
|
|
|
|
</div>
|
2019-11-27 17:14:02 +01:00
|
|
|
</div>
|
|
|
|
{!hideButton && (
|
|
|
|
<div className="deposit-ether-modal__buy-row__button">
|
|
|
|
<Button
|
|
|
|
type="secondary"
|
|
|
|
className="deposit-ether-modal__deposit-button"
|
|
|
|
large
|
|
|
|
onClick={onButtonClick}
|
|
|
|
>
|
|
|
|
{buttonLabel}
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-11-27 17:14:02 +01:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
render() {
|
2021-02-16 16:31:16 +01:00
|
|
|
const {
|
2021-03-12 23:23:26 +01:00
|
|
|
chainId,
|
2021-02-16 16:31:16 +01:00
|
|
|
toWyre,
|
2021-06-25 15:10:24 +02:00
|
|
|
toTransak,
|
2021-02-16 16:31:16 +01:00
|
|
|
address,
|
|
|
|
toFaucet,
|
|
|
|
isTestnet,
|
|
|
|
isMainnet,
|
|
|
|
} = this.props;
|
2021-03-12 23:23:26 +01:00
|
|
|
const networkName = NETWORK_TO_NAME_MAP[chainId];
|
2019-11-27 17:14:02 +01:00
|
|
|
|
|
|
|
return (
|
2020-11-03 00:41:28 +01:00
|
|
|
<div className="page-container page-container--full-width page-container--full-height">
|
2019-11-27 17:14:02 +01:00
|
|
|
<div className="page-container__header">
|
|
|
|
<div className="page-container__title">
|
|
|
|
{this.context.t('depositEther')}
|
|
|
|
</div>
|
|
|
|
<div className="page-container__subtitle">
|
|
|
|
{this.context.t('needEtherInWallet')}
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
className="page-container__header-close"
|
|
|
|
onClick={() => {
|
2021-02-04 19:15:23 +01:00
|
|
|
this.props.hideWarning();
|
|
|
|
this.props.hideModal();
|
2019-11-27 17:14:02 +01:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="page-container__content">
|
|
|
|
<div className="deposit-ether-modal__buy-rows">
|
|
|
|
{this.renderRow({
|
|
|
|
logo: (
|
|
|
|
<div
|
|
|
|
className="deposit-ether-modal__logo"
|
|
|
|
style={{
|
|
|
|
backgroundImage: "url('./images/wyre.svg')",
|
|
|
|
height: '40px',
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
),
|
|
|
|
title: this.context.t('buyWithWyre'),
|
|
|
|
text: this.context.t('buyWithWyreDescription'),
|
|
|
|
buttonLabel: this.context.t('continueToWyre'),
|
2020-05-28 18:24:52 +02:00
|
|
|
onButtonClick: () => {
|
|
|
|
this.context.metricsEvent({
|
|
|
|
eventOpts: {
|
|
|
|
category: 'Accounts',
|
|
|
|
action: 'Deposit Ether',
|
|
|
|
name: 'Click buy Ether via Wyre',
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
toWyre(address);
|
2020-05-28 18:24:52 +02:00
|
|
|
},
|
2021-02-16 16:31:16 +01:00
|
|
|
hide: !isMainnet,
|
2019-11-27 17:14:02 +01:00
|
|
|
})}
|
2021-06-25 15:10:24 +02:00
|
|
|
{this.renderRow({
|
|
|
|
logo: (
|
|
|
|
<div
|
|
|
|
className="deposit-ether-modal__logo"
|
|
|
|
style={{
|
|
|
|
backgroundImage: "url('./images/transak.svg')",
|
|
|
|
height: '60px',
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
),
|
|
|
|
title: this.context.t('buyWithTransak'),
|
|
|
|
text: this.context.t('buyWithTransakDescription'),
|
|
|
|
buttonLabel: this.context.t('continueToTransak'),
|
|
|
|
onButtonClick: () => {
|
|
|
|
this.context.metricsEvent({
|
|
|
|
eventOpts: {
|
|
|
|
category: 'Accounts',
|
|
|
|
action: 'Deposit Ether',
|
|
|
|
name: 'Click buy Ether via Transak',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
toTransak(address);
|
|
|
|
},
|
|
|
|
hide: !isMainnet,
|
|
|
|
})}
|
2019-11-27 17:14:02 +01:00
|
|
|
{this.renderRow({
|
|
|
|
logo: (
|
2020-11-16 18:27:53 +01:00
|
|
|
<img
|
|
|
|
alt=""
|
2019-11-27 17:14:02 +01:00
|
|
|
className="deposit-ether-modal__logo"
|
2020-11-16 18:27:53 +01:00
|
|
|
src="./images/deposit-eth.svg"
|
2019-11-27 17:14:02 +01:00
|
|
|
style={{
|
2020-11-16 18:27:53 +01:00
|
|
|
height: '75px',
|
|
|
|
width: '75px',
|
2019-11-27 17:14:02 +01:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
),
|
2020-11-16 18:27:53 +01:00
|
|
|
title: this.context.t('directDepositEther'),
|
|
|
|
text: this.context.t('directDepositEtherExplainer'),
|
|
|
|
buttonLabel: this.context.t('viewAccount'),
|
|
|
|
onButtonClick: () => this.goToAccountDetailsModal(),
|
|
|
|
})}
|
2021-03-19 16:48:41 +01:00
|
|
|
{networkName &&
|
|
|
|
this.renderRow({
|
|
|
|
logo: <i className="fa fa-tint fa-2x" />,
|
|
|
|
title: this.context.t('testFaucet'),
|
|
|
|
text: this.context.t('getEtherFromFaucet', [networkName]),
|
|
|
|
buttonLabel: this.context.t('getEther'),
|
|
|
|
onButtonClick: () => toFaucet(chainId),
|
|
|
|
hide: !isTestnet,
|
|
|
|
})}
|
2019-11-27 17:14:02 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-11-27 17:14:02 +01:00
|
|
|
}
|
|
|
|
}
|