Skip to content

[Nexus] networkToChainId accepts partially numeric network IDs #8829

Description

@royalpinto007

Summary

networkToChainId currently uses loose numeric parsing for CAIP-style and plain numeric network strings. Because of that, invalid network IDs such as eip155:1abc, eip155:1.5, or 1abc can be parsed as chain ID 1 instead of being rejected.

Why this matters

Nexus uses the parsed chain ID for payment network handling. If a malformed network identifier is partially accepted, a bad request can be routed as a valid chain instead of failing fast with a clear invalid-network error.

Reproduction

networkToChainId("eip155:1abc") // currently returns 1
networkToChainId("1abc") // currently returns 1
networkToChainId("eip155:1.5") // currently returns 1

Expected behavior

Only fully numeric positive safe integer chain IDs should be accepted for eip155:<chainId> and plain numeric network IDs. Partially numeric strings should throw Invalid network: ....

Proposed fix

Use strict chain ID parsing before falling back to named networks, and add unit coverage for malformed numeric inputs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    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