Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: preserve actual key source label in setup wizard
Keep the source from resolve_key() instead of re-deriving it from
keystore_exists() heuristic. Correctly shows "POLYMARKET_PRIVATE_KEY
env var" when the key came from the env var.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
  • Loading branch information
smypmsa and claude committed Feb 25, 2026
commit fe911b0dbfd9b65bcbfa6d1c574579e5fd3372ef
44 changes: 21 additions & 23 deletions src/commands/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,32 +85,30 @@ pub fn execute() -> Result<()> {
step_header(1, total, "Wallet");

let address = if config::config_exists() || config::keystore_exists() {
// Try plaintext config first, then encrypted keystore
let existing_addr = {
let (key, _) = config::resolve_key(None);
key.as_deref()
// Try plaintext config / env var / flag first, then encrypted keystore
let (existing_addr, source) = {
let (key, src) = config::resolve_key(None);
let addr = key
.as_deref()
.and_then(|k| LocalSigner::from_str(k).ok())
.map(|s| s.address())
}
.or_else(|| {
if config::keystore_exists() {
crate::password::prompt_password_with_retries(|pw| {
config::load_key_encrypted(pw)
})
.ok()
.and_then(|k| LocalSigner::from_str(&k).ok())
.map(|s| s.address())
} else {
None
}
});
.map(|s| s.address());
(addr, src)
};
let (existing_addr, source) = if existing_addr.is_some() {
(existing_addr, source)
} else if config::keystore_exists() {
let addr = crate::password::prompt_password_with_retries(|pw| {
config::load_key_encrypted(pw)
})
.ok()
.and_then(|k| LocalSigner::from_str(&k).ok())
.map(|s| s.address());
(addr, config::KeySource::Keystore)
} else {
(None, source)
};

if let Some(addr) = existing_addr {
let source = if config::keystore_exists() {
config::KeySource::Keystore
} else {
config::KeySource::ConfigFile
};
println!(" ✓ Wallet already configured ({})", source.label());
println!(" Address: {addr}");
println!();
Expand Down