Only enable faucets on chains explicitly flagged as network === testnet
This commit is contained in:
parent
d29b3fdfb3
commit
d198a5c5b2
|
@ -88,7 +88,7 @@ const Address: React.FC = () => {
|
|||
? metadatas[checksummedAddress]
|
||||
: undefined;
|
||||
|
||||
const { faucets } = useChainInfo();
|
||||
const { network, faucets } = useChainInfo();
|
||||
|
||||
// Search address by nonce === transaction @ nonce
|
||||
const rawNonce = searchParams.get("nonce");
|
||||
|
@ -124,7 +124,7 @@ const Address: React.FC = () => {
|
|||
</span>
|
||||
<Copy value={checksummedAddress} rounded />
|
||||
{/* Only display faucets for testnets who actually have any */}
|
||||
{faucets && faucets.length > 0 && (
|
||||
{network === "testnet" && faucets && faucets.length > 0 && (
|
||||
<Faucet address={checksummedAddress} rounded />
|
||||
)}
|
||||
{isENS && (
|
||||
|
|
|
@ -8,17 +8,21 @@ import ContentFrame from "./ContentFrame";
|
|||
import StandardFrame from "./StandardFrame";
|
||||
import StandardSubtitle from "./StandardSubtitle";
|
||||
import { useChainInfo } from "./useChainInfo";
|
||||
|
||||
const Faucets: React.FC = () => {
|
||||
const { faucets } = useChainInfo();
|
||||
const { network, faucets } = useChainInfo();
|
||||
const loc = useLocation();
|
||||
const urls = useMemo(() => {
|
||||
const s = new URLSearchParams(loc.search);
|
||||
const address = s.get("address");
|
||||
|
||||
const _urls = faucets.map((u) =>
|
||||
const _urls: string[] =
|
||||
network === "testnet"
|
||||
? faucets.map((u) =>
|
||||
// eslint-disable-next-line no-template-curly-in-string
|
||||
address !== null ? u.replaceAll("${ADDRESS}", address) : u
|
||||
);
|
||||
)
|
||||
: [];
|
||||
|
||||
// Shuffle faucets to avoid UI bias
|
||||
for (let i = _urls.length - 1; i > 0; i--) {
|
||||
|
@ -27,7 +31,7 @@ const Faucets: React.FC = () => {
|
|||
}
|
||||
|
||||
return _urls;
|
||||
}, [faucets, loc]);
|
||||
}, [network, faucets, loc]);
|
||||
|
||||
return (
|
||||
<StandardFrame>
|
||||
|
|
|
@ -3,6 +3,7 @@ import { chainInfoURL } from "./url";
|
|||
import { OtterscanRuntime } from "./useRuntime";
|
||||
|
||||
export type ChainInfo = {
|
||||
network: string | undefined;
|
||||
faucets: string[];
|
||||
nativeCurrency: {
|
||||
name: string;
|
||||
|
@ -12,6 +13,7 @@ export type ChainInfo = {
|
|||
};
|
||||
|
||||
export const defaultChainInfo: ChainInfo = {
|
||||
network: undefined,
|
||||
faucets: [],
|
||||
nativeCurrency: {
|
||||
name: "Ether",
|
||||
|
|
Loading…
Reference in New Issue