Skip to content

Commit

Permalink
Using hex crate again
Browse files Browse the repository at this point in the history
  • Loading branch information
rgomezr391 committed Nov 25, 2024
1 parent d969e57 commit 2d1e668
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/cosmos-bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ cw4-group = "2.0.0"
cw-utils = "2.0.0"
cosmwasm-std = "2.1.4"
csv = "1.3.0"
hex = "0.4"

[dev-dependencies]
quickcheck = "1"
Expand Down
5 changes: 1 addition & 4 deletions packages/cosmos-bin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ fn gen_wallet(hrp: AddressHrp) -> Result<()> {
let phrase = cosmos::SeedPhrase::random();
let wallet = phrase.with_hrp(hrp)?;
let private_key = wallet.get_privkey().private_key.display_secret();
let mut public_key = String::new();
for byte in wallet.public_key_bytes() {
public_key.push_str(&format!("{:02x}", byte));
}
let public_key = hex::encode(wallet.public_key_bytes());
println!("Mnemonic: {}", phrase.phrase());
println!("Address: {wallet}");
println!("Private Key: {}", private_key);
Expand Down
5 changes: 1 addition & 4 deletions packages/cosmos/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,10 +559,7 @@ mod tests {
let address_hrp = AddressHrp::from_static("cosmos");
let wallet = Wallet::generate(address_hrp).unwrap();
let private_key = wallet.get_privkey().private_key.display_secret();
let mut public_key = String::new();
for byte in wallet.public_key_bytes() {
public_key.push_str(&format!("{:02x}", byte));
}
let public_key = hex::encode(wallet.public_key_bytes());
assert_eq!(private_key.to_string().len(), 64);
assert_eq!(public_key.to_string().len(), 66);
}
Expand Down

0 comments on commit 2d1e668

Please sign in to comment.