otterscan/src/special/london/London.tsx

32 lines
861 B
TypeScript
Raw Normal View History

2021-07-29 04:24:39 +00:00
import React, { useContext } from "react";
2021-07-30 07:41:29 +00:00
import { useLatestBlock } from "../../useLatestBlock";
import { RuntimeContext } from "../../useRuntime";
2021-07-29 04:24:39 +00:00
import Countdown from "./Countdown";
import Blocks from "./Blocks";
2021-07-30 07:55:21 +00:00
import { londonBlockNumber } from "./params";
2021-07-29 04:24:39 +00:00
const London: React.FC = () => {
const { provider } = useContext(RuntimeContext);
const block = useLatestBlock(provider);
if (!provider || !block) {
2021-07-29 04:24:39 +00:00
return <></>;
}
// Display countdown
const targetBlockNumber =
londonBlockNumber[provider.network.chainId.toString()];
if (block.number < targetBlockNumber) {
2021-07-29 04:24:39 +00:00
return (
<Countdown
provider={provider}
currentBlock={block}
targetBlock={targetBlockNumber}
2021-07-29 04:24:39 +00:00
/>
);
}
2021-07-30 07:55:21 +00:00
return <Blocks latestBlock={block} targetBlockNumber={targetBlockNumber} />;
2021-07-29 04:24:39 +00:00
};
export default React.memo(London);