Skip to content

feat: external wallet support for secure CLI trading#36

Open
arein wants to merge 4 commits intoPolymarket:mainfrom
arein:feat/cwp-send-transaction
Open

feat: external wallet support for secure CLI trading#36
arein wants to merge 4 commits intoPolymarket:mainfrom
arein:feat/cwp-send-transaction

Conversation

@arein
Copy link

@arein arein commented Mar 9, 2026

Summary

Enables Polymarket CLI users to trade without exposing their private keys. External wallets (e.g. MetaMask via WalletConnect) can now handle signing and transaction sending through WalletConnect's CLI SDK, so users get the full CLI experience — connect wallet, approve contracts, place orders — without compromising on security.

polymarket.mp4

How it works

flowchart TD
    A[polymarket approve set] --> B{Wallet type?}
    B -->|Local private key| C[alloy Provider]
    C --> D[Sign + send via eth_sendRawTransaction]
    D --> E[alloy .watch await confirms tx]
    B -->|External wallet via CWP| F[Encode calldata via SolCall]
    F --> G[CWP send-transaction]
    G --> H[External wallet signs + sends]
    H --> I[Poll RPC for receipt with timeout]
    E --> J[✓ Approval confirmed]
    I --> J
Loading

Changes

  • src/cwp.rs — Add send-transaction types and methods to CwpSigner
  • src/auth.rs — Add send_and_confirm_cwp_tx helper with 2-minute timeout and on-chain revert detection; update resolve_signer to return PolySigner enum
  • src/commands/approve.rs — Branch approve set on local vs external wallet signer
  • src/commands/wallet.rs — Add wallet connect/disconnect commands for external wallets
  • src/config.rs — Persist external wallet configuration (provider binary, address, signature type)
  • Cargo.toml — Add eip712 alloy feature and async-trait dependency

Test plan

  • cargo build compiles
  • cargo test — all 143 tests pass
  • polymarket approve set with WalletConnect wallet — all 6 approvals (3 USDC + 3 CTF) confirmed on-chain
  • polymarket approve check still works for both wallet types
  • polymarket clob create-order works end-to-end with external wallet — order was signed, posted, and matched
  • Manual test with local private key wallet (verify no regression)

🤖 Generated with Claude Code


Note

Medium Risk
Introduces a new signing/tx-sending path that shells out to external wallet-* binaries and changes how approvals are broadcast and confirmed, which can affect trading flows. Config format changes (new signer type + optional key) may impact existing users if not migrated carefully.

Overview
Enables external wallet signing via a new CwpSigner/PolySigner abstraction, allowing the CLI to authenticate and sign EIP-712 typed data through a CWP provider instead of requiring a local private key.

Adds polymarket wallet connect/disconnect to discover and persist a CWP provider + address, updates config storage to support signer_type with optional private_key, and reworks approve set to either send transactions normally (local key) or ABI-encode calldata and submit via CWP with RPC receipt polling + revert detection (send_and_confirm_cwp_tx).

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

@arein arein changed the title feat: CWP wallet support for approve set feat: external wallet support for secure CLI trading Mar 9, 2026
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

arein and others added 4 commits March 11, 2026 14:37
Add send-transaction support to CwpSigner, enabling WalletConnect
wallets to send on-chain approval transactions. Previously only
local private key wallets could use `approve set`.

- Add CWP send-transaction types and methods (cwp.rs)
- Add send_and_confirm_cwp_tx helper with timeout and revert detection (auth.rs)
- Branch approve set on PolySigner::Local vs PolySigner::Cwp
- Add CWP wallet connect/disconnect commands (wallet.rs)
- Add CWP config persistence (config.rs)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
sign_hash and sign_typed_data were using lowercase hex while
send_transaction used EIP-55 checksummed format. Standardize on
checksummed addresses for all CWP protocol account fields.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Move sleep before receipt check to avoid unnecessary 2s delay on timeout
- Add comment about signed int normalization scope (uint256 only)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@arein arein force-pushed the feat/cwp-send-transaction branch from 2398961 to 304d2ca Compare March 11, 2026 07:38
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