/* eslint-disable react/prop-types */ import React, { Component, useState } from 'react'; import { Tab, Tabs, TabList, TabPanel } from 'react-tabs'; import { Accordion, AccordionItem, AccordionItemHeading, AccordionItemButton, AccordionItemPanel } from 'react-accessible-accordion'; import QRCode from 'qrcode.react'; import { shell, clipboard } from 'electron'; import styles from './Receive.css'; import cstyles from './Common.css'; import Utils from '../utils/utils'; import { AddressBalance, Info, ReceivePageState, AddressBookEntry } from './AppState'; import ScrollPane from './ScrollPane'; const AddressBlock = ({ addressBalance, label, currencyName, zecPrice, privateKey, fetchAndSetSinglePrivKey }) => { const { address } = addressBalance; const [copied, setCopied] = useState(false); const balance = addressBalance.balance || 0; const openAddress = () => { if (currencyName === 'TAZ') { shell.openExternal(`https://chain.so/address/ZECTEST/${address}`); } else { shell.openExternal(`https://zcha.in/accounts/${address}`); } }; return ( {address}
{label && (
Label
{label}
)}
Funds
{currencyName} {balance}
{Utils.getZecToUsdString(zecPrice, balance)}
{privateKey && (
Private Key
{privateKey}
)}
{!privateKey && ( )} {Utils.isTransparent(address) && ( )}
); }; type Props = { addresses: string[], addressesWithBalance: AddressBalance[], addressBook: AddressBookEntry[], info: Info, receivePageState: ReceivePageState, fetchAndSetSinglePrivKey: string => void, createNewAddress: boolean => void, rerenderKey: number }; export default class Receive extends Component { render() { const { addresses, addressesWithBalance, addressPrivateKeys, addressBook, info, receivePageState, fetchAndSetSinglePrivKey, createNewAddress, rerenderKey } = this.props; // Convert the addressBalances into a map. const addressMap = addressesWithBalance.reduce((map, a) => { // eslint-disable-next-line no-param-reassign map[a.address] = a.balance; return map; }, {}); const zaddrs = addresses .filter(a => Utils.isSapling(a)) .slice(0, 100) .map(a => new AddressBalance(a, addressMap[a])); let defaultZaddr = zaddrs.length ? zaddrs[0].address : ''; if (receivePageState && Utils.isSapling(receivePageState.newAddress)) { defaultZaddr = receivePageState.newAddress; // move this address to the front, since the scrollbar will reset when we re-render zaddrs.sort((x, y) => { // eslint-disable-next-line prettier/prettier, no-nested-ternary return x.address === defaultZaddr ? -1 : y.address === defaultZaddr ? 1 : 0 }); } const taddrs = addresses .filter(a => Utils.isTransparent(a)) .slice(0, 100) .map(a => new AddressBalance(a, addressMap[a])); let defaultTaddr = taddrs.length ? taddrs[0].address : ''; if (receivePageState && Utils.isTransparent(receivePageState.newAddress)) { defaultTaddr = receivePageState.newAddress; // move this address to the front, since the scrollbar will reset when we re-render taddrs.sort((x, y) => { // eslint-disable-next-line prettier/prettier, no-nested-ternary return x.address === defaultTaddr ? -1 : y.address === defaultTaddr ? 1 : 0 }); } const addressBookMap = addressBook.reduce((map, obj) => { // eslint-disable-next-line no-param-reassign map[obj.address] = obj.label; return map; }, {}); return (
Shielded Transparent {/* Change the hardcoded height */} {zaddrs.map(a => ( ))} {/* Change the hardcoded height */} {taddrs.map(a => ( ))}
); } }