Skip to content

Add WalletClient support to ExchangeOrderBuilder#20

Closed
carlos-poly wants to merge 1 commit intocarlos/02-26-switch_to_pnpmfrom
carlos/02-26-add_walletclient_support_to_exchangeorderbuilder
Closed

Add WalletClient support to ExchangeOrderBuilder#20
carlos-poly wants to merge 1 commit intocarlos/02-26-switch_to_pnpmfrom
carlos/02-26-add_walletclient_support_to_exchangeorderbuilder

Conversation

@carlos-poly
Copy link
Copy Markdown

@carlos-poly carlos-poly commented Feb 26, 2026

Summary

This PR adds viem WalletClient support to ExchangeOrderBuilder while preserving compatibility with existing ethers signers (Wallet | JsonRpcSigner).

What changed

  • Refactored signer handling in ExchangeOrderBuilder to use a local minimal signer abstraction.
  • Expanded constructor signer input to:
    • Wallet | JsonRpcSigner | WalletClient
  • Replaced direct signer calls with adapter behavior:
    • Address resolution: account.address for WalletClient
    • Typed data signing: walletClient.signTypedData(...) for WalletClient
  • Preserved existing ethers behavior:
    • getAddress()
    • _signTypedData(...)
  • Added fail-fast validation for viem clients without a hoisted account:
    • throws walletClient.account is required
  • Added WalletClient tests:
    • successful order build using account.address
    • deterministic typed-data signature path
    • missing-account error path
  • Bumped package version in package.json:
    • 3.1.03.2.0

Why

Consumers can now use viem wallet clients directly without wrapping them in ethers-compatible signers.

Backward compatibility

  • No breaking API change to constructor shape/order.
  • Existing ethers-based integrations continue to work unchanged.

Validation

  • pnpm test passes
  • pnpm build passes

Note

Medium Risk
Touches order signing/address validation logic; while behavior is intended to be backwards-compatible, adapter detection and typed-data signing differences could break integrations if signer objects don’t match expected shapes.

Overview
Adds viem WalletClient support to ExchangeOrderBuilder. The constructor now accepts Wallet | JsonRpcSigner | WalletClient and routes address resolution and EIP-712 signing through a minimal IExchangeSigner adapter (including a fail-fast error when walletClient.account is missing).

Updates tests and release version. Adds a new test suite covering WalletClient order building, deterministic typed-data signatures, and the missing-account error case, and bumps package.json from 3.1.0 to 3.2.0.

Written by Cursor Bugbot for commit 136452e. This will update automatically on new commits. Configure here.

Copy link
Copy Markdown
Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@carlos-poly carlos-poly marked this pull request as ready for review February 26, 2026 18:38
@carlos-poly carlos-poly requested a review from a team as a code owner February 26, 2026 18:38
@carlos-poly carlos-poly force-pushed the carlos/02-26-add_walletclient_support_to_exchangeorderbuilder branch from 55c535c to c80569a Compare February 26, 2026 18:40
@carlos-poly carlos-poly changed the title Add WalletClient support to ExchangeOrderBuilder Add WalletClient support to ExchangeOrderBuilder Feb 26, 2026
@carlos-poly carlos-poly force-pushed the carlos/02-26-switch_to_pnpm branch from beb7ce5 to 5fcb9a7 Compare February 26, 2026 18:45
@carlos-poly carlos-poly force-pushed the carlos/02-26-add_walletclient_support_to_exchangeorderbuilder branch from c80569a to 136452e Compare February 26, 2026 18:45
@carlos-poly
Copy link
Copy Markdown
Author

Tackled in Polymarket/clob-client#313

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant