From 0c55155fa3783f1d6359babe6375fe4d697c456e Mon Sep 17 00:00:00 2001 From: ssy Date: Thu, 26 Feb 2026 21:52:07 +0800 Subject: [PATCH] fix: use derive_safe_wallet instead of derive_proxy_wallet for default proxy derivation The CLI used derive_proxy_wallet (EIP-1167 minimal proxy) to derive the proxy wallet address, but Polymarket deploys Gnosis Safe wallets for browser wallet users. This caused the derived address to not match the actual proxy wallet returned by the profiles API. Changes: - Default signature_type from "proxy" to "gnosis-safe" - Replace all derive_proxy_wallet calls with derive_safe_wallet in wallet.rs and setup.rs - Decouple parse_signature_type from DEFAULT_SIGNATURE_TYPE constant to avoid incorrect mapping after the default change Users can still use --signature-type proxy for Magic Link accounts. Fixes #14 --- src/auth.rs | 2 +- src/commands/setup.rs | 4 ++-- src/commands/wallet.rs | 16 ++++++++-------- src/config.rs | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/auth.rs b/src/auth.rs index 15ad61e..3958b6c 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -13,7 +13,7 @@ pub const RPC_URL: &str = "https://polygon.drpc.org"; fn parse_signature_type(s: &str) -> SignatureType { match s { - config::DEFAULT_SIGNATURE_TYPE => SignatureType::Proxy, + "proxy" => SignatureType::Proxy, "gnosis-safe" => SignatureType::GnosisSafe, _ => SignatureType::Eoa, } diff --git a/src/commands/setup.rs b/src/commands/setup.rs index dd04671..e7268f7 100644 --- a/src/commands/setup.rs +++ b/src/commands/setup.rs @@ -5,7 +5,7 @@ use std::str::FromStr; use anyhow::{Context, Result}; use polymarket_client_sdk::auth::{LocalSigner, Signer as _}; use polymarket_client_sdk::types::Address; -use polymarket_client_sdk::{POLYGON, derive_proxy_wallet}; +use polymarket_client_sdk::{POLYGON, derive_safe_wallet}; use super::wallet::normalize_key; use crate::config; @@ -156,7 +156,7 @@ fn finish_setup(address: Address) -> Result<()> { step_header(2, total, "Proxy Wallet"); - let proxy = derive_proxy_wallet(address, POLYGON); + let proxy = derive_safe_wallet(address, POLYGON); match proxy { Some(proxy) => { println!(" ✓ Proxy wallet derived"); diff --git a/src/commands/wallet.rs b/src/commands/wallet.rs index ce7597f..e80e018 100644 --- a/src/commands/wallet.rs +++ b/src/commands/wallet.rs @@ -5,7 +5,7 @@ use anyhow::{Context, Result, bail}; use clap::{Args, Subcommand}; use polymarket_client_sdk::auth::LocalSigner; use polymarket_client_sdk::auth::Signer as _; -use polymarket_client_sdk::{POLYGON, derive_proxy_wallet}; +use polymarket_client_sdk::{POLYGON, derive_safe_wallet}; use crate::config; use crate::output::OutputFormat; @@ -23,8 +23,8 @@ pub enum WalletCommand { /// Overwrite existing wallet #[arg(long)] force: bool, - /// Signature type: eoa, proxy (default), or gnosis-safe - #[arg(long, default_value = "proxy")] + /// Signature type: eoa, proxy, or gnosis-safe (default) + #[arg(long, default_value = "gnosis-safe")] signature_type: String, }, /// Import an existing private key @@ -34,8 +34,8 @@ pub enum WalletCommand { /// Overwrite existing wallet #[arg(long)] force: bool, - /// Signature type: eoa, proxy (default), or gnosis-safe - #[arg(long, default_value = "proxy")] + /// Signature type: eoa, proxy, or gnosis-safe (default) + #[arg(long, default_value = "gnosis-safe")] signature_type: String, }, /// Show the address of the configured wallet @@ -103,7 +103,7 @@ fn cmd_create(output: &OutputFormat, force: bool, signature_type: &str) -> Resul config::save_wallet(&key_hex, POLYGON, signature_type)?; let config_path = config::config_path()?; - let proxy_addr = derive_proxy_wallet(address, POLYGON); + let proxy_addr = derive_safe_wallet(address, POLYGON); match output { OutputFormat::Json => { @@ -144,7 +144,7 @@ fn cmd_import(key: &str, output: &OutputFormat, force: bool, signature_type: &st config::save_wallet(&normalized, POLYGON, signature_type)?; let config_path = config::config_path()?; - let proxy_addr = derive_proxy_wallet(address, POLYGON); + let proxy_addr = derive_safe_wallet(address, POLYGON); match output { OutputFormat::Json => { @@ -195,7 +195,7 @@ fn cmd_show(output: &OutputFormat, private_key_flag: Option<&str>) -> Result<()> let address = signer.as_ref().map(|s| s.address().to_string()); let proxy_addr = signer .as_ref() - .and_then(|s| derive_proxy_wallet(s.address(), POLYGON)) + .and_then(|s| derive_safe_wallet(s.address(), POLYGON)) .map(|a| a.to_string()); let sig_type = config::resolve_signature_type(None); diff --git a/src/config.rs b/src/config.rs index d2f5395..49b3349 100644 --- a/src/config.rs +++ b/src/config.rs @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize}; const ENV_VAR: &str = "POLYMARKET_PRIVATE_KEY"; const SIG_TYPE_ENV_VAR: &str = "POLYMARKET_SIGNATURE_TYPE"; -pub const DEFAULT_SIGNATURE_TYPE: &str = "proxy"; +pub const DEFAULT_SIGNATURE_TYPE: &str = "gnosis-safe"; pub const NO_WALLET_MSG: &str = "No wallet configured. Run `polymarket wallet create` or `polymarket wallet import `";