Skip to content

Issue Type: Bug / Code Correctness #519

@chymak0vadina

Description

@chymak0vadina

Issue Type: Bug / Code Correctness

Title: Fix missing error handling for unsupported network parameter in CdpClient.evm.sendTransaction

Description:
In the TypeScript CDP SDK (@coinbase/cdp-sdk), calling cdp.evm.sendTransaction({ …, network }) with an unsupported or mistyped network string (e.g., "ethereum" instead of "base-sepolia" or "base") currently results in a generic error or failed RPC call without a clear SDK-level validation. This can lead to cryptic errors during runtime and make it hard for developers to diagnose issues related to network configuration. :contentReference[oaicite:0]{index=0}

Expected behavior:

  • If an unsupported or invalid network string is passed into cdp.evm.sendTransaction (or related EVM methods), the SDK should validate the network parameter early.
  • The method should throw a clear and descriptive error (e.g., Unsupported network: ${network}) before attempting any RPC or API call.
  • The error message should list valid supported networks for quick reference.

Proposed solution:

  • Add validation logic in the core EVM client wrapper before making API or RPC calls.
  • Use a centralized list of supported networks (e.g., from the SDK’s configuration or a const enum).
  • Update types so that network ideally accepts only a union of valid network identifiers where possible.
  • Add unit tests verifying that invalid network values throw with clear messages.

Acceptance criteria:

  • Passing an invalid network to sendTransaction, requestFaucet, createAccount, etc., throws a descriptive SDK error.
  • Tests are added to cover incorrect network parameter usage.
  • No breaking behavior for existing valid network calls.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions