You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
251 lines
6.5 KiB
251 lines
6.5 KiB
4 years ago
|
import classnames from 'classnames';
|
||
|
import PropTypes from 'prop-types';
|
||
|
import React, { Component } from 'react';
|
||
|
import Button from '../../../components/ui/button';
|
||
7 years ago
|
|
||
5 years ago
|
export default class SelectHardware extends Component {
|
||
5 years ago
|
static contextTypes = {
|
||
|
t: PropTypes.func,
|
||
4 years ago
|
};
|
||
6 years ago
|
|
||
5 years ago
|
static propTypes = {
|
||
|
connectToHardwareWallet: PropTypes.func.isRequired,
|
||
|
browserSupported: PropTypes.bool.isRequired,
|
||
4 years ago
|
useLedgerLive: PropTypes.bool.isRequired,
|
||
4 years ago
|
};
|
||
6 years ago
|
|
||
5 years ago
|
state = {
|
||
|
selectedDevice: null,
|
||
4 years ago
|
};
|
||
6 years ago
|
|
||
5 years ago
|
connect = () => {
|
||
|
if (this.state.selectedDevice) {
|
||
4 years ago
|
this.props.connectToHardwareWallet(this.state.selectedDevice);
|
||
6 years ago
|
}
|
||
4 years ago
|
return null;
|
||
|
};
|
||
6 years ago
|
|
||
4 years ago
|
renderConnectToTrezorButton() {
|
||
5 years ago
|
return (
|
||
|
<button
|
||
|
className={classnames('hw-connect__btn', {
|
||
4 years ago
|
selected: this.state.selectedDevice === 'trezor',
|
||
5 years ago
|
})}
|
||
5 years ago
|
onClick={(_) => this.setState({ selectedDevice: 'trezor' })}
|
||
5 years ago
|
>
|
||
|
<img
|
||
|
className="hw-connect__btn__img"
|
||
|
src="images/trezor-logo.svg"
|
||
4 years ago
|
alt="Trezor"
|
||
5 years ago
|
/>
|
||
|
</button>
|
||
4 years ago
|
);
|
||
5 years ago
|
}
|
||
7 years ago
|
|
||
4 years ago
|
renderConnectToLedgerButton() {
|
||
5 years ago
|
return (
|
||
|
<button
|
||
|
className={classnames('hw-connect__btn', {
|
||
4 years ago
|
selected: this.state.selectedDevice === 'ledger',
|
||
5 years ago
|
})}
|
||
5 years ago
|
onClick={(_) => this.setState({ selectedDevice: 'ledger' })}
|
||
5 years ago
|
>
|
||
|
<img
|
||
|
className="hw-connect__btn__img"
|
||
|
src="images/ledger-logo.svg"
|
||
4 years ago
|
alt="Ledger"
|
||
5 years ago
|
/>
|
||
|
</button>
|
||
4 years ago
|
);
|
||
5 years ago
|
}
|
||
7 years ago
|
|
||
4 years ago
|
renderButtons() {
|
||
5 years ago
|
return (
|
||
5 years ago
|
<>
|
||
5 years ago
|
<div className="hw-connect__btn-wrapper">
|
||
|
{this.renderConnectToLedgerButton()}
|
||
|
{this.renderConnectToTrezorButton()}
|
||
|
</div>
|
||
5 years ago
|
</>
|
||
4 years ago
|
);
|
||
5 years ago
|
}
|
||
6 years ago
|
|
||
4 years ago
|
renderContinueButton() {
|
||
|
return (
|
||
|
<Button
|
||
|
type="primary"
|
||
|
large
|
||
|
className="hw-connect__connect-btn"
|
||
|
onClick={this.connect}
|
||
|
disabled={!this.state.selectedDevice}
|
||
|
>
|
||
|
{this.context.t('continue')}
|
||
|
</Button>
|
||
|
);
|
||
|
}
|
||
|
|
||
4 years ago
|
renderUnsupportedBrowser() {
|
||
5 years ago
|
return (
|
||
5 years ago
|
<div className="new-external-account-form unsupported-browser">
|
||
5 years ago
|
<div className="hw-connect">
|
||
4 years ago
|
<h3 className="hw-connect__title">
|
||
|
{this.context.t('browserNotSupported')}
|
||
|
</h3>
|
||
|
<p className="hw-connect__msg">
|
||
|
{this.context.t('chromeRequiredForHardwareWallets')}
|
||
|
</p>
|
||
5 years ago
|
</div>
|
||
|
<Button
|
||
|
type="primary"
|
||
|
large
|
||
4 years ago
|
onClick={() =>
|
||
|
global.platform.openTab({
|
||
|
url: 'https://google.com/chrome',
|
||
|
})
|
||
|
}
|
||
5 years ago
|
>
|
||
|
{this.context.t('downloadGoogleChrome')}
|
||
|
</Button>
|
||
|
</div>
|
||
4 years ago
|
);
|
||
5 years ago
|
}
|
||
6 years ago
|
|
||
4 years ago
|
renderHeader() {
|
||
5 years ago
|
return (
|
||
|
<div className="hw-connect__header">
|
||
4 years ago
|
<h3 className="hw-connect__header__title">
|
||
|
{this.context.t('hardwareWallets')}
|
||
|
</h3>
|
||
|
<p className="hw-connect__header__msg">
|
||
|
{this.context.t('hardwareWalletsMsg')}
|
||
|
</p>
|
||
5 years ago
|
</div>
|
||
4 years ago
|
);
|
||
5 years ago
|
}
|
||
6 years ago
|
|
||
4 years ago
|
renderTutorialsteps() {
|
||
|
switch (this.state.selectedDevice) {
|
||
|
case 'ledger':
|
||
|
return this.renderLedgerTutorialSteps();
|
||
|
case 'trezor':
|
||
|
return this.renderTrezorTutorialSteps();
|
||
|
default:
|
||
|
return '';
|
||
|
}
|
||
5 years ago
|
}
|
||
6 years ago
|
|
||
4 years ago
|
renderLedgerTutorialSteps() {
|
||
|
const steps = [];
|
||
|
if (this.props.useLedgerLive) {
|
||
|
steps.push({
|
||
|
title: this.context.t('step1LedgerWallet'),
|
||
|
message: this.context.t('step1LedgerWalletMsg', [
|
||
|
<a
|
||
|
className="hw-connect__msg-link"
|
||
|
href="https://www.ledger.com/ledger-live"
|
||
|
rel="noopener noreferrer"
|
||
|
target="_blank"
|
||
|
key="ledger-live-app-link"
|
||
|
>
|
||
|
{this.context.t('ledgerLiveApp')}
|
||
|
</a>,
|
||
|
]),
|
||
|
});
|
||
4 years ago
|
}
|
||
|
|
||
4 years ago
|
steps.push({
|
||
|
asset: 'plug-in-wallet',
|
||
|
dimensions: { width: '225px', height: '75px' },
|
||
|
title: this.context.t('step2LedgerWallet'),
|
||
|
message: this.context.t('step2LedgerWalletMsg', [
|
||
|
<a
|
||
|
className="hw-connect__msg-link"
|
||
|
href="https://metamask.zendesk.com/hc/en-us/articles/360020394612-How-to-connect-a-Trezor-or-Ledger-Hardware-Wallet"
|
||
|
rel="noopener noreferrer"
|
||
|
target="_blank"
|
||
|
key="ledger-support-link"
|
||
|
>
|
||
|
{this.context.t('hardwareWalletSupportLinkConversion')}
|
||
|
</a>,
|
||
|
]),
|
||
|
});
|
||
|
|
||
4 years ago
|
return (
|
||
4 years ago
|
<div className="hw-tutorial">
|
||
|
{steps.map((step, index) => (
|
||
|
<div className="hw-connect" key={index}>
|
||
|
<h3 className="hw-connect__title">{step.title}</h3>
|
||
|
<p className="hw-connect__msg">{step.message}</p>
|
||
|
{step.asset && (
|
||
|
<img
|
||
|
className="hw-connect__step-asset"
|
||
|
src={`images/${step.asset}.svg`}
|
||
|
{...step.dimensions}
|
||
|
alt=""
|
||
|
/>
|
||
|
)}
|
||
|
</div>
|
||
|
))}
|
||
|
</div>
|
||
4 years ago
|
);
|
||
|
}
|
||
|
|
||
4 years ago
|
renderTrezorTutorialSteps() {
|
||
5 years ago
|
const steps = [
|
||
|
{
|
||
4 years ago
|
asset: 'plug-in-wallet',
|
||
5 years ago
|
dimensions: { width: '225px', height: '75px' },
|
||
4 years ago
|
title: this.context.t('step1TrezorWallet'),
|
||
|
message: this.context.t('step1TrezorWalletMsg', [
|
||
|
<a
|
||
|
className="hw-connect__msg-link"
|
||
|
href="https://metamask.zendesk.com/hc/en-us/articles/360020394612-How-to-connect-a-Trezor-or-Ledger-Hardware-Wallet"
|
||
|
rel="noopener noreferrer"
|
||
|
target="_blank"
|
||
|
key="trezor-support-link"
|
||
|
>
|
||
|
{this.context.t('hardwareWalletSupportLinkConversion')}
|
||
|
</a>,
|
||
|
]),
|
||
5 years ago
|
},
|
||
4 years ago
|
];
|
||
7 years ago
|
|
||
5 years ago
|
return (
|
||
4 years ago
|
<div className="hw-tutorial">
|
||
5 years ago
|
{steps.map((step, index) => (
|
||
|
<div className="hw-connect" key={index}>
|
||
|
<h3 className="hw-connect__title">{step.title}</h3>
|
||
|
<p className="hw-connect__msg">{step.message}</p>
|
||
4 years ago
|
{step.asset && (
|
||
|
<img
|
||
|
className="hw-connect__step-asset"
|
||
|
src={`images/${step.asset}.svg`}
|
||
|
{...step.dimensions}
|
||
|
alt=""
|
||
|
/>
|
||
|
)}
|
||
5 years ago
|
</div>
|
||
|
))}
|
||
|
</div>
|
||
4 years ago
|
);
|
||
5 years ago
|
}
|
||
7 years ago
|
|
||
4 years ago
|
renderConnectScreen() {
|
||
5 years ago
|
return (
|
||
5 years ago
|
<div className="new-external-account-form">
|
||
5 years ago
|
{this.renderHeader()}
|
||
|
{this.renderButtons()}
|
||
4 years ago
|
{this.state.selectedDevice && this.renderTutorialsteps()}
|
||
|
{this.renderContinueButton()}
|
||
5 years ago
|
</div>
|
||
4 years ago
|
);
|
||
5 years ago
|
}
|
||
|
|
||
4 years ago
|
render() {
|
||
5 years ago
|
if (this.props.browserSupported) {
|
||
4 years ago
|
return this.renderConnectScreen();
|
||
5 years ago
|
}
|
||
4 years ago
|
return this.renderUnsupportedBrowser();
|
||
5 years ago
|
}
|
||
7 years ago
|
}
|