Merge branch 'feature/remove-testnet-locks' into develop

This commit is contained in:
Willian Mitsuda 2021-07-25 18:46:17 -03:00
commit b1e30b2d93
6 changed files with 48 additions and 9 deletions

View File

@ -1,5 +1,6 @@
import React, { Suspense } from "react"; import React, { Suspense } from "react";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom"; import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
import WarningHeader from "./WarningHeader";
import Home from "./Home"; import Home from "./Home";
import Search from "./Search"; import Search from "./Search";
import Title from "./Title"; import Title from "./Title";
@ -26,6 +27,7 @@ const App = () => {
) : ( ) : (
<RuntimeContext.Provider value={runtime}> <RuntimeContext.Provider value={runtime}>
<div className="h-screen flex flex-col"> <div className="h-screen flex flex-col">
<WarningHeader />
<Router> <Router>
<Switch> <Switch>
<Route path="/" exact> <Route path="/" exact>

View File

@ -67,8 +67,12 @@ const Block: React.FC = () => {
const _block = provider.formatter.block(_rawBlock); const _block = provider.formatter.block(_rawBlock);
const extBlock: ExtendedBlock = { const extBlock: ExtendedBlock = {
blockReward: provider.formatter.bigNumber(_rawIssuance.blockReward), blockReward: provider.formatter.bigNumber(
unclesReward: provider.formatter.bigNumber(_rawIssuance.uncleReward), _rawIssuance.blockReward ?? 0
),
unclesReward: provider.formatter.bigNumber(
_rawIssuance.uncleReward ?? 0
),
feeReward: fees, feeReward: fees,
size: provider.formatter.number(_rawBlock.size), size: provider.formatter.number(_rawBlock.size),
sha3Uncles: _rawBlock.sha3Uncles, sha3Uncles: _rawBlock.sha3Uncles,

View File

@ -5,7 +5,13 @@ const Footer: React.FC = () => {
const { provider } = useContext(RuntimeContext); const { provider } = useContext(RuntimeContext);
return ( return (
<div className="w-full px-2 py-1 border-t border-t-gray-100 text-xs bg-link-blue text-gray-200 text-center"> <div
className={`w-full px-2 py-1 border-t border-t-gray-100 text-xs ${
provider?.network.chainId === 1
? "bg-link-blue text-gray-200"
: "bg-orange-400 text-white"
} text-center`}
>
{provider ? ( {provider ? (
<>Using Erigon node at {provider.connection.url}</> <>Using Erigon node at {provider.connection.url}</>
) : ( ) : (

View File

@ -1,9 +1,11 @@
import React, { useState, useRef } from "react"; import React, { useState, useRef, useContext } from "react";
import { Link, useHistory } from "react-router-dom"; import { Link, useHistory } from "react-router-dom";
import useKeyboardShortcut from "use-keyboard-shortcut"; import useKeyboardShortcut from "use-keyboard-shortcut";
import PriceBox from "./PriceBox"; import PriceBox from "./PriceBox";
import { RuntimeContext } from "./useRuntime";
const Title: React.FC = () => { const Title: React.FC = () => {
const { provider } = useContext(RuntimeContext);
const [search, setSearch] = useState<string>(); const [search, setSearch] = useState<string>();
const [canSubmit, setCanSubmit] = useState<boolean>(false); const [canSubmit, setCanSubmit] = useState<boolean>(false);
const history = useHistory(); const history = useHistory();
@ -43,7 +45,7 @@ const Title: React.FC = () => {
</div> </div>
</Link> </Link>
<div className="flex items-baseline space-x-3"> <div className="flex items-baseline space-x-3">
<PriceBox /> {provider?.network.chainId === 1 && <PriceBox />}
<form <form
className="flex" className="flex"
onSubmit={handleSubmit} onSubmit={handleSubmit}

28
src/WarningHeader.tsx Normal file
View File

@ -0,0 +1,28 @@
import React, { useContext } from "react";
import { RuntimeContext } from "./useRuntime";
const WarningHeader: React.FC = () => {
const { provider } = useContext(RuntimeContext);
const chainId = provider?.network.chainId;
if (chainId === 1) {
return <></>;
}
let chainMsg = `ChainID: ${chainId}`;
if (chainId === 3) {
chainMsg = "Ropsten Testnet";
} else if (chainId === 4) {
chainMsg = "Rinkeby Testnet";
} else if (chainId === 5) {
chainMsg = "Görli Testnet";
} else if (chainId === 42) {
chainMsg = "Kovan Testnet";
}
return (
<div className="w-full bg-orange-400 text-white text-center font-bold px-2 py-1">
You are on {chainMsg}
</div>
);
};
export default React.memo(WarningHeader);

View File

@ -33,10 +33,7 @@ export const useProvider = (
setConnStatus(ConnectionStatus.CONNECTING); setConnStatus(ConnectionStatus.CONNECTING);
const tryToConnect = async () => { const tryToConnect = async () => {
const provider = new ethers.providers.JsonRpcProvider( const provider = new ethers.providers.JsonRpcProvider(erigonURL);
erigonURL,
"mainnet"
);
// Check if it is at least a regular ETH node // Check if it is at least a regular ETH node
let blockNumber: number = 0; let blockNumber: number = 0;