2020-09-10 02:52:45 +03:00
|
|
|
import * as React from "react";
|
|
|
|
import * as System from "~/components/system";
|
2020-09-09 20:56:35 +03:00
|
|
|
import * as Constants from "~/common/constants";
|
2020-09-23 22:46:56 +03:00
|
|
|
import * as Strings from "~/common/strings";
|
2020-09-10 02:52:45 +03:00
|
|
|
|
|
|
|
import { css } from "@emotion/react";
|
2020-09-09 20:56:35 +03:00
|
|
|
import { LoaderSpinner } from "~/components/system/components/Loaders";
|
2020-09-10 02:52:45 +03:00
|
|
|
|
|
|
|
import Section from "~/components/core/Section";
|
|
|
|
import ScenePage from "~/components/core/ScenePage";
|
|
|
|
import ScenePageHeader from "~/components/core/ScenePageHeader";
|
2020-09-23 05:35:56 +03:00
|
|
|
import TestnetBanner from "~/components/core/TestnetBanner";
|
2020-09-10 02:52:45 +03:00
|
|
|
|
2020-09-09 20:56:35 +03:00
|
|
|
const STYLES_LABEL = css`
|
|
|
|
font-family: ${Constants.font.semiBold};
|
|
|
|
font-size: 16px;
|
|
|
|
margin-bottom: 16px;
|
|
|
|
`;
|
|
|
|
|
2020-09-23 12:46:59 +03:00
|
|
|
let mounted = false;
|
|
|
|
|
2020-09-10 02:52:45 +03:00
|
|
|
export default class SceneArchive extends React.Component {
|
2020-09-23 22:46:56 +03:00
|
|
|
state = { networkViewer: null };
|
2020-09-09 20:56:35 +03:00
|
|
|
|
|
|
|
async componentDidMount() {
|
2020-09-23 12:46:59 +03:00
|
|
|
if (mounted) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
mounted = true;
|
2020-09-09 20:56:35 +03:00
|
|
|
let networkViewer;
|
|
|
|
try {
|
|
|
|
const response = await fetch("/api/network");
|
|
|
|
const json = await response.json();
|
|
|
|
networkViewer = json.data;
|
|
|
|
} catch (e) {}
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
networkViewer,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-09-23 12:46:59 +03:00
|
|
|
componentWillUnmount() {
|
|
|
|
mounted = false;
|
|
|
|
}
|
|
|
|
|
2020-09-10 02:52:45 +03:00
|
|
|
render() {
|
2020-09-23 22:46:56 +03:00
|
|
|
const { networkViewer } = this.state;
|
|
|
|
const addressMap = {};
|
|
|
|
const addresses = [];
|
|
|
|
let selected = null;
|
|
|
|
let balance = 0;
|
|
|
|
|
|
|
|
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];
|
|
|
|
}
|
|
|
|
|
|
|
|
balance = Strings.formatAsFilecoinConversion(selected.balance);
|
|
|
|
}
|
|
|
|
|
2020-09-10 02:52:45 +03:00
|
|
|
return (
|
|
|
|
<ScenePage>
|
2020-09-23 22:46:56 +03:00
|
|
|
<TestnetBanner balance={balance} />
|
|
|
|
<ScenePageHeader title="Filecoin: archiving and logs">
|
2020-09-23 05:35:56 +03:00
|
|
|
Use this section to archive all of your data on to Filecoin through a
|
2020-09-23 22:46:56 +03:00
|
|
|
storage deal. Once you make a storage deal, you can view the logs
|
|
|
|
here.
|
2020-09-10 02:52:45 +03:00
|
|
|
</ScenePageHeader>
|
|
|
|
|
2020-09-09 20:56:35 +03:00
|
|
|
{this.state.networkViewer ? (
|
|
|
|
<React.Fragment>
|
2020-09-23 22:46:56 +03:00
|
|
|
<System.ButtonPrimary
|
|
|
|
onClick={() =>
|
|
|
|
this.props.onAction({
|
|
|
|
type: "SIDEBAR",
|
|
|
|
value: "SIDEBAR_FILECOIN_ARCHIVE",
|
|
|
|
})
|
|
|
|
}
|
|
|
|
>
|
|
|
|
Make storage deal
|
|
|
|
</System.ButtonPrimary>
|
|
|
|
|
2020-09-09 20:56:35 +03:00
|
|
|
<Section
|
2020-09-23 05:35:56 +03:00
|
|
|
title="Trusted miners"
|
|
|
|
style={{ minWidth: "auto", marginTop: 48 }}
|
|
|
|
onAction={this.props.onAction}
|
2020-09-09 20:56:35 +03:00
|
|
|
>
|
|
|
|
<System.Table
|
|
|
|
data={{
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
key: "miner",
|
|
|
|
name: "Miner ID",
|
|
|
|
width: "100%",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
rows: this.state.networkViewer.powerInfo.defaultStorageConfig.cold.filecoin.trustedMinersList.map(
|
|
|
|
(miner) => {
|
|
|
|
return {
|
|
|
|
miner,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
),
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Section>
|
|
|
|
|
|
|
|
<Section
|
2020-09-23 22:46:56 +03:00
|
|
|
title="Archive deal logs"
|
2020-09-23 05:35:56 +03:00
|
|
|
style={{ minWidth: "auto", marginTop: 48 }}
|
2020-09-09 20:56:35 +03:00
|
|
|
>
|
2020-09-23 22:46:56 +03:00
|
|
|
<System.Table
|
|
|
|
data={{
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
key: "job",
|
|
|
|
name: "Job Message",
|
|
|
|
width: "100%",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
rows: this.state.networkViewer.archive.jobs.map((job) => {
|
|
|
|
return {
|
|
|
|
job: job.msg,
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
}}
|
|
|
|
/>
|
2020-09-09 20:56:35 +03:00
|
|
|
</Section>
|
|
|
|
|
2020-09-23 05:35:56 +03:00
|
|
|
<Section
|
2020-09-23 22:46:56 +03:00
|
|
|
title="(one-off) Storage deal logs"
|
2020-09-23 05:35:56 +03:00
|
|
|
style={{ minWidth: "auto", marginTop: 48 }}
|
|
|
|
>
|
2020-09-09 20:56:35 +03:00
|
|
|
<System.Table
|
|
|
|
data={{
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
key: "job",
|
|
|
|
name: "Job Message",
|
|
|
|
width: "100%",
|
|
|
|
},
|
|
|
|
],
|
2020-09-23 22:46:56 +03:00
|
|
|
rows: this.state.networkViewer.dealJobs.map((job) => {
|
2020-09-09 20:56:35 +03:00
|
|
|
return {
|
|
|
|
job: job.msg,
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Section>
|
|
|
|
</React.Fragment>
|
|
|
|
) : (
|
|
|
|
<LoaderSpinner style={{ marginTop: 48, height: 32, width: 32 }} />
|
|
|
|
)}
|
2020-09-10 02:52:45 +03:00
|
|
|
</ScenePage>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|