|
|
@ -11,6 +11,7 @@ import { LatestTransactionsTable } from "./LatestTransactionsTable"; |
|
|
|
import { Block } from "src/types"; |
|
|
|
import { Block } from "src/types"; |
|
|
|
import { getBlocks } from "src/api/client"; |
|
|
|
import { getBlocks } from "src/api/client"; |
|
|
|
import { calculateSecondPerBlocks, calculateSecondsPerBlock } from "./helpers"; |
|
|
|
import { calculateSecondPerBlocks, calculateSecondsPerBlock } from "./helpers"; |
|
|
|
|
|
|
|
import { ShardDropdown } from "src/components/ui/ShardDropdown"; |
|
|
|
|
|
|
|
|
|
|
|
const filter = { |
|
|
|
const filter = { |
|
|
|
offset: 0, |
|
|
|
offset: 0, |
|
|
@ -25,6 +26,7 @@ export function MainPage() { |
|
|
|
const history = useHistory(); |
|
|
|
const history = useHistory(); |
|
|
|
const isLessDesktop = useMediaQuery({ maxDeviceWidth: breakpoints.desktop }); |
|
|
|
const isLessDesktop = useMediaQuery({ maxDeviceWidth: breakpoints.desktop }); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const [selectedShard, setSelectedShard] = useState<string>("0"); |
|
|
|
const [blocks, setBlocks] = useState<Block[]>([]); |
|
|
|
const [blocks, setBlocks] = useState<Block[]>([]); |
|
|
|
const [blockLatency, setBlockLatency] = useState<number>(2.01); |
|
|
|
const [blockLatency, setBlockLatency] = useState<number>(2.01); |
|
|
|
|
|
|
|
|
|
|
@ -38,9 +40,11 @@ export function MainPage() { |
|
|
|
const exec = async () => { |
|
|
|
const exec = async () => { |
|
|
|
try { |
|
|
|
try { |
|
|
|
let blocks = await Promise.all( |
|
|
|
let blocks = await Promise.all( |
|
|
|
availableShards.map((shardNumber) => |
|
|
|
selectedShard === "All shards" |
|
|
|
getBlocks([+shardNumber, filter]) |
|
|
|
? availableShards.map((shardNumber) => |
|
|
|
) |
|
|
|
getBlocks([+shardNumber, filter]) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
: [getBlocks([+selectedShard, filter])] |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
const blocksList = blocks.reduce((prev, cur, index) => { |
|
|
|
const blocksList = blocks.reduce((prev, cur, index) => { |
|
|
@ -48,7 +52,10 @@ export function MainPage() { |
|
|
|
...prev, |
|
|
|
...prev, |
|
|
|
...cur.map((item) => ({ |
|
|
|
...cur.map((item) => ({ |
|
|
|
...item, |
|
|
|
...item, |
|
|
|
shardNumber: +availableShards[index], |
|
|
|
shardNumber: |
|
|
|
|
|
|
|
selectedShard === "All shards" |
|
|
|
|
|
|
|
? +availableShards[index] |
|
|
|
|
|
|
|
: +selectedShard, |
|
|
|
})), |
|
|
|
})), |
|
|
|
]; |
|
|
|
]; |
|
|
|
return prev; |
|
|
|
return prev; |
|
|
@ -61,7 +68,7 @@ export function MainPage() { |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
setBlockLatency(calculateSecondPerBlocks(blocks)); |
|
|
|
setBlockLatency(calculateSecondPerBlocks(blocks)); |
|
|
|
setBlockLatencyMap(calculateSecondsPerBlock(blocks)) |
|
|
|
setBlockLatencyMap(calculateSecondsPerBlock(blocks)); |
|
|
|
} catch (err) { |
|
|
|
} catch (err) { |
|
|
|
console.log(err); |
|
|
|
console.log(err); |
|
|
|
} |
|
|
|
} |
|
|
@ -73,7 +80,7 @@ export function MainPage() { |
|
|
|
return () => { |
|
|
|
return () => { |
|
|
|
clearTimeout(tId); |
|
|
|
clearTimeout(tId); |
|
|
|
}; |
|
|
|
}; |
|
|
|
}, []); |
|
|
|
}, [selectedShard]); |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<BaseContainer pad="0"> |
|
|
|
<BaseContainer pad="0"> |
|
|
@ -82,12 +89,22 @@ export function MainPage() { |
|
|
|
<BasePage style={{ flex: "1 1 100%" }}> |
|
|
|
<BasePage style={{ flex: "1 1 100%" }}> |
|
|
|
<Box |
|
|
|
<Box |
|
|
|
border={{ size: "xsmall", side: "bottom" }} |
|
|
|
border={{ size: "xsmall", side: "bottom" }} |
|
|
|
pad={{ bottom: "small" }} |
|
|
|
|
|
|
|
margin={{ bottom: "small" }} |
|
|
|
margin={{ bottom: "small" }} |
|
|
|
|
|
|
|
direction={"row"} |
|
|
|
|
|
|
|
align={"baseline"} |
|
|
|
|
|
|
|
justify={"between"} |
|
|
|
|
|
|
|
style={{ marginTop: "-7px" }} |
|
|
|
> |
|
|
|
> |
|
|
|
<Text size="large" weight="bold"> |
|
|
|
<Text size="large" weight="bold"> |
|
|
|
Latest Blocks |
|
|
|
Latest Blocks |
|
|
|
</Text> |
|
|
|
</Text> |
|
|
|
|
|
|
|
<Box style={{ maxWidth: "120px", minWidth: '120px' }} align={"start"}> |
|
|
|
|
|
|
|
<ShardDropdown |
|
|
|
|
|
|
|
allShardsAvailable={true} |
|
|
|
|
|
|
|
selected={selectedShard} |
|
|
|
|
|
|
|
onClick={(shardNumber) => setSelectedShard(shardNumber)} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
</Box> |
|
|
|
</Box> |
|
|
|
</Box> |
|
|
|
|
|
|
|
|
|
|
|
<LatestBlocksTable blocks={blocks} /> |
|
|
|
<LatestBlocksTable blocks={blocks} /> |
|
|
|