2021-06-09 17:28:16 -07:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import QRCode from 'qrcode.react';
|
2022-01-10 14:17:52 -08:00
|
|
|
import React from 'react';
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2022-01-10 14:01:24 -08:00
|
|
|
import Icon from 'soapbox/components/icon';
|
2021-06-09 17:49:53 -07:00
|
|
|
import { CopyableInput } from 'soapbox/features/forms';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2021-06-09 17:49:53 -07:00
|
|
|
import { getExplorerUrl } from '../utils/block_explorer';
|
2022-01-10 14:17:52 -08:00
|
|
|
import CoinDB from '../utils/coin_db';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2022-01-10 14:01:24 -08:00
|
|
|
import CryptoIcon from './crypto_icon';
|
2021-06-09 17:28:16 -07:00
|
|
|
|
2021-09-11 14:49:05 -07:00
|
|
|
export default class DetailedCryptoAddress extends ImmutablePureComponent {
|
2021-06-09 17:28:16 -07:00
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
address: PropTypes.string.isRequired,
|
|
|
|
ticker: PropTypes.string.isRequired,
|
|
|
|
note: PropTypes.string,
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { address, ticker, note } = this.props;
|
|
|
|
const title = CoinDB.getIn([ticker, 'name']);
|
|
|
|
const explorerUrl = getExplorerUrl(ticker, address);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className='crypto-address'>
|
|
|
|
<div className='crypto-address__head'>
|
2021-09-11 14:21:12 -07:00
|
|
|
<CryptoIcon
|
|
|
|
className='crypto-address__icon'
|
|
|
|
ticker={ticker}
|
|
|
|
title={title}
|
|
|
|
/>
|
2021-06-09 18:36:02 -07:00
|
|
|
<div className='crypto-address__title'>{title || ticker.toUpperCase()}</div>
|
2021-06-09 17:28:16 -07:00
|
|
|
<div className='crypto-address__actions'>
|
2021-06-09 18:36:02 -07:00
|
|
|
{explorerUrl && <a href={explorerUrl} target='_blank'>
|
2021-09-27 21:47:43 -07:00
|
|
|
<Icon src={require('@tabler/icons/icons/external-link.svg')} />
|
2021-06-09 18:36:02 -07:00
|
|
|
</a>}
|
2021-06-09 17:28:16 -07:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{note && <div className='crypto-address__note'>{note}</div>}
|
|
|
|
<div className='crypto-address__qrcode'>
|
|
|
|
<QRCode value={address} />
|
|
|
|
</div>
|
|
|
|
<div className='crypto-address__address simple_form'>
|
2021-06-09 17:49:53 -07:00
|
|
|
<CopyableInput value={address} />
|
2021-06-09 17:28:16 -07:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|