slate/scenes/SceneMiners.js

93 lines
2.4 KiB
JavaScript
Raw Normal View History

import * as React from "react";
import * as Strings from "~/common/strings";
import * as Constants from "~/common/constants";
import * as System from "~/components/system";
import { css } from "@emotion/react";
import Section from "~/components/core/Section";
import ScenePage from "~/components/core/ScenePage";
2020-09-27 19:38:20 +03:00
import ScenePageHeader from "~/components/core/ScenePageHeader";
let mounted = false;
export default class SceneMiners extends React.Component {
2020-09-27 19:38:20 +03:00
state = { miners: [] };
async componentDidMount() {
if (mounted) {
return null;
}
mounted = true;
let miners = [];
try {
2020-10-19 02:48:22 +03:00
const response = await fetch("https://sentinel.slate.host/api/mapped-static-global-miners");
2020-09-27 19:38:20 +03:00
const json = await response.json();
2020-10-19 02:48:22 +03:00
const sources = json.data;
2020-09-27 19:38:20 +03:00
sources.forEach((group) => {
miners = [...group.minerAddresses, ...miners];
2020-09-27 19:38:20 +03:00
});
} catch (e) {}
this.setState({ miners });
}
componentWillUnmount() {
mounted = false;
}
render() {
return (
<ScenePage>
2020-10-19 02:48:22 +03:00
<ScenePageHeader title="Miners">
Whenever you make a deal against the Filecoin Network, Slate works with Textile's
infrastructure to find the best possible miner to make a storage deal with.
2020-09-27 19:38:20 +03:00
</ScenePageHeader>
2020-10-19 02:48:22 +03:00
<Section title="Listing" style={{ maxWidth: 960, minWidth: "auto" }}>
<System.Table
data={{
columns: [
{
key: "id",
2020-09-27 19:38:20 +03:00
name: "Miner",
2020-10-19 02:48:22 +03:00
width: "96px",
},
{
key: "minPieceSizeFormatted",
name: "Minimum size",
width: "124px",
},
{
key: "minDealDuration",
name: "Minimum duration",
width: "140px",
},
{
2020-09-27 19:38:20 +03:00
key: "location",
name: "Location",
width: "188px",
},
2020-10-19 02:48:22 +03:00
{
key: "priceFIL",
name: "Price",
width: "100%",
},
],
rows: this.state.miners.map((each) => {
return {
...each,
...each.storageAsk,
};
}),
}}
/>
</Section>
</ScenePage>
);
}
}