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