Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(Blockaid): pass chain id instead of chain name for Blast and others #4800

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
24 changes: 3 additions & 21 deletions apps/web/src/services/security/modules/BlockaidModule/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,10 @@ import type { EIP712TypedData } from '@safe-global/safe-gateway-typescript-sdk'
import { type SecurityResponse, type SecurityModule, SecuritySeverity } from '../types'
import type { AssetDiff, TransactionScanResponse } from './types'
import { BLOCKAID_API, BLOCKAID_CLIENT_ID } from '@/config/constants'
import { numberToHex } from '@/utils/hex'

/** @see https://docs.blockaid.io/docs/supported-chains */
const API_CHAINS: Record<string, string> = {
1: 'ethereum',
10: 'optimism',
56: 'bsc',
100: 'gnosis',
137: 'polygon',
238: 'blast',
324: 'zksync',
8453: 'base',
42161: 'arbitrum',
43114: 'avalanche',
59144: 'linea',
534352: 'scroll',
7777777: 'zora',
}

const blockaidSeverityMap: Record<string, SecuritySeverity> = {
Malicious: SecuritySeverity.HIGH,
Warning: SecuritySeverity.MEDIUM,
Expand Down Expand Up @@ -91,15 +78,10 @@ export class BlockaidModule implements SecurityModule<BlockaidModuleRequest, Blo
}

const { chainId, safeAddress } = request

if (!API_CHAINS[chainId]) {
throw new Error('Security checks are not available on the current chain.')
}

const message = BlockaidModule.prepareMessage(request)

const payload: BlockaidPayload = {
chain: API_CHAINS[chainId],
chain: numberToHex(chainId),
account_address: safeAddress,
data: {
method: 'eth_signTypedData_v4',
Expand Down
Loading