|
1 | | -use std::fmt::Write as _; |
2 | 1 | use std::str::FromStr; |
3 | 2 |
|
4 | | -use alloy::signers::local::PrivateKeySigner; |
5 | 3 | use anyhow::{Context, Result, bail}; |
6 | 4 | use clap::{Args, Subcommand}; |
7 | 5 | use polymarket_client_sdk::auth::LocalSigner; |
@@ -82,22 +80,12 @@ fn guard_overwrite(force: bool) -> Result<()> { |
82 | 80 | Ok(()) |
83 | 81 | } |
84 | 82 |
|
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 | | - |
95 | 83 | fn cmd_create(output: OutputFormat, force: bool, signature_type: &str) -> Result<()> { |
96 | 84 | guard_overwrite(force)?; |
97 | 85 |
|
98 | 86 | let signer = LocalSigner::random().with_chain_id(Some(POLYGON)); |
99 | 87 | let address = signer.address(); |
100 | | - let key_hex = signer_key_hex(&signer); |
| 88 | + let key_hex = format!("{:#x}", signer.to_bytes()); |
101 | 89 |
|
102 | 90 | config::save_wallet(&key_hex, POLYGON, signature_type)?; |
103 | 91 | let config_path = config::config_path()?; |
@@ -138,7 +126,7 @@ fn cmd_import(key: &str, output: OutputFormat, force: bool, signature_type: &str |
138 | 126 | .context("Invalid private key")? |
139 | 127 | .with_chain_id(Some(POLYGON)); |
140 | 128 | let address = signer.address(); |
141 | | - let key_hex = signer_key_hex(&signer); |
| 129 | + let key_hex = format!("{:#x}", signer.to_bytes()); |
142 | 130 |
|
143 | 131 | config::save_wallet(&key_hex, POLYGON, signature_type)?; |
144 | 132 | let config_path = config::config_path()?; |
|
0 commit comments