2017-07-16 21:02:13 +00:00
|
|
|
import React from 'react';
|
2018-06-15 23:28:42 +00:00
|
|
|
import html2canvas from 'html2canvas';
|
2018-06-11 21:22:25 +00:00
|
|
|
import { addHexPrefix, toChecksumAddress } from 'ethereumjs-util';
|
2018-06-18 01:53:00 +00:00
|
|
|
|
2017-07-16 21:02:13 +00:00
|
|
|
import notesBg from 'assets/images/notes-bg.png';
|
2017-09-25 02:06:28 +00:00
|
|
|
import sidebarImg from 'assets/images/print-sidebar.png';
|
2018-06-18 01:53:00 +00:00
|
|
|
import { Identicon, QRCode } from 'components/ui';
|
2018-06-15 23:28:42 +00:00
|
|
|
import './index.scss';
|
2017-07-16 21:02:13 +00:00
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
interface Props {
|
|
|
|
address: string;
|
2017-10-14 19:24:48 +00:00
|
|
|
privateKey: string;
|
2017-09-25 02:06:28 +00:00
|
|
|
}
|
2017-08-09 12:01:34 +00:00
|
|
|
|
2017-10-14 19:24:48 +00:00
|
|
|
export default class PaperWallet extends React.Component<Props, {}> {
|
2018-06-15 23:28:42 +00:00
|
|
|
private container: HTMLElement | null;
|
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
public render() {
|
2018-06-11 21:22:25 +00:00
|
|
|
const { privateKey } = this.props;
|
|
|
|
const address = toChecksumAddress(addHexPrefix(this.props.address));
|
2017-07-16 21:02:13 +00:00
|
|
|
|
|
|
|
return (
|
2018-06-15 23:28:42 +00:00
|
|
|
<div className="PaperWallet" ref={el => (this.container = el)}>
|
|
|
|
<img src={sidebarImg} className="PaperWallet-sidebar" alt="MyCrypto Logo" />
|
2017-07-16 21:02:13 +00:00
|
|
|
|
2018-06-15 23:28:42 +00:00
|
|
|
<div className="PaperWallet-block">
|
|
|
|
<div className="PaperWallet-block-box">
|
2017-10-14 19:24:48 +00:00
|
|
|
<QRCode data={address} />
|
2017-07-16 21:02:13 +00:00
|
|
|
</div>
|
2018-06-15 23:28:42 +00:00
|
|
|
<p className="PaperWallet-block-text">YOUR ADDRESS</p>
|
2017-07-16 21:02:13 +00:00
|
|
|
</div>
|
|
|
|
|
2018-06-15 23:28:42 +00:00
|
|
|
<div className="PaperWallet-block">
|
|
|
|
<img src={notesBg} className="PaperWallet-block-box is-shaded" aria-hidden={true} />
|
|
|
|
<p className="PaperWallet-block-text">AMOUNT / NOTES</p>
|
2017-07-16 21:02:13 +00:00
|
|
|
</div>
|
|
|
|
|
2018-06-15 23:28:42 +00:00
|
|
|
<div className="PaperWallet-block">
|
|
|
|
<div className="PaperWallet-block-box">
|
2017-07-16 21:02:13 +00:00
|
|
|
<QRCode data={privateKey} />
|
|
|
|
</div>
|
2018-06-15 23:28:42 +00:00
|
|
|
<p className="PaperWallet-block-text">YOUR PRIVATE KEY</p>
|
2017-07-16 21:02:13 +00:00
|
|
|
</div>
|
|
|
|
|
2018-06-15 23:28:42 +00:00
|
|
|
<div className="PaperWallet-info">
|
|
|
|
<p className="PaperWallet-info-text">
|
|
|
|
<strong className="PaperWallet-info-text-label">Your Address:</strong>
|
2017-07-16 21:02:13 +00:00
|
|
|
<br />
|
2017-10-14 19:24:48 +00:00
|
|
|
{address}
|
2017-07-16 21:02:13 +00:00
|
|
|
</p>
|
2018-06-15 23:28:42 +00:00
|
|
|
<p className="PaperWallet-info-text">
|
|
|
|
<strong className="PaperWallet-info-text-label">Your Private Key:</strong>
|
2017-07-16 21:02:13 +00:00
|
|
|
<br />
|
|
|
|
{privateKey}
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
|
2018-06-15 23:28:42 +00:00
|
|
|
<div className="PaperWallet-identicon">
|
|
|
|
<div className="PaperWallet-identicon-left">
|
2017-10-14 19:24:48 +00:00
|
|
|
<Identicon address={address} size={'42px'} />
|
2017-07-16 21:02:13 +00:00
|
|
|
</div>
|
2018-06-15 23:28:42 +00:00
|
|
|
<p className="PaperWallet-identicon-text">
|
|
|
|
Always look for this icon when sending to this wallet
|
|
|
|
</p>
|
2017-07-16 21:02:13 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2018-06-15 23:28:42 +00:00
|
|
|
|
|
|
|
public toPNG = async () => {
|
|
|
|
if (!this.container) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
const canvas = await html2canvas(this.container);
|
|
|
|
return canvas.toDataURL('image/png');
|
|
|
|
};
|
2017-07-16 21:02:13 +00:00
|
|
|
}
|