Skip to content

Docs: ‎Exchange constructor example doesn’t match current type definition #1

@tayelroy

Description

@tayelroy

Hi there

First, thank you for maintaining this project. I’ve been exploring the SDK and noticed a small docs inconsistency that might trip up new users.

Summary

The Exchange class constructor in the type definitions requires a rpcUrls: string[] parameter, but the docs example only shows three arguments and omits this required field.

Current behavior

The TypeScript declaration (from the SDK) is:

export declare class Exchange {
  constructor(
    walletClient: WalletClient,
    root: Address,
    accountId: number,
    rpcUrls: string[],
    agent?: Agent
  );
}

However, the docs show the following usage:

const exchange = new Exchange(
  walletClient,
  '0xYourWalletAddress',
  0 // accountId
);

This compiles incorrectly because the required rpcUrls argument is missing.

Expected behavior

The docs example should match the public API and include the rpcUrls array (and optionally mention the agent parameter), for example:

const exchange = new Exchange(
  walletClient,
  '0xYourWalletAddress',
  0, // accountId
  ['https://mainnet.infura.io/v3/YOUR_KEY'] // rpcUrls
  // optionally: new Agent(...)
);

Alternatively, if rpcUrls is not intended to be required anymore, the type definition could be updated to reflect that.

Why this matters

Having the docs aligned with the actual constructor signature helps new users get started more smoothly and avoids confusion or runtime errors when following the example.

Question

Could you confirm whether:

  • rpcUrls is intended to be required for Exchange, and
  • the docs should be updated to include it (and mention the optional agent parameter), or
  • the type definition should be changed to match the three-argument usage?

Happy to open a PR to adjust the documentation once the intended behavior is confirmed. Thanks again for your work on this project!

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