Skip to content

Commit 47f8386

Browse files
committed
replace signer_key_hex with inline format!
1 parent c44ae8c commit 47f8386

2 files changed

Lines changed: 4 additions & 17 deletions

File tree

src/commands/setup.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use polymarket_client_sdk::auth::{LocalSigner, Signer as _};
66
use polymarket_client_sdk::types::Address;
77
use polymarket_client_sdk::{POLYGON, derive_proxy_wallet};
88

9-
use super::wallet::signer_key_hex;
109
use crate::config;
1110

1211
fn print_banner() {
@@ -117,12 +116,12 @@ fn setup_wallet() -> Result<Address> {
117116
let signer = LocalSigner::from_str(&key)
118117
.context("Invalid private key")?
119118
.with_chain_id(Some(POLYGON));
120-
let hex = signer_key_hex(&signer);
119+
let hex = format!("{:#x}", signer.to_bytes());
121120
(signer.address(), hex)
122121
} else {
123122
let signer = LocalSigner::random().with_chain_id(Some(POLYGON));
124123
let address = signer.address();
125-
let hex = signer_key_hex(&signer);
124+
let hex = format!("{:#x}", signer.to_bytes());
126125
(address, hex)
127126
};
128127

src/commands/wallet.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
use std::fmt::Write as _;
21
use std::str::FromStr;
32

4-
use alloy::signers::local::PrivateKeySigner;
53
use anyhow::{Context, Result, bail};
64
use clap::{Args, Subcommand};
75
use polymarket_client_sdk::auth::LocalSigner;
@@ -82,22 +80,12 @@ fn guard_overwrite(force: bool) -> Result<()> {
8280
Ok(())
8381
}
8482

85-
pub(crate) fn signer_key_hex(signer: &PrivateKeySigner) -> String {
86-
let bytes = signer.credential().to_bytes();
87-
let mut hex = String::with_capacity(2 + bytes.len() * 2);
88-
hex.push_str("0x");
89-
for b in &bytes {
90-
write!(hex, "{b:02x}").unwrap();
91-
}
92-
hex
93-
}
94-
9583
fn cmd_create(output: OutputFormat, force: bool, signature_type: &str) -> Result<()> {
9684
guard_overwrite(force)?;
9785

9886
let signer = LocalSigner::random().with_chain_id(Some(POLYGON));
9987
let address = signer.address();
100-
let key_hex = signer_key_hex(&signer);
88+
let key_hex = format!("{:#x}", signer.to_bytes());
10189

10290
config::save_wallet(&key_hex, POLYGON, signature_type)?;
10391
let config_path = config::config_path()?;
@@ -138,7 +126,7 @@ fn cmd_import(key: &str, output: OutputFormat, force: bool, signature_type: &str
138126
.context("Invalid private key")?
139127
.with_chain_id(Some(POLYGON));
140128
let address = signer.address();
141-
let key_hex = signer_key_hex(&signer);
129+
let key_hex = format!("{:#x}", signer.to_bytes());
142130

143131
config::save_wallet(&key_hex, POLYGON, signature_type)?;
144132
let config_path = config::config_path()?;

0 commit comments

Comments
 (0)