otterscan/src/special/london/London.tsx

38 lines
906 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-29 04:24:39 +00:00
const londonBlockNumber: { [chainId: string]: number } = {
"1": 12965000,
"3": 10499401,
"4": 8897988,
"5": 5062605,
};
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
/>
);
}
return <Blocks latestBlock={block} />;
2021-07-29 04:24:39 +00:00
};
export default React.memo(London);