diff --git a/explorer/package-lock.json b/explorer/package-lock.json index bb11a4bedc..4d9a51baed 100644 --- a/explorer/package-lock.json +++ b/explorer/package-lock.json @@ -5790,6 +5790,14 @@ "sha.js": "^2.4.8" } }, + "cross-fetch": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.0.6.tgz", + "integrity": "sha512-KBPUbqgFjzWlVcURG+Svp9TlhA5uliYtiNx/0r8nv0pdypeQCRJ9IaSIc3q/x3q8t3F75cHuwxVql1HFGHCNJQ==", + "requires": { + "node-fetch": "2.6.1" + } + }, "cross-spawn": { "version": "6.0.5", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", diff --git a/explorer/package.json b/explorer/package.json index 6b05d92257..77e45c5892 100644 --- a/explorer/package.json +++ b/explorer/package.json @@ -29,6 +29,7 @@ "chai": "^4.3.0", "chart.js": "^2.9.4", "classnames": "2.2.6", + "cross-fetch": "^3.0.6", "humanize-duration-ts": "^2.1.1", "node-sass": "^4.14.1", "prettier": "^2.2.1", diff --git a/explorer/src/pages/AccountDetailsPage.tsx b/explorer/src/pages/AccountDetailsPage.tsx index d21dc312d9..2300012a3b 100644 --- a/explorer/src/pages/AccountDetailsPage.tsx +++ b/explorer/src/pages/AccountDetailsPage.tsx @@ -162,8 +162,8 @@ function DetailsSections({ pubkey, tab }: { pubkey: PublicKey; tab?: string }) { <> {flaggedAccounts.has(address) && (
- 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.
)} {} diff --git a/explorer/src/providers/accounts/flagged-accounts.tsx b/explorer/src/providers/accounts/flagged-accounts.tsx index bd62a93f7f..ff8ca6fa66 100644 --- a/explorer/src/providers/accounts/flagged-accounts.tsx +++ b/explorer/src/providers/accounts/flagged-accounts.tsx @@ -1,20 +1,21 @@ import React from "react"; +import { fetch } from "cross-fetch"; -const initialState = new Map(); -const FlaggedContext = React.createContext>(initialState); +const FLAGGED_REGISTRY = + "https://solana-labs.github.io/solana-flagged-accounts/flagged.txt"; +type FlaggedMap = Map; type ProviderProps = { children: React.ReactNode }; +const FlaggedContext = React.createContext(new Map()); + export function FlaggedAccountsProvider({ children }: ProviderProps) { - const [flaggedAccounts, setFlaggedAccounts] = React.useState< - Map - >(initialState); + const [flaggedAccounts, setFlaggedAccounts] = React.useState( + new Map() + ); React.useEffect(() => { - window - .fetch( - "https://solana-labs.github.io/solana-flagged-accounts/flagged.txt" - ) + fetch(FLAGGED_REGISTRY) .then((res) => { return res.text(); })