-
Notifications
You must be signed in to change notification settings - Fork 146
feat: add SOCKS5/HTTP proxy support #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
d3d1f23
5acf9f7
e690e5f
27cb3e4
489d83e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…ARKET_PROXY env > config file)
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,17 +6,21 @@ use serde::{Deserialize, Serialize}; | |
|
|
||
| const ENV_VAR: &str = "POLYMARKET_PRIVATE_KEY"; | ||
| const SIG_TYPE_ENV_VAR: &str = "POLYMARKET_SIGNATURE_TYPE"; | ||
| const PROXY_ENV_VAR: &str = "POLYMARKET_PROXY"; | ||
| pub const DEFAULT_SIGNATURE_TYPE: &str = "proxy"; | ||
|
|
||
| pub const NO_WALLET_MSG: &str = | ||
| "No wallet configured. Run `polymarket wallet create` or `polymarket wallet import <key>`"; | ||
|
|
||
| #[derive(Serialize, Deserialize)] | ||
| pub struct Config { | ||
| #[serde(default)] | ||
| pub private_key: String, | ||
| pub chain_id: u64, | ||
| #[serde(default = "default_signature_type")] | ||
| pub signature_type: String, | ||
| #[serde(default, skip_serializing_if = "Option::is_none")] | ||
| pub proxy: Option<String>, | ||
| } | ||
|
|
||
| fn default_signature_type() -> String { | ||
|
|
@@ -98,6 +102,7 @@ pub fn save_wallet(key: &str, chain_id: u64, signature_type: &str) -> Result<()> | |
| private_key: key.to_string(), | ||
| chain_id, | ||
| signature_type: signature_type.to_string(), | ||
| proxy: None, | ||
cursor[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }; | ||
| let json = serde_json::to_string_pretty(&config)?; | ||
| let path = config_path()?; | ||
|
|
@@ -125,6 +130,22 @@ pub fn save_wallet(key: &str, chain_id: u64, signature_type: &str) -> Result<()> | |
| Ok(()) | ||
| } | ||
|
|
||
|
|
||
| /// Priority: CLI flag > env var > config file. | ||
| pub fn resolve_proxy(cli_flag: Option<&str>) -> Option<String> { | ||
| if let Some(url) = cli_flag { | ||
| return Some(url.to_string()); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Empty proxy string not filtered from CLI flagLow Severity
|
||
| } | ||
| if let Ok(url) = std::env::var(PROXY_ENV_VAR) | ||
| && !url.is_empty() | ||
| { | ||
| return Some(url); | ||
| } | ||
| if let Some(config) = load_config() { | ||
| return config.proxy; | ||
| } | ||
| None | ||
| } | ||
| /// Priority: CLI flag > env var > config file. | ||
| pub fn resolve_key(cli_flag: Option<&str>) -> (Option<String>, KeySource) { | ||
| if let Some(key) = cli_flag { | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.