Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 7 additions & 3 deletions src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ use polymarket_client_sdk::{POLYGON, clob};

use crate::config;

pub const RPC_URL: &str = "https://polygon.drpc.org";
const DEFAULT_RPC_URL: &str = "https://polygon.drpc.org";

fn rpc_url() -> String {
std::env::var("POLYMARKET_RPC_URL").unwrap_or_else(|_| DEFAULT_RPC_URL.to_string())
}

fn parse_signature_type(s: &str) -> SignatureType {
match s {
Expand Down Expand Up @@ -53,7 +57,7 @@ pub async fn authenticate_with_signer(

pub async fn create_readonly_provider() -> Result<impl alloy::providers::Provider + Clone> {
ProviderBuilder::new()
.connect(RPC_URL)
.connect(&rpc_url())
.await
.context("Failed to connect to Polygon RPC")
}
Expand All @@ -68,7 +72,7 @@ pub async fn create_provider(
.with_chain_id(Some(POLYGON));
ProviderBuilder::new()
.wallet(signer)
.connect(RPC_URL)
.connect(&rpc_url())
.await
.context("Failed to connect to Polygon RPC with wallet")
}
Expand Down
9 changes: 5 additions & 4 deletions src/commands/approve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::auth;
use crate::output::OutputFormat;
use crate::output::approve::{ApprovalStatus, print_approval_status, print_tx_result};

/// Must match `USDC_ADDRESS_STR` in commands/mod.rs.
const USDC_ADDRESS: Address = address!("0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174");

sol! {
Expand Down Expand Up @@ -39,7 +40,7 @@ pub enum ApproveCommand {
/// Check current contract approvals for a wallet
Check {
/// Wallet address to check (defaults to configured wallet)
address: Option<String>,
address: Option<Address>,
},
/// Approve all required contracts for trading (sends on-chain transactions)
Set,
Expand Down Expand Up @@ -82,18 +83,18 @@ pub async fn execute(
private_key: Option<&str>,
) -> Result<()> {
match args.command {
ApproveCommand::Check { address } => check(address.as_deref(), private_key, output).await,
ApproveCommand::Check { address } => check(address, private_key, output).await,
ApproveCommand::Set => set(private_key, output).await,
}
}

async fn check(
address_arg: Option<&str>,
address_arg: Option<Address>,
private_key: Option<&str>,
output: OutputFormat,
) -> Result<()> {
let owner: Address = if let Some(addr) = address_arg {
super::parse_address(addr)?
addr
} else {
let signer = auth::resolve_signer(private_key)?;
polymarket_client_sdk::auth::Signer::address(&signer)
Expand Down
7 changes: 2 additions & 5 deletions src/commands/bridge.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use super::parse_address;
use crate::output::OutputFormat;
use crate::output::bridge::{print_deposit, print_status, print_supported_assets};
use anyhow::Result;
Expand All @@ -19,7 +18,7 @@ pub enum BridgeCommand {
/// Get deposit addresses for a wallet (EVM, Solana, Bitcoin)
Deposit {
/// Polymarket wallet address (0x...)
address: String,
address: polymarket_client_sdk::types::Address,
},

/// List supported chains and tokens for deposits
Expand All @@ -39,9 +38,7 @@ pub async fn execute(
) -> Result<()> {
match args.command {
BridgeCommand::Deposit { address } => {
let request = DepositRequest::builder()
.address(parse_address(&address)?)
.build();
let request = DepositRequest::builder().address(address).build();

let response = client.deposit(&request).await?;
print_deposit(&response, &output)?;
Expand Down
Loading