Skip to content

Commit

Permalink
feat: add blocklist for NFT scam detection (#2331)
Browse files Browse the repository at this point in the history
Co-authored-by: Nicole O'Brien <[email protected]>
  • Loading branch information
jeeanribeiro and nicole-obrien authored Apr 17, 2024
1 parent 73fb9fe commit 2212d33
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 4 deletions.
11 changes: 11 additions & 0 deletions packages/desktop/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
import { _ } from '@core/i18n'
import { getAndUpdateShimmerEvmTokensMetadata } from '@core/market/actions'
import { initializeWalletConnect } from '@auxiliary/wallet-connect/actions'
import { NFT_BLOCKLIST_JSON_URL } from '@core/utils/constants/nft-blocklist-json-url.constant'
import { nftBlocklist } from '@core/utils/stores/nft-blocklist.store'
import nftBlockListJson from '@core/utils/json/nft-blocklist.json'
$: $activeProfile, saveActiveProfile()
Expand Down Expand Up @@ -107,6 +110,14 @@
registerMenuButtons()
void initializeWalletConnect()
await getAndUpdateShimmerEvmTokensMetadata()
try {
const response = await fetch(NFT_BLOCKLIST_JSON_URL)
const blocklist = await response.json()
nftBlocklist.set(blocklist)
} catch (error) {
nftBlocklist.set(nftBlockListJson)
}
})
onDestroy(() => {
Expand Down
10 changes: 6 additions & 4 deletions packages/shared/src/lib/core/nfts/utils/isScamIrc27Nft.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { IIrc27Metadata } from '../interfaces'
import { nftBlocklist } from '@core/utils/stores/nft-blocklist.store'
import { get } from 'svelte/store'

export function isScamIrc27Nft(metadata: IIrc27Metadata): boolean {
const SCAM_URLS = ['iotalottery.com', 'iota-lottery.com', 'lottery-iota.com', 'fly-fire.com']
const SCAM_PHRASES = ['lottery', 'lotto', 'raffle', 'giveaway', 'scam', 'won']
const { urls, keywords } = get(nftBlocklist)

if (
SCAM_URLS.some(
urls.some(
(url) =>
metadata?.uri?.toLocaleLowerCase()?.includes(url) ||
metadata?.name?.toLocaleLowerCase()?.includes(url) ||
Expand All @@ -15,7 +17,7 @@ export function isScamIrc27Nft(metadata: IIrc27Metadata): boolean {
) {
return true
} else if (
SCAM_PHRASES.some(
keywords.some(
(phrase) =>
metadata?.name?.toLocaleLowerCase()?.includes(phrase) ||
metadata?.issuerName?.toLocaleLowerCase()?.includes(phrase) ||
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const NFT_BLOCKLIST_JSON_URL =
'https://raw.githubusercontent.com/bloomwalletio/bloom/develop/packages/shared/src/lib/core/utils/json/nft-blocklist.json'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface NftBlocklist {
urls: string[]
keywords: string[]
}
4 changes: 4 additions & 0 deletions packages/shared/src/lib/core/utils/json/nft-blocklist.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"keywords": ["lottery", "lotto", "raffle", "giveaway", "scam", "won"],
"urls": ["iotalottery.com", "iota-lottery.com", "lottery-iota.com", "fly-fire.com"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { writable } from 'svelte/store'
import { NftBlocklist } from '../interfaces/nft-blocklist.interface'

export const nftBlocklist = writable<NftBlocklist>({ urls: [], keywords: [] })

0 comments on commit 2212d33

Please sign in to comment.