2021-02-04 19:15:23 +01:00
|
|
|
import classnames from 'classnames';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
import Button from '../../../components/ui/button';
|
2022-03-24 01:05:40 +01:00
|
|
|
import LogoLedger from '../../../components/ui/logo/logo-ledger';
|
|
|
|
import LogoQRBased from '../../../components/ui/logo/logo-qr-based';
|
|
|
|
import LogoTrezor from '../../../components/ui/logo/logo-trezor';
|
|
|
|
import LogoLattice from '../../../components/ui/logo/logo-lattice';
|
|
|
|
|
2021-11-23 18:28:39 +01:00
|
|
|
import {
|
|
|
|
DEVICE_NAMES,
|
|
|
|
LEDGER_TRANSPORT_TYPES,
|
|
|
|
} from '../../../../shared/constants/hardware-wallets';
|
2022-08-23 16:19:31 +02:00
|
|
|
import ZENDESK_URLS from '../../../helpers/constants/zendesk-url';
|
2018-07-05 23:45:28 +02:00
|
|
|
|
2020-05-28 20:47:48 +02:00
|
|
|
export default class SelectHardware extends Component {
|
2019-11-23 17:23:09 +01:00
|
|
|
static contextTypes = {
|
|
|
|
t: PropTypes.func,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-08-17 01:39:52 +02:00
|
|
|
|
2019-11-23 17:23:09 +01:00
|
|
|
static propTypes = {
|
|
|
|
connectToHardwareWallet: PropTypes.func.isRequired,
|
|
|
|
browserSupported: PropTypes.bool.isRequired,
|
2021-10-21 21:17:03 +02:00
|
|
|
ledgerTransportType: PropTypes.oneOf(Object.values(LEDGER_TRANSPORT_TYPES)),
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-08-17 01:39:52 +02:00
|
|
|
|
2019-11-23 17:23:09 +01:00
|
|
|
state = {
|
|
|
|
selectedDevice: null,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-08-17 01:39:52 +02:00
|
|
|
|
2019-11-23 17:23:09 +01:00
|
|
|
connect = () => {
|
|
|
|
if (this.state.selectedDevice) {
|
2021-02-04 19:15:23 +01:00
|
|
|
this.props.connectToHardwareWallet(this.state.selectedDevice);
|
2018-08-17 01:39:52 +02:00
|
|
|
}
|
2021-02-04 19:15:23 +01:00
|
|
|
return null;
|
|
|
|
};
|
2018-08-17 01:39:52 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
renderConnectToTrezorButton() {
|
2019-11-23 17:23:09 +01:00
|
|
|
return (
|
|
|
|
<button
|
|
|
|
className={classnames('hw-connect__btn', {
|
2021-11-23 18:28:39 +01:00
|
|
|
selected: this.state.selectedDevice === DEVICE_NAMES.TREZOR,
|
2019-11-23 17:23:09 +01:00
|
|
|
})}
|
2021-11-23 18:28:39 +01:00
|
|
|
onClick={(_) => this.setState({ selectedDevice: DEVICE_NAMES.TREZOR })}
|
2019-11-23 17:23:09 +01:00
|
|
|
>
|
2022-03-24 01:05:40 +01:00
|
|
|
<LogoTrezor className="hw-connect__btn__img" ariaLabel="Trezor" />
|
2019-11-23 17:23:09 +01:00
|
|
|
</button>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-11-23 17:23:09 +01:00
|
|
|
}
|
2018-07-05 23:45:28 +02:00
|
|
|
|
2021-11-08 15:48:41 +01:00
|
|
|
renderConnectToLatticeButton() {
|
|
|
|
return (
|
|
|
|
<button
|
|
|
|
className={classnames('hw-connect__btn', {
|
2021-11-23 18:28:39 +01:00
|
|
|
selected: this.state.selectedDevice === DEVICE_NAMES.LATTICE,
|
2021-11-08 15:48:41 +01:00
|
|
|
})}
|
2021-11-23 18:28:39 +01:00
|
|
|
onClick={(_) => this.setState({ selectedDevice: DEVICE_NAMES.LATTICE })}
|
2021-11-08 15:48:41 +01:00
|
|
|
>
|
2022-03-24 01:05:40 +01:00
|
|
|
<LogoLattice className="hw-connect__btn__img" ariaLabel="Lattice" />
|
2021-11-08 15:48:41 +01:00
|
|
|
</button>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
renderConnectToLedgerButton() {
|
2019-11-23 17:23:09 +01:00
|
|
|
return (
|
|
|
|
<button
|
|
|
|
className={classnames('hw-connect__btn', {
|
2021-11-23 18:28:39 +01:00
|
|
|
selected: this.state.selectedDevice === DEVICE_NAMES.LEDGER,
|
2019-11-23 17:23:09 +01:00
|
|
|
})}
|
2021-11-23 18:28:39 +01:00
|
|
|
onClick={(_) => this.setState({ selectedDevice: DEVICE_NAMES.LEDGER })}
|
2019-11-23 17:23:09 +01:00
|
|
|
>
|
2022-03-24 01:05:40 +01:00
|
|
|
<LogoLedger className="hw-connect__btn__img" ariaLabel="Ledger" />
|
2019-11-23 17:23:09 +01:00
|
|
|
</button>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-11-23 17:23:09 +01:00
|
|
|
}
|
2018-07-05 23:45:28 +02:00
|
|
|
|
2021-11-23 18:28:39 +01:00
|
|
|
renderConnectToQRButton() {
|
|
|
|
return (
|
|
|
|
<button
|
|
|
|
className={classnames('hw-connect__btn', {
|
|
|
|
selected: this.state.selectedDevice === DEVICE_NAMES.QR,
|
|
|
|
})}
|
|
|
|
onClick={(_) => this.setState({ selectedDevice: DEVICE_NAMES.QR })}
|
|
|
|
>
|
2022-03-24 01:05:40 +01:00
|
|
|
<LogoQRBased className="hw-connect__btn__img" ariaLabel="QRCode" />
|
2021-11-23 18:28:39 +01:00
|
|
|
</button>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
renderButtons() {
|
2019-11-23 17:23:09 +01:00
|
|
|
return (
|
2020-05-28 20:47:48 +02:00
|
|
|
<>
|
2019-11-23 17:23:09 +01:00
|
|
|
<div className="hw-connect__btn-wrapper">
|
|
|
|
{this.renderConnectToLedgerButton()}
|
|
|
|
{this.renderConnectToTrezorButton()}
|
|
|
|
</div>
|
2021-11-08 15:48:41 +01:00
|
|
|
<div
|
|
|
|
className="hw-connect__btn-wrapper"
|
|
|
|
style={{ margin: '10px 0 0 0' }}
|
|
|
|
>
|
|
|
|
{this.renderConnectToLatticeButton()}
|
2021-11-23 18:28:39 +01:00
|
|
|
{this.renderConnectToQRButton()}
|
2021-11-08 15:48:41 +01:00
|
|
|
</div>
|
2020-05-28 20:47:48 +02:00
|
|
|
</>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-11-23 17:23:09 +01:00
|
|
|
}
|
2018-07-19 04:57:47 +02:00
|
|
|
|
2021-04-26 20:05:48 +02:00
|
|
|
renderContinueButton() {
|
|
|
|
return (
|
|
|
|
<Button
|
|
|
|
type="primary"
|
|
|
|
large
|
|
|
|
className="hw-connect__connect-btn"
|
|
|
|
onClick={this.connect}
|
|
|
|
disabled={!this.state.selectedDevice}
|
|
|
|
>
|
|
|
|
{this.context.t('continue')}
|
|
|
|
</Button>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
renderUnsupportedBrowser() {
|
2019-11-23 17:23:09 +01:00
|
|
|
return (
|
2020-05-28 20:47:48 +02:00
|
|
|
<div className="new-external-account-form unsupported-browser">
|
2019-11-23 17:23:09 +01:00
|
|
|
<div className="hw-connect">
|
2020-11-03 00:41:28 +01:00
|
|
|
<h3 className="hw-connect__title">
|
|
|
|
{this.context.t('browserNotSupported')}
|
|
|
|
</h3>
|
|
|
|
<p className="hw-connect__msg">
|
|
|
|
{this.context.t('chromeRequiredForHardwareWallets')}
|
|
|
|
</p>
|
2019-11-23 17:23:09 +01:00
|
|
|
</div>
|
|
|
|
<Button
|
|
|
|
type="primary"
|
|
|
|
large
|
2020-11-03 00:41:28 +01:00
|
|
|
onClick={() =>
|
|
|
|
global.platform.openTab({
|
|
|
|
url: 'https://google.com/chrome',
|
|
|
|
})
|
|
|
|
}
|
2019-11-23 17:23:09 +01:00
|
|
|
>
|
|
|
|
{this.context.t('downloadGoogleChrome')}
|
|
|
|
</Button>
|
|
|
|
</div>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-11-23 17:23:09 +01:00
|
|
|
}
|
2018-07-19 04:57:47 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
renderHeader() {
|
2019-11-23 17:23:09 +01:00
|
|
|
return (
|
|
|
|
<div className="hw-connect__header">
|
2020-11-03 00:41:28 +01:00
|
|
|
<h3 className="hw-connect__header__title">
|
|
|
|
{this.context.t('hardwareWallets')}
|
|
|
|
</h3>
|
|
|
|
<p className="hw-connect__header__msg">
|
|
|
|
{this.context.t('hardwareWalletsMsg')}
|
|
|
|
</p>
|
2019-11-23 17:23:09 +01:00
|
|
|
</div>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-11-23 17:23:09 +01:00
|
|
|
}
|
2018-08-17 01:39:52 +02:00
|
|
|
|
2021-04-26 20:05:48 +02:00
|
|
|
renderTutorialsteps() {
|
|
|
|
switch (this.state.selectedDevice) {
|
2021-11-23 18:28:39 +01:00
|
|
|
case DEVICE_NAMES.LEDGER:
|
2021-04-26 20:05:48 +02:00
|
|
|
return this.renderLedgerTutorialSteps();
|
2021-11-23 18:28:39 +01:00
|
|
|
case DEVICE_NAMES.TREZOR:
|
2021-04-26 20:05:48 +02:00
|
|
|
return this.renderTrezorTutorialSteps();
|
2021-11-23 18:28:39 +01:00
|
|
|
case DEVICE_NAMES.LATTICE:
|
2021-11-08 15:48:41 +01:00
|
|
|
return this.renderLatticeTutorialSteps();
|
2021-11-23 18:28:39 +01:00
|
|
|
case DEVICE_NAMES.QR:
|
|
|
|
return this.renderQRHardwareWalletSteps();
|
2021-04-26 20:05:48 +02:00
|
|
|
default:
|
|
|
|
return '';
|
|
|
|
}
|
2019-11-23 17:23:09 +01:00
|
|
|
}
|
2018-07-19 05:12:49 +02:00
|
|
|
|
2021-04-26 20:05:48 +02:00
|
|
|
renderLedgerTutorialSteps() {
|
|
|
|
const steps = [];
|
2021-10-21 21:17:03 +02:00
|
|
|
if (this.props.ledgerTransportType === LEDGER_TRANSPORT_TYPES.LIVE) {
|
2021-04-26 20:05:48 +02:00
|
|
|
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>,
|
|
|
|
]),
|
|
|
|
});
|
2018-07-19 04:57:47 +02:00
|
|
|
}
|
|
|
|
|
2021-04-26 20:05:48 +02:00
|
|
|
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"
|
2022-08-23 16:19:31 +02:00
|
|
|
href={ZENDESK_URLS.HARDWARE_CONNECTION}
|
2021-04-26 20:05:48 +02:00
|
|
|
rel="noopener noreferrer"
|
|
|
|
target="_blank"
|
|
|
|
key="ledger-support-link"
|
|
|
|
>
|
|
|
|
{this.context.t('hardwareWalletSupportLinkConversion')}
|
|
|
|
</a>,
|
|
|
|
]),
|
|
|
|
});
|
|
|
|
|
2021-11-08 15:48:41 +01:00
|
|
|
return (
|
|
|
|
<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>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
renderLatticeTutorialSteps() {
|
|
|
|
const steps = [
|
|
|
|
{
|
|
|
|
asset: 'connect-lattice',
|
|
|
|
dimensions: { width: '225px', height: '75px' },
|
|
|
|
title: this.context.t('step1LatticeWallet'),
|
|
|
|
message: this.context.t('step1LatticeWalletMsg', [
|
|
|
|
<a
|
|
|
|
className="hw-connect__msg-link"
|
2022-08-23 16:19:31 +02:00
|
|
|
href={ZENDESK_URLS.HARDWARE_CONNECTION}
|
2021-11-08 15:48:41 +01:00
|
|
|
rel="noopener noreferrer"
|
|
|
|
target="_blank"
|
|
|
|
key="lattice-setup-link"
|
|
|
|
>
|
|
|
|
{this.context.t('hardwareWalletSupportLinkConversion')}
|
|
|
|
</a>,
|
|
|
|
]),
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2019-11-23 17:23:09 +01:00
|
|
|
return (
|
2021-04-26 20:05:48 +02:00
|
|
|
<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>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-11-23 17:23:09 +01:00
|
|
|
}
|
2018-07-19 04:57:47 +02:00
|
|
|
|
2021-04-26 20:05:48 +02:00
|
|
|
renderTrezorTutorialSteps() {
|
2019-11-23 17:23:09 +01:00
|
|
|
const steps = [
|
|
|
|
{
|
2021-04-26 20:05:48 +02:00
|
|
|
asset: 'plug-in-wallet',
|
2019-12-03 21:50:55 +01:00
|
|
|
dimensions: { width: '225px', height: '75px' },
|
2021-04-26 20:05:48 +02:00
|
|
|
title: this.context.t('step1TrezorWallet'),
|
|
|
|
message: this.context.t('step1TrezorWalletMsg', [
|
|
|
|
<a
|
|
|
|
className="hw-connect__msg-link"
|
2022-08-23 16:19:31 +02:00
|
|
|
href={ZENDESK_URLS.HARDWARE_CONNECTION}
|
2021-04-26 20:05:48 +02:00
|
|
|
rel="noopener noreferrer"
|
|
|
|
target="_blank"
|
|
|
|
key="trezor-support-link"
|
|
|
|
>
|
|
|
|
{this.context.t('hardwareWalletSupportLinkConversion')}
|
|
|
|
</a>,
|
|
|
|
]),
|
2019-11-23 17:23:09 +01:00
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
];
|
2018-07-05 23:45:28 +02:00
|
|
|
|
2019-11-23 17:23:09 +01:00
|
|
|
return (
|
2021-04-26 20:05:48 +02:00
|
|
|
<div className="hw-tutorial">
|
2019-11-23 17:23:09 +01:00
|
|
|
{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>
|
2021-04-26 20:05:48 +02:00
|
|
|
{step.asset && (
|
|
|
|
<img
|
|
|
|
className="hw-connect__step-asset"
|
|
|
|
src={`images/${step.asset}.svg`}
|
|
|
|
{...step.dimensions}
|
|
|
|
alt=""
|
|
|
|
/>
|
|
|
|
)}
|
2019-11-23 17:23:09 +01:00
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</div>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-11-23 17:23:09 +01:00
|
|
|
}
|
2018-07-05 23:45:28 +02:00
|
|
|
|
2021-11-23 18:28:39 +01:00
|
|
|
renderQRHardwareWalletSteps() {
|
|
|
|
const steps = [];
|
|
|
|
steps.push(
|
|
|
|
{
|
|
|
|
title: this.context.t('QRHardwareWalletSteps1Title'),
|
|
|
|
message: this.context.t('QRHardwareWalletSteps1Description'),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
message: (
|
|
|
|
<>
|
|
|
|
<a
|
|
|
|
className="hw-connect__msg-link"
|
|
|
|
href="https://keyst.one"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
target="_blank"
|
|
|
|
key="keystone-support-link"
|
|
|
|
>
|
|
|
|
{this.context.t('keystone')}
|
|
|
|
</a>
|
|
|
|
<a
|
|
|
|
className="hw-connect__msg-link"
|
|
|
|
href="https://keyst.one/mm"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
target="_blank"
|
|
|
|
key="keystone-tutorial-link"
|
|
|
|
>
|
|
|
|
{this.context.t('keystoneTutorial')}
|
|
|
|
</a>
|
|
|
|
</>
|
|
|
|
),
|
|
|
|
},
|
2022-02-22 20:00:51 +01:00
|
|
|
{
|
|
|
|
message: (
|
|
|
|
<>
|
|
|
|
<a
|
|
|
|
className="hw-connect__msg-link"
|
|
|
|
href="https://airgap.it/metamask"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
target="_blank"
|
|
|
|
key="airgap-vault-support-link"
|
|
|
|
>
|
|
|
|
{this.context.t('airgapVault')}
|
|
|
|
</a>
|
|
|
|
<a
|
|
|
|
className="hw-connect__msg-link"
|
|
|
|
href="https://support.airgap.it/guides/metamask"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
target="_blank"
|
|
|
|
key="airgap-vault-tutorial-link"
|
|
|
|
>
|
|
|
|
{this.context.t('airgapVaultTutorial')}
|
|
|
|
</a>
|
|
|
|
</>
|
|
|
|
),
|
|
|
|
},
|
2021-11-23 18:28:39 +01:00
|
|
|
{
|
|
|
|
message: this.context.t('QRHardwareWalletSteps2Description'),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
asset: 'qrcode-wallet-demo',
|
|
|
|
dimensions: { width: '225px', height: '75px' },
|
|
|
|
},
|
|
|
|
);
|
|
|
|
return (
|
|
|
|
<div className="hw-tutorial">
|
|
|
|
{steps.map((step, index) => (
|
|
|
|
<div className="hw-connect" key={index}>
|
|
|
|
{step.title && <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>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
renderConnectScreen() {
|
2019-11-23 17:23:09 +01:00
|
|
|
return (
|
2020-05-28 20:47:48 +02:00
|
|
|
<div className="new-external-account-form">
|
2019-11-23 17:23:09 +01:00
|
|
|
{this.renderHeader()}
|
|
|
|
{this.renderButtons()}
|
2021-10-21 18:11:31 +02:00
|
|
|
{this.state.selectedDevice ? this.renderTutorialsteps() : null}
|
2021-04-26 20:05:48 +02:00
|
|
|
{this.renderContinueButton()}
|
2019-11-23 17:23:09 +01:00
|
|
|
</div>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-11-23 17:23:09 +01:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
render() {
|
2019-11-23 17:23:09 +01:00
|
|
|
if (this.props.browserSupported) {
|
2021-02-04 19:15:23 +01:00
|
|
|
return this.renderConnectScreen();
|
2019-11-23 17:23:09 +01:00
|
|
|
}
|
2021-02-04 19:15:23 +01:00
|
|
|
return this.renderUnsupportedBrowser();
|
2019-11-23 17:23:09 +01:00
|
|
|
}
|
2018-07-05 23:45:28 +02:00
|
|
|
}
|