2018-03-26 23:32:43 +02:00
|
|
|
// @flow
|
2017-12-21 22:08:54 +01:00
|
|
|
import React from 'react';
|
2018-03-26 23:32:43 +02:00
|
|
|
import Button from 'component/button';
|
2019-01-22 21:36:28 +01:00
|
|
|
import CopyableText from 'component/copyableText';
|
2018-06-12 15:22:53 +02:00
|
|
|
import QRCode from 'component/common/qr-code';
|
2019-09-26 18:07:11 +02:00
|
|
|
import Card from 'component/common/card';
|
2020-09-02 22:08:37 +02:00
|
|
|
import LbcSymbol from 'component/common/lbc-symbol';
|
2017-05-11 02:59:47 +02:00
|
|
|
|
2018-03-26 23:32:43 +02:00
|
|
|
type Props = {
|
|
|
|
checkAddressIsMine: string => void,
|
|
|
|
receiveAddress: string,
|
|
|
|
getNewAddress: () => void,
|
|
|
|
gettingNewAddress: boolean,
|
|
|
|
};
|
|
|
|
|
2018-10-28 19:32:52 +01:00
|
|
|
type State = {
|
|
|
|
showQR: boolean,
|
|
|
|
};
|
|
|
|
|
|
|
|
class WalletAddress extends React.PureComponent<Props, State> {
|
2018-06-12 15:22:53 +02:00
|
|
|
constructor(props: Props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
showQR: false,
|
|
|
|
};
|
|
|
|
|
2019-03-05 18:54:11 +01:00
|
|
|
(this: any).toggleQR = this.toggleQR.bind(this);
|
2018-06-12 15:22:53 +02:00
|
|
|
}
|
|
|
|
|
2019-06-17 22:32:38 +02:00
|
|
|
componentDidMount() {
|
2018-04-19 01:02:24 +02:00
|
|
|
const { checkAddressIsMine, receiveAddress, getNewAddress } = this.props;
|
|
|
|
if (!receiveAddress) {
|
|
|
|
getNewAddress();
|
|
|
|
} else {
|
|
|
|
checkAddressIsMine(receiveAddress);
|
|
|
|
}
|
2017-05-11 02:59:47 +02:00
|
|
|
}
|
|
|
|
|
2018-10-28 19:32:52 +01:00
|
|
|
toggleQR() {
|
|
|
|
this.setState({
|
|
|
|
showQR: !this.state.showQR,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-05-11 02:59:47 +02:00
|
|
|
render() {
|
2019-11-22 22:13:00 +01:00
|
|
|
const { receiveAddress, getNewAddress, gettingNewAddress } = this.props;
|
2018-06-12 15:22:53 +02:00
|
|
|
const { showQR } = this.state;
|
2017-05-11 02:59:47 +02:00
|
|
|
|
|
|
|
return (
|
2019-09-26 18:07:11 +02:00
|
|
|
<Card
|
2020-09-02 22:08:37 +02:00
|
|
|
title={<LbcSymbol prefix={__('Receive')} isTitle />}
|
|
|
|
subtitle={__('Use this address to receive LBRY Credits.')}
|
2019-09-26 18:07:11 +02:00
|
|
|
actions={
|
|
|
|
<React.Fragment>
|
2019-11-22 22:13:00 +01:00
|
|
|
<CopyableText
|
|
|
|
primaryButton
|
|
|
|
label={__('Your Address')}
|
|
|
|
copyable={receiveAddress}
|
|
|
|
snackMessage={__('Address copied.')}
|
|
|
|
/>
|
2018-03-26 23:32:43 +02:00
|
|
|
|
2019-09-26 18:07:11 +02:00
|
|
|
<div className="card__actions">
|
|
|
|
{!IS_WEB && (
|
|
|
|
<Button
|
2019-11-22 22:13:00 +01:00
|
|
|
button="secondary"
|
2019-09-26 18:07:11 +02:00
|
|
|
label={__('Get New Address')}
|
|
|
|
onClick={getNewAddress}
|
|
|
|
disabled={gettingNewAddress}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
<Button button="link" label={showQR ? __('Hide QR code') : __('Show QR code')} onClick={this.toggleQR} />
|
|
|
|
</div>
|
2019-09-30 23:48:30 +02:00
|
|
|
<p className="help">
|
2019-11-01 18:27:01 +01:00
|
|
|
{!IS_WEB &&
|
|
|
|
__('You can generate a new address at any time, and any previous addresses will continue to work.')}
|
2019-09-30 23:48:30 +02:00
|
|
|
</p>
|
2018-03-26 23:32:43 +02:00
|
|
|
|
2019-09-26 18:07:11 +02:00
|
|
|
{showQR && <QRCode value={receiveAddress} paddingTop />}
|
|
|
|
</React.Fragment>
|
|
|
|
}
|
|
|
|
/>
|
2017-05-11 02:59:47 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-06 06:21:55 +02:00
|
|
|
export default WalletAddress;
|