Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/plugins/ScamWarning/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@masknet/web3-shared-evm": "workspace:^",
"@masknet/web3-shared-solana": "workspace:^",
"@masknet/web3-providers": "workspace:^",
"@scamsniffer/detector": "0.0.39",
"@scamsniffer/detector": "workspace:*",
"react-use": "^17.5.0"
}
}
}
32 changes: 32 additions & 0 deletions packages/plugins/ScamWarning/tests/detector.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { Detector } from '@scamsniffer/detector'

describe('inline ScamSniffer detector', () => {
const detector = new Detector({ onlyBuiltIn: false })

beforeEach(() => {
vi.stubGlobal('fetch', vi.fn())
})

it('checks hosts against the bundled blacklist without fetching', async () => {
await expect(detector.checkUrlInBlacklist('https://usdt-transfer-bnb1.netlify.app/path')).resolves.toBe(true)
await expect(detector.checkUrlInBlacklist('https://sub.usdt-transfer-bnb1.netlify.app/path')).resolves.toBe(
false,
)
expect(fetch).not.toHaveBeenCalled()
})

it('checks addresses case-insensitively against the bundled blacklist', async () => {
await expect(detector.checkAddressInBlacklist('0x7538FD1e30D8e7771105D470Fe8d65B6ab0Da93f')).resolves.toBe(true)
await expect(detector.checkAddressInBlacklist('0x0000000000000000000000000000000000000000')).resolves.toBe(
false,
)
expect(fetch).not.toHaveBeenCalled()
})

it('returns false for URLs without a parseable host', async () => {
await expect(detector.checkUrlInBlacklist('not a URL')).resolves.toBe(false)
await expect(detector.checkUrlInBlacklist('')).resolves.toBe(false)
expect(fetch).not.toHaveBeenCalled()
})
})
8 changes: 8 additions & 0 deletions packages/plugins/ScamWarning/tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "dist"
},
"include": ["detector.test.ts"]
}
71 changes: 0 additions & 71 deletions patches/@scamsniffer__detector.patch

This file was deleted.

3 changes: 3 additions & 0 deletions patches/scamsniffer-detector/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @scamsniffer/detector (forked)

This package is no longer maintained, and brings a lot of outdated dependencies.
Loading
Loading