Skip to content

fix(sdk): getChainConfig fails for chains where mapping key differs from viem name #1026

@nud3l

Description

@nud3l

Bug

getChainConfig("bsc") throws Chain id for "bsc" not found because getChainIdByName only searches by chain.name.toLowerCase(), not by the mapping key in supportedChainsMapping.

The mapping key is bsc but the viem chain name is BNB Smart Chain. Six chains are affected:

Key Viem Name
bsc BNB Smart Chain
bera Berachain
sei Sei Network
soneium Soneium Mainnet
optimism OP Mainnet
arbitrum Arbitrum One

This breaks any SDK consumer that uses the gateway API chain names (which return the mapping keys like bsc, not viem names like BNB Smart Chain).

Fix

Updated getChainIdByName in src/gateway/utils/common.ts to check both the mapping key and chain.name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions