mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore(deps): trim cli-util crate deps (#9410)
This commit is contained in:
@ -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
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
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,
|
||||
@ -8,6 +6,11 @@ use std::{
|
||||
};
|
||||
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 {
|
||||
@ -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)
|
||||
}
|
||||
|
||||
@ -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,
|
||||
@ -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() {
|
||||
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user