Skip to content
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

chore(deps): trim cli-util crate deps #9410

Merged
merged 1 commit into from
Jul 10, 2024
Merged
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
5 changes: 3 additions & 2 deletions Cargo.lock

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

20 changes: 13 additions & 7 deletions crates/cli/util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,24 @@ rust-version.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true
exclude.workspace = true

[lints]
workspace = true

[dependencies]
# reth
reth-fs-util.workspace = true
reth-network.workspace = true
reth-primitives.workspace = true
secp256k1.workspace = true

# eth
alloy-primitives.workspace = true
alloy-eips.workspace = true

secp256k1 = { workspace = true, features = ["rand"] }
rand.workspace = true

# misc
thiserror.workspace = true
eyre.workspace = true

[dev-dependencies]
proptest.workspace = true

[lints]
workspace = true
9 changes: 6 additions & 3 deletions crates/cli/util/src/load_secret_key.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
use reth_fs_util::{self as fs, FsPathError};
use reth_network::config::rng_secret_key;
use reth_primitives::hex::encode as hex_encode;
use secp256k1::{Error as SecretKeyBaseError, SecretKey};
use std::{
io,
path::{Path, PathBuf},
};
use thiserror::Error;

/// Convenience function to create a new random [`SecretKey`]
pub fn rng_secret_key() -> SecretKey {
SecretKey::new(&mut rand::thread_rng())
}

/// Errors returned by loading a [`SecretKey`], including IO errors.
#[derive(Error, Debug)]
pub enum SecretKeyError {
Expand Down Expand Up @@ -50,7 +53,7 @@ pub fn get_secret_key(secret_key_path: &Path) -> Result<SecretKey, SecretKeyErro
}

let secret = rng_secret_key();
let hex = hex_encode(secret.as_ref());
let hex = alloy_primitives::hex::encode(secret.as_ref());
fs::write(secret_key_path, hex)?;
Ok(secret)
}
Expand Down
6 changes: 3 additions & 3 deletions crates/cli/util/src/parsers.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use reth_primitives::{BlockHashOrNumber, B256};
use alloy_eips::BlockHashOrNumber;
use alloy_primitives::B256;
use std::{
net::{IpAddr, Ipv4Addr, SocketAddr, ToSocketAddrs},
str::FromStr,
Expand Down Expand Up @@ -68,7 +69,6 @@ pub fn parse_socket_address(value: &str) -> eyre::Result<SocketAddr, SocketAddre
mod tests {
use super::*;
use proptest::prelude::Rng;
use secp256k1::rand::thread_rng;

#[test]
fn parse_socket_addresses() {
Expand All @@ -83,7 +83,7 @@ mod tests {

#[test]
fn parse_socket_address_random() {
let port: u16 = thread_rng().gen();
let port: u16 = rand::thread_rng().gen();

for value in [format!("localhost:{port}"), format!(":{port}"), port.to_string()] {
let socket_addr = parse_socket_address(&value)
Expand Down
Loading