explorer: add fetch polyfill and clean up / message change (#15505)

This commit is contained in:
Josh
2021-02-23 21:27:35 -08:00
committed by GitHub
parent b8f1ffb483
commit a07fa5b623
4 changed files with 21 additions and 11 deletions

View File

@@ -162,8 +162,8 @@ function DetailsSections({ pubkey, tab }: { pubkey: PublicKey; tab?: string }) {
<>
{flaggedAccounts.has(address) && (
<div className="alert alert-danger alert-scam" role="alert">
Warning! This account has been flagged as a scam account. Please be
cautious sending SOL to this account.
Warning! This account has been flagged by the community as a scam
account. Please be cautious sending SOL to this account.
</div>
)}
{<InfoSection account={account} />}

View File

@@ -1,20 +1,21 @@
import React from "react";
import { fetch } from "cross-fetch";
const initialState = new Map();
const FlaggedContext = React.createContext<Map<string, boolean>>(initialState);
const FLAGGED_REGISTRY =
"https://solana-labs.github.io/solana-flagged-accounts/flagged.txt";
type FlaggedMap = Map<string, boolean>;
type ProviderProps = { children: React.ReactNode };
const FlaggedContext = React.createContext<FlaggedMap>(new Map());
export function FlaggedAccountsProvider({ children }: ProviderProps) {
const [flaggedAccounts, setFlaggedAccounts] = React.useState<
Map<string, boolean>
>(initialState);
const [flaggedAccounts, setFlaggedAccounts] = React.useState<FlaggedMap>(
new Map()
);
React.useEffect(() => {
window
.fetch(
"https://solana-labs.github.io/solana-flagged-accounts/flagged.txt"
)
fetch(FLAGGED_REGISTRY)
.then((res) => {
return res.text();
})