2018-02-02 06:01:30 +00:00
|
|
|
import { IV3Wallet } from 'ethereumjs-wallet';
|
2017-12-28 19:54:07 +00:00
|
|
|
import React, { Component } from 'react';
|
2018-03-22 03:50:25 +00:00
|
|
|
import translate, { translateRaw } from 'translations';
|
2017-12-28 19:54:07 +00:00
|
|
|
import { makeBlob } from 'utils/blob';
|
|
|
|
import './DownloadWallet.scss';
|
|
|
|
import Template from '../Template';
|
|
|
|
|
|
|
|
interface Props {
|
2018-02-02 06:01:30 +00:00
|
|
|
keystore: IV3Wallet;
|
|
|
|
filename: string;
|
2017-12-28 19:54:07 +00:00
|
|
|
continue(): void;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface State {
|
|
|
|
hasDownloadedWallet: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default class DownloadWallet extends Component<Props, State> {
|
|
|
|
public state: State = {
|
2018-02-02 06:01:30 +00:00
|
|
|
hasDownloadedWallet: false
|
2017-12-28 19:54:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
public render() {
|
2018-02-02 06:01:30 +00:00
|
|
|
const { filename } = this.props;
|
2017-12-28 19:54:07 +00:00
|
|
|
const { hasDownloadedWallet } = this.state;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Template>
|
|
|
|
<div className="DlWallet">
|
2018-03-22 03:50:25 +00:00
|
|
|
<h1 className="DlWallet-title">{translate('GEN_LABEL_2')}</h1>
|
2017-12-28 19:54:07 +00:00
|
|
|
|
|
|
|
<a
|
|
|
|
role="button"
|
|
|
|
className="DlWallet-download btn btn-primary btn-lg"
|
|
|
|
aria-label="Download Keystore File (UTC / JSON · Recommended · Encrypted)"
|
2018-03-22 03:50:25 +00:00
|
|
|
aria-describedby={translateRaw('X_KEYSTOREDESC')}
|
2017-12-28 19:54:07 +00:00
|
|
|
download={filename}
|
|
|
|
href={this.getBlob()}
|
|
|
|
onClick={this.handleDownloadKeystore}
|
|
|
|
>
|
2018-03-22 03:50:25 +00:00
|
|
|
{translate('ACTION_13', { $thing: translateRaw('X_KEYSTORE2') })}
|
2017-12-28 19:54:07 +00:00
|
|
|
</a>
|
|
|
|
|
|
|
|
<div className="DlWallet-warning">
|
2018-03-22 03:50:25 +00:00
|
|
|
<p>{translate('DL_WALLET_WARNING_1')}</p>
|
|
|
|
<p>{translate('DL_WALLET_WARNING_2')}</p>
|
|
|
|
<p>{translate('DL_WALLET_WARNING_3')}</p>
|
2017-12-28 19:54:07 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<button
|
|
|
|
className="DlWallet-continue btn btn-danger"
|
|
|
|
role="button"
|
|
|
|
onClick={this.handleContinue}
|
|
|
|
disabled={!hasDownloadedWallet}
|
|
|
|
>
|
2018-03-22 03:50:25 +00:00
|
|
|
{translate('ACTION_14')}
|
2017-12-28 19:54:07 +00:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</Template>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-02-02 06:01:30 +00:00
|
|
|
public getBlob = () => makeBlob('text/json;charset=UTF-8', this.props.keystore);
|
2017-12-28 19:54:07 +00:00
|
|
|
|
|
|
|
private handleContinue = () => this.state.hasDownloadedWallet && this.props.continue();
|
|
|
|
|
2018-02-02 06:01:30 +00:00
|
|
|
private handleDownloadKeystore = () => this.setState({ hasDownloadedWallet: true });
|
2017-12-28 19:54:07 +00:00
|
|
|
}
|