feat: external wallet support for secure CLI trading#36
Open
arein wants to merge 4 commits intoPolymarket:mainfrom
Open
feat: external wallet support for secure CLI trading#36arein wants to merge 4 commits intoPolymarket:mainfrom
arein wants to merge 4 commits intoPolymarket:mainfrom
Conversation
There was a problem hiding this comment.
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.
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>
2398961 to
304d2ca
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 --> JChanges
src/cwp.rs— Addsend-transactiontypes and methods toCwpSignersrc/auth.rs— Addsend_and_confirm_cwp_txhelper with 2-minute timeout and on-chain revert detection; updateresolve_signerto returnPolySignerenumsrc/commands/approve.rs— Branchapprove seton local vs external wallet signersrc/commands/wallet.rs— Add wallet connect/disconnect commands for external walletssrc/config.rs— Persist external wallet configuration (provider binary, address, signature type)Cargo.toml— Addeip712alloy feature andasync-traitdependencyTest plan
cargo buildcompilescargo test— all 143 tests passpolymarket approve setwith WalletConnect wallet — all 6 approvals (3 USDC + 3 CTF) confirmed on-chainpolymarket approve checkstill works for both wallet typespolymarket clob create-orderworks end-to-end with external wallet — order was signed, posted, and matched🤖 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/PolySignerabstraction, 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/disconnectto discover and persist a CWP provider + address, updates config storage to supportsigner_typewith optionalprivate_key, and reworksapprove setto 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.