From 577310380a752a09f056f555663485f1e48dc451 Mon Sep 17 00:00:00 2001 From: Josh Date: Wed, 27 Jan 2021 13:50:02 -0800 Subject: [PATCH] explorer: Introduce scam registry and flag on account pages (#14886) * explorer: add spam registry * explorer: adjust warning messaging * fix: remove red borders * explorer: change spam to scam * explorer: no need for this to be a prop now --- explorer/src/pages/AccountDetailsPage.tsx | 8 ++++++++ explorer/src/scamRegistry.ts | 12 ++++++++++++ explorer/src/scss/_solana.scss | 5 +++++ 3 files changed, 25 insertions(+) create mode 100644 explorer/src/scamRegistry.ts diff --git a/explorer/src/pages/AccountDetailsPage.tsx b/explorer/src/pages/AccountDetailsPage.tsx index 23aff1cb51..79f34c1c10 100644 --- a/explorer/src/pages/AccountDetailsPage.tsx +++ b/explorer/src/pages/AccountDetailsPage.tsx @@ -28,6 +28,7 @@ import { SlotHashesCard } from "components/account/SlotHashesCard"; import { StakeHistoryCard } from "components/account/StakeHistoryCard"; import { BlockhashesCard } from "components/account/BlockhashesCard"; import { ConfigAccountSection } from "components/account/ConfigAccountSection"; +import { isScamAccount } from "scamRegistry"; const TABS_LOOKUP: { [id: string]: Tab } = { "spl-token:mint": { @@ -129,6 +130,7 @@ function DetailsSections({ pubkey, tab }: { pubkey: PublicKey; tab?: string }) { const info = useAccountInfo(address); const { status } = useCluster(); const location = useLocation(); + const isScam = isScamAccount(address); // Fetch account on load React.useEffect(() => { @@ -157,6 +159,12 @@ function DetailsSections({ pubkey, tab }: { pubkey: PublicKey; tab?: string }) { return ( <> + {isScam && ( +
+ Warning! This account has been flagged as a scam account. Please be + cautious sending SOL to this account. +
+ )} {} {} diff --git a/explorer/src/scamRegistry.ts b/explorer/src/scamRegistry.ts new file mode 100644 index 0000000000..413ccb30da --- /dev/null +++ b/explorer/src/scamRegistry.ts @@ -0,0 +1,12 @@ +const scamAddresses = toHash(["GACpXND1SSfTSQMmqGuFvGwXB3jGEYBDRGNzmLfTYwSP"]); + +export function isScamAccount(address: string) { + return address in scamAddresses; +} + +function toHash(addresses: string[]) { + return addresses.reduce((prev: { [addr: string]: boolean }, addr) => { + prev[addr] = true; + return prev; + }, {}); +} diff --git a/explorer/src/scss/_solana.scss b/explorer/src/scss/_solana.scss index f70f0c5a15..ee321d252a 100644 --- a/explorer/src/scss/_solana.scss +++ b/explorer/src/scss/_solana.scss @@ -326,3 +326,8 @@ div.inner-cards { max-height: 20rem; overflow-y: auto; } + +.alert-danger.alert-scam { + background: red; + border: 1px solid red; +}