/ common / components / WalletDecrypt / components / ParitySigner.tsx
ParitySigner.tsx
 1  import React, { PureComponent } from 'react';
 2  import { connect } from 'react-redux';
 3  
 4  import translate from 'translations';
 5  import { isValidETHAddress } from 'libs/validators';
 6  import { ParitySignerWallet } from 'libs/wallet';
 7  import { wikiLink } from 'libs/wallet/non-deterministic/parity';
 8  import { notificationsActions } from 'features/notifications';
 9  import AppStoreBadge from 'assets/images/mobile/app-store-badge.png';
10  import GooglePlayBadge from 'assets/images/mobile/google-play-badge.png';
11  import { ParityQrSigner } from 'components';
12  import { NewTabLink } from 'components/ui';
13  import './ParitySigner.scss';
14  
15  interface Props {
16    showNotification: notificationsActions.TShowNotification;
17    onUnlock(param: any): void;
18  }
19  
20  interface SignerAddress {
21    address: string;
22    chainId: number;
23  }
24  
25  type SignerQrContent = SignerAddress | string;
26  
27  class ParitySignerDecryptClass extends PureComponent<Props> {
28    public render() {
29      return (
30        <div className="ParitySignerUnlock">
31          <ParityQrSigner scan={true} onScan={this.unlockAddress} />
32          <p>{translate('ADD_PARITY_4', { $wiki_link: wikiLink })}</p>
33          <p>{translate('ADD_PARITY_2')}</p>
34          <p>
35            <NewTabLink href="https://itunes.apple.com/us/app/parity-signer/id1218174838">
36              <img className="ParitySignerUnlock-badge" src={AppStoreBadge} alt="App Store" />
37            </NewTabLink>
38            <NewTabLink href="https://play.google.com/store/apps/details?id=com.nativesigner">
39              <img className="ParitySignerUnlock-badge" src={GooglePlayBadge} alt="Google Play" />
40            </NewTabLink>
41          </p>
42        </div>
43      );
44    }
45  
46    private unlockAddress = (content: SignerQrContent) => {
47      if (typeof content === 'string' || !isValidETHAddress(content.address)) {
48        this.props.showNotification('danger', 'Not a valid address!');
49        return;
50      }
51  
52      this.props.onUnlock(new ParitySignerWallet(content.address));
53    };
54  }
55  
56  export const ParitySignerDecrypt = connect(() => ({}), {
57    showNotification: notificationsActions.showNotification
58  })(ParitySignerDecryptClass);