fix: use derive_safe_wallet instead of derive_proxy_wallet for default proxy derivation#22
Open
pck101001 wants to merge 3 commits intoPolymarket:mainfrom
Open
fix: use derive_safe_wallet instead of derive_proxy_wallet for default proxy derivation#22pck101001 wants to merge 3 commits intoPolymarket:mainfrom
pck101001 wants to merge 3 commits intoPolymarket:mainfrom
Conversation
…t 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 Polymarket#14
The previous commit unconditionally used derive_safe_wallet() for all signature types. When a user specifies --signature-type proxy, the CLI would incorrectly display a Gnosis Safe address instead of the EIP-1167 proxy address. Add derive_wallet_for_type() helper that dispatches to the correct derivation function based on signature_type: - "proxy" → derive_proxy_wallet() (EIP-1167) - "gnosis-safe" → derive_safe_wallet() (Gnosis Safe) - "eoa" / other → None Apply this to wallet create, import, show, and setup finish_setup().
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.
Move derive_wallet_for_type() to pub(crate) in wallet.rs and reuse it in setup.rs instead of duplicating the signature_type match inline.
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
derive_proxy_wallet(EIP-1167) withderive_safe_wallet(Gnosis Safe) as the default proxy wallet derivationDEFAULT_SIGNATURE_TYPEfrom"proxy"to"gnosis-safe"--signature-type proxyfor Magic Link accountsProblem
The CLI derives the proxy wallet address using
derive_proxy_wallet()(EIP-1167 minimal proxy, factory0xaB45...), but Polymarket deploys Gnosis Safe wallets (factory0xaacF...) for browser wallet users. The two derivation methods use different salt encoding, factory addresses, and init code hashes, producing completely different addresses for the same EOA.This causes:
wallet showdisplaying the wrong proxy addressclob balancereturning 0 (querying wrong address)approve setapproving the wrong addresssetupwizard directing users to deposit to the wrong addressChanges
src/config.rsDEFAULT_SIGNATURE_TYPE:"proxy"→"gnosis-safe"src/commands/wallet.rsderive_proxy_wallet→derive_safe_wallet; default--signature-type→"gnosis-safe"src/commands/setup.rsderive_proxy_wallet→derive_safe_walletsrc/auth.rsparse_signature_typefromDEFAULT_SIGNATURE_TYPEconstant to prevent incorrect mappingVerification
Test plan
cargo test— all 143 tests pass (94 unit + 49 integration)polymarket wallet showdisplays the correct Gnosis Safe proxy addresspolymarket clob balancereturns the actual balance--signature-type proxystill works for Magic Link accountsFixes #14
Note
Medium Risk
Changes the CLI’s default signature type and derived funding/approval address, which can affect where users deposit funds and what address gets approved. Risk is moderated by still allowing explicit
--signature-typeoverrides but misconfiguration could still lead to wrong addresses shown/used.Overview
Updates the CLI to default
signature_typetognosis-safe(DEFAULT_SIGNATURE_TYPEandwallet create/importdefaults), aligning derived “proxy wallet” addresses with Gnosis Safe instead of EIP-1167 proxies.Introduces
derive_wallet_for_typeand wires it throughwallet show/create/importand thesetupwizard so the displayed/deposit proxy address matches the selected signature type, and simplifies auth signature-type parsing to map explicit strings (e.g.,"proxy","gnosis-safe") rather than depending on the default constant.Written by Cursor Bugbot for commit c9255ca. This will update automatically on new commits. Configure here.