import * as React from "react"; import * as Strings from "~/common/strings"; import * as Constants from "~/common/constants"; import * as SVG from "~/common/svg"; import * as System from "~/components/system"; import { css } from "@emotion/react"; import { dispatchCustomEvent } from "~/common/custom-events"; import { LoaderSpinner } from "~/components/system/components/Loaders"; import Section from "~/components/core/Section"; import ScenePage from "~/components/core/ScenePage"; import ScenePageHeader from "~/components/core/ScenePageHeader"; import TestnetBanner from "~/components/core/TestnetBanner"; const STYLES_GROUP = css` padding: 24px; `; const STYLES_ROW = css` display: flex; align-items: flex-start; justify-content: space-between; padding: 24px; width: 100%; `; const STYLES_CIRCLE_BUTTON = css` height: 48px; width: 48px; border-radius: 48px; display: inline-flex; align-items: center; justify-content: center; background: ${Constants.system.black}; color: ${Constants.system.white}; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07); cursor: pointer; `; const STYLES_TEXT = css` min-width: 5%; padding-top: 6px; width: 100%; overflow-wrap: break-word; `; const STYLES_FOCUS = css` font-size: ${Constants.typescale.lvl1}; font-family: ${Constants.font.medium}; overflow-wrap: break-word; width: 100%; strong { font-family: ${Constants.font.semiBold}; font-weight: 400; } `; const STYLES_FOCUS_EMPAHSIS = css` color: ${Constants.system.brand}; `; const STYLES_SUBTEXT = css` margin-top: 8px; font-size: 12px; overflow-wrap: break-word; `; const STYLES_ACTIONS = css` flex-shrink: 0; padding-left: 24px; `; const STYLES_ITEM = css` margin-top: 24px; display: inline-flex; flex-direction: column; max-width: 220px; margin-right: 32px; `; const STYLES_ITEM_GROUP = css` display: flex; align-items: flex-start; justify-content: flex-start; `; let mounted = false; export default class SceneWallet extends React.Component { state = {}; async componentDidMount() { if (mounted) { return null; } mounted = true; let networkViewer; try { const response = await fetch("/api/network"); const json = await response.json(); networkViewer = json.data; } catch (e) {} this.setState({ networkViewer, }); } componentWillUnmount() { mounted = false; } state = { table_transaction: null, visible: false }; _handleChange = (e) => { this.setState({ [e.target.name]: e.target.value }); }; _handleWalletChange = (e) => { this.setState({ visible: false }); this.props.onSelectedChange(e); }; _handleMakeAddressVisible = () => { this.setState({ visible: !this.state.visible }); }; _handleCopy = (text) => { Strings.copyText(text); dispatchCustomEvent({ name: "create-alert", detail: { alert: { message: "Copied to clipboard!", status: "INFO" } }, }); }; render() { // TODO(jim): Temporary because of read only Filecoin Addresses const { networkViewer } = this.state; const addressMap = {}; const addresses = []; let selected = null; if (networkViewer) { networkViewer.powerInfo.balancesList.forEach((a) => { addressMap[a.addr.addr] = { ...a.addr, balance: a.balance }; addresses.push({ ...a.addr, balance: a.balance }); }); if (addresses.length) { selected = addresses[0]; } let transactions = []; if (selected.transactions) { transactions = [...selected.transactions]; } } return ( This is your wallet address. It is prefilled by Textile to help test the Filecoin Testnet. {networkViewer ? (
{/*
*/}
{this.state.visible ? ( selected.addr ) : ( Hidden )}
Filecoin address
{selected.name}{" "} {networkViewer.settings_cold_default_address === selected.addr ? ( (Primary) ) : null}
Filecoin address alias
{Strings.formatAsFilecoinConversion(selected.balance)}
Filecoin
{selected.type}
Address type
this._handleCopy(selected.address)} >
) : ( )}
); } }