Skip to content

Magic numbers: Hardcoded blockchain chain IDs #251

@realfishsam

Description

@realfishsam

Category

Blockchain Chain IDs

Locations

Inline integer literals (no named constant):

  • core/src/exchanges/limitless/index.ts:552chainId: 8453 (Base mainnet)
  • core/src/exchanges/limitless/client.ts:205chainId: 8453 (Base mainnet)
  • core/src/exchanges/limitless/client.ts:383chainId: 8453 (Base mainnet)
  • core/src/exchanges/polymarket/index.ts:675chainId: 137 (Polygon mainnet)
  • core/src/exchanges/probable/auth.ts:61chainId: 56 (BSC mainnet)

Already using named constants (correct pattern):

  • core/src/exchanges/hyperliquid/config.ts:17export const EXCHANGE_CHAIN_ID = 1337
  • core/src/exchanges/myriad/utils.ts:8-9ABSTRACT: 2741, LINEA: 59144 in a NETWORKS map

Inconsistencies

  • Limitless repeats 8453 three times across two files. A testnet migration or chain upgrade requires 3 independent edits.
  • Hyperliquid and Myriad use named constants; Limitless, Polymarket, and Probable do not — no consistent pattern.
  • Chain ID 56 (BSC) in probable/auth.ts is particularly opaque: there is no PROBABLE_CHAIN_ID constant or comment naming the network.

Risk

Chain IDs are critical for transaction signing. An inline 8453 copy-pasted to a test file could silently sign transactions for the wrong network. No grep for "Base mainnet" will find 8453 without knowing to look.

Suggested Fix

Follow the Hyperliquid/Myriad pattern and define named constants per exchange:

// core/src/exchanges/limitless/config.ts
export const LIMITLESS_CHAIN_ID = 8453; // Base mainnet

// core/src/exchanges/polymarket/config.ts
export const POLYMARKET_CHAIN_ID = 137; // Polygon mainnet

// core/src/exchanges/probable/config.ts
export const PROBABLE_CHAIN_ID = 56; // BSC mainnet

Found by automated magic numbers audit

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions