From b1121dabb90820612ab7a800d353a470230eb395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20H=C3=A4ggblad?= Date: Tue, 21 Feb 2023 11:30:23 +0100 Subject: [PATCH] Merge 4 tiny crates into nym-bin-common (#3065) * Rename to bin-common * Merge into new crate * Merge 3 crates into bin-common * WIP * Move build.rs to the correct place * regex nym_bin_common * regex nym_bin_common::build_information * regex nym_version_checker * Update some explicit mod paths * Makefile: add nym-connect-android * Additional fixes * rustfmt * Update crate metadata * Move completions crate into nym-bin-common * Makefile: add examples * Fix examples * rustfmt --- Cargo.lock | 92 ++++++------------- Cargo.toml | 4 +- Makefile | 36 ++++++-- clients/credential/Cargo.toml | 3 +- clients/credential/src/commands.rs | 2 +- clients/credential/src/main.rs | 4 +- clients/native/Cargo.toml | 5 +- clients/native/src/commands/mod.rs | 4 +- clients/native/src/commands/run.rs | 2 +- clients/native/src/commands/upgrade.rs | 2 +- clients/native/src/main.rs | 4 +- clients/socks5/Cargo.toml | 5 +- clients/socks5/src/commands/mod.rs | 4 +- clients/socks5/src/commands/run.rs | 2 +- clients/socks5/src/commands/upgrade.rs | 2 +- clients/socks5/src/main.rs | 4 +- .../.gitignore | 0 common/bin-common/Cargo.toml | 23 +++++ .../build.rs | 0 .../src/build_information/mod.rs} | 0 .../src/completions/mod.rs} | 0 common/bin-common/src/lib.rs | 7 ++ .../lib.rs => bin-common/src/logging/mod.rs} | 0 .../src/version_checker/mod.rs} | 0 common/build-information/Cargo.toml | 15 --- common/completions/Cargo.toml | 11 --- common/logging/Cargo.toml | 10 -- common/mixnode-common/Cargo.toml | 2 +- common/mixnode-common/src/verloc/mod.rs | 9 +- common/topology/Cargo.toml | 2 +- common/topology/src/filter.rs | 3 +- common/version-checker/Cargo.toml | 15 --- explorer-api/Cargo.toml | 2 +- explorer-api/src/main.rs | 2 +- gateway/Cargo.toml | 5 +- gateway/src/commands/mod.rs | 5 +- gateway/src/commands/upgrade.rs | 2 +- gateway/src/main.rs | 6 +- mixnode/Cargo.toml | 5 +- mixnode/src/commands/mod.rs | 5 +- mixnode/src/commands/upgrade.rs | 2 +- mixnode/src/main.rs | 6 +- mixnode/src/node/mod.rs | 2 +- nym-api/Cargo.toml | 4 +- nym-api/src/main.rs | 2 +- nym-api/src/support/cli/mod.rs | 2 +- nym-connect-android/src-tauri/Cargo.lock | 57 ++++-------- nym-connect-android/src-tauri/Cargo.toml | 2 +- nym-connect/src-tauri/Cargo.toml | 2 +- nym-wallet/Cargo.lock | 85 ++++++++++++++--- nym-wallet/nym-wallet-recovery-cli/Cargo.toml | 2 +- .../nym-wallet-recovery-cli/src/main.rs | 2 +- sdk/rust/nym-sdk/Cargo.toml | 2 +- sdk/rust/nym-sdk/examples/builder.rs | 2 +- .../nym-sdk/examples/builder_with_storage.rs | 2 +- .../manually_handle_keys_and_config.rs | 2 +- sdk/rust/nym-sdk/examples/simple.rs | 2 +- service-providers/common/Cargo.toml | 2 +- .../common/src/interface/control.rs | 2 +- .../network-requester/Cargo.toml | 5 +- .../network-requester/src/cli/mod.rs | 4 +- .../network-requester/src/cli/run.rs | 3 +- .../network-requester/src/core.rs | 2 +- .../network-requester/src/main.rs | 4 +- .../network-statistics/Cargo.toml | 2 +- .../network-statistics/src/main.rs | 2 +- tools/nym-cli/Cargo.toml | 2 +- tools/nym-cli/src/main.rs | 2 +- 68 files changed, 250 insertions(+), 262 deletions(-) rename common/{version-checker => bin-common}/.gitignore (100%) create mode 100644 common/bin-common/Cargo.toml rename common/{build-information => bin-common}/build.rs (100%) rename common/{build-information/src/lib.rs => bin-common/src/build_information/mod.rs} (100%) rename common/{completions/src/lib.rs => bin-common/src/completions/mod.rs} (100%) create mode 100644 common/bin-common/src/lib.rs rename common/{logging/src/lib.rs => bin-common/src/logging/mod.rs} (100%) rename common/{version-checker/src/lib.rs => bin-common/src/version_checker/mod.rs} (100%) delete mode 100644 common/build-information/Cargo.toml delete mode 100644 common/completions/Cargo.toml delete mode 100644 common/logging/Cargo.toml delete mode 100644 common/version-checker/Cargo.toml diff --git a/Cargo.lock b/Cargo.lock index 025fcd5e88..549e8ecbca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -445,14 +445,6 @@ dependencies = [ "serde", ] -[[package]] -name = "build-information" -version = "0.1.0" -dependencies = [ - "serde", - "vergen 7.5.1", -] - [[package]] name = "bumpalo" version = "3.12.0" @@ -805,15 +797,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "completions" -version = "0.1.0" -dependencies = [ - "clap 4.1.4", - "clap_complete", - "clap_complete_fig", -] - [[package]] name = "config" version = "0.1.0" @@ -1035,13 +1018,12 @@ dependencies = [ "bip39", "clap 4.1.4", "coconut-interface", - "completions", "config", "credential-storage", "credentials", "log", - "logging", "network-defaults", + "nym-bin-common", "nym-crypto", "nym-pemstore", "rand 0.7.3", @@ -1856,9 +1838,9 @@ dependencies = [ "isocountry", "itertools", "log", - "logging", "maxminddb", "network-defaults", + "nym-bin-common", "nym-contracts-common", "nym-mixnet-contract-common", "nym-task", @@ -3056,14 +3038,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "logging" -version = "0.1.0" -dependencies = [ - "log", - "pretty_env_logger", -] - [[package]] name = "loom" version = "0.5.6" @@ -3187,6 +3161,7 @@ dependencies = [ "humantime-serde", "log", "network-defaults", + "nym-bin-common", "nym-crypto", "nym-sphinx-acknowledgements", "nym-sphinx-addressing", @@ -3195,7 +3170,6 @@ dependencies = [ "nym-sphinx-params", "nym-sphinx-types", "nym-task", - "nym-version-checker", "rand 0.8.5", "serde", "thiserror", @@ -3374,7 +3348,6 @@ dependencies = [ "async-trait", "bip39", "bs58", - "build-information", "cfg-if", "clap 4.1.4", "coconut-bandwidth-contract-common", @@ -3398,9 +3371,9 @@ dependencies = [ "inclusion-probability", "lazy_static", "log", - "logging", "multisig-contract-common", "nym-api-requests", + "nym-bin-common", "nym-contracts-common", "nym-crypto", "nym-mixnet-contract-common", @@ -3408,7 +3381,6 @@ dependencies = [ "nym-sphinx", "nym-task", "nym-topology", - "nym-version-checker", "nym-vesting-contract-common", "nymcoconut", "okapi", @@ -3449,6 +3421,20 @@ dependencies = [ "ts-rs", ] +[[package]] +name = "nym-bin-common" +version = "0.1.0" +dependencies = [ + "clap 4.1.4", + "clap_complete", + "clap_complete_fig", + "log", + "pretty_env_logger", + "semver 0.11.0", + "serde", + "vergen 7.5.1", +] + [[package]] name = "nym-bity-integration" version = "0.1.0" @@ -3477,8 +3463,8 @@ dependencies = [ "clap_complete_fig", "dotenv", "log", - "logging", "network-defaults", + "nym-bin-common", "nym-cli-commands", "pretty_env_logger", "serde", @@ -3526,12 +3512,10 @@ dependencies = [ name = "nym-client" version = "1.1.9" dependencies = [ - "build-information", "clap 4.1.4", "client-connections", "client-core", "coconut-interface", - "completions", "config", "credential-storage", "credentials", @@ -3541,14 +3525,13 @@ dependencies = [ "gateway-requests", "lazy_static", "log", - "logging", "network-defaults", + "nym-bin-common", "nym-crypto", "nym-pemstore", "nym-sphinx", "nym-task", "nym-topology", - "nym-version-checker", "pretty_env_logger", "rand 0.7.3", "serde", @@ -3609,11 +3592,9 @@ dependencies = [ "atty", "bip39", "bs58", - "build-information", "clap 4.1.4", "coconut-interface", "colored", - "completions", "config", "credentials", "dashmap 4.0.2", @@ -3624,17 +3605,16 @@ dependencies = [ "humantime-serde", "lazy_static", "log", - "logging", "mixnet-client", "mixnode-common", "network-defaults", "nym-api-requests", + "nym-bin-common", "nym-crypto", "nym-pemstore", "nym-sphinx", "nym-task", "nym-types", - "nym-version-checker", "once_cell", "pretty_env_logger", "rand 0.7.3", @@ -3678,10 +3658,8 @@ dependencies = [ "anyhow", "atty", "bs58", - "build-information", "clap 4.1.4", "colored", - "completions", "config", "cupid", "dirs", @@ -3690,10 +3668,10 @@ dependencies = [ "humantime-serde", "lazy_static", "log", - "logging", "mixnet-client", "mixnode-common", "nonexhaustive-delayqueue", + "nym-bin-common", "nym-crypto", "nym-pemstore", "nym-sphinx", @@ -3702,7 +3680,6 @@ dependencies = [ "nym-task", "nym-topology", "nym-types", - "nym-version-checker", "pretty_env_logger", "rand 0.7.3", "rocket", @@ -3721,24 +3698,21 @@ name = "nym-network-requester" version = "1.1.9" dependencies = [ "async-trait", - "build-information", "clap 4.1.4", "client-connections", "client-core", - "completions", "config", "dirs", "futures", "ipnetwork 0.20.0", "lazy_static", "log", - "logging", "network-defaults", + "nym-bin-common", "nym-crypto", "nym-sdk", "nym-sphinx", "nym-task", - "nym-version-checker", "ordered-buffer", "pretty_env_logger", "proxy-helpers", @@ -3764,7 +3738,7 @@ version = "1.1.9" dependencies = [ "dirs", "log", - "logging", + "nym-bin-common", "pretty_env_logger", "rocket", "serde", @@ -3807,8 +3781,8 @@ dependencies = [ "gateway-client", "gateway-requests", "log", - "logging", "network-defaults", + "nym-bin-common", "nym-crypto", "nym-sphinx", "nym-task", @@ -3826,12 +3800,10 @@ dependencies = [ name = "nym-socks5-client" version = "1.1.9" dependencies = [ - "build-information", "clap 4.1.4", "client-connections", "client-core", "coconut-interface", - "completions", "config", "credential-storage", "credentials", @@ -3841,15 +3813,14 @@ dependencies = [ "gateway-requests", "lazy_static", "log", - "logging", "mobile-storage", "network-defaults", + "nym-bin-common", "nym-crypto", "nym-pemstore", "nym-sphinx", "nym-task", "nym-topology", - "nym-version-checker", "ordered-buffer", "pin-project", "pretty_env_logger", @@ -4011,11 +3982,11 @@ version = "0.1.0" dependencies = [ "bs58", "log", + "nym-bin-common", "nym-crypto", "nym-mixnet-contract-common", "nym-sphinx-addressing", "nym-sphinx-types", - "nym-version-checker", "rand 0.7.3", "thiserror", ] @@ -4046,13 +4017,6 @@ dependencies = [ "validator-client", ] -[[package]] -name = "nym-version-checker" -version = "0.1.0" -dependencies = [ - "semver 0.11.0", -] - [[package]] name = "nym-vesting-contract" version = "1.1.3" @@ -5557,8 +5521,8 @@ version = "0.1.0" dependencies = [ "anyhow", "async-trait", - "build-information", "log", + "nym-bin-common", "nym-sdk", "nym-sphinx-anonymous-replies", "serde", diff --git a/Cargo.toml b/Cargo.toml index d126c7200e..4e562f6179 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,7 @@ members = [ "clients/native/websocket-requests", "clients/socks5", "common/bandwidth-claim-contract", + "common/bin-common", "common/client-libs/gateway-client", "common/client-libs/mixnet-client", "common/client-libs/validator-client", @@ -30,7 +31,6 @@ members = [ "common/coconut-interface", "common/commands", "common/config", - "common/build-information", "common/cosmwasm-smart-contracts/coconut-bandwidth-contract", "common/cosmwasm-smart-contracts/coconut-dkg", "common/cosmwasm-smart-contracts/contracts-common", @@ -46,7 +46,6 @@ members = [ "common/execute", "common/inclusion-probability", "common/ledger", - "common/logging", "common/mixnode-common", "common/network-defaults", "common/nonexhaustive-delayqueue", @@ -69,7 +68,6 @@ members = [ "common/topology", "common/types", "common/wasm-utils", - "common/completions", "explorer-api", "gateway", "gateway/gateway-requests", diff --git a/Makefile b/Makefile index a19b0334f0..3f4c1725d2 100644 --- a/Makefile +++ b/Makefile @@ -2,12 +2,12 @@ test: clippy-all cargo-test wasm fmt test-all: test cargo-test-expensive no-clippy: build cargo-test wasm fmt happy: fmt clippy-happy test -clippy-all: clippy-main clippy-all-contracts clippy-all-wallet clippy-all-connect clippy-all-wasm-client -clippy-happy: clippy-happy-main clippy-happy-contracts clippy-happy-wallet clippy-happy-connect -cargo-test: test-main test-contracts test-wallet test-connect +clippy-all: clippy-main clippy-main-examples clippy-all-contracts clippy-all-wallet clippy-all-connect clippy-all-connect-android clippy-all-wasm-client +clippy-happy: clippy-happy-main clippy-happy-contracts clippy-happy-wallet clippy-happy-connect clippy-happy-connect-android +cargo-test: test-main test-contracts test-wallet test-connect test-connect-android cargo-test-expensive: test-main-expensive test-contracts-expensive test-wallet-expensive test-connect-expensive -build: build-contracts build-wallet build-main build-connect build-wasm-client -fmt: fmt-main fmt-contracts fmt-wallet fmt-connect fmt-wasm-client +build: build-contracts build-wallet build-main build-main-examples build-connect build-connect-android build-wasm-client +fmt: fmt-main fmt-contracts fmt-wallet fmt-connect fmt-connect-android fmt-wasm-client clippy-happy-main: cargo clippy @@ -21,9 +21,15 @@ clippy-happy-wallet: clippy-happy-connect: cargo clippy --manifest-path nym-connect/Cargo.toml +clippy-happy-connect-android: + cargo clippy --manifest-path nym-connect-android/src-tauri/Cargo.toml + clippy-main: cargo clippy --workspace -- -D warnings +clippy-main-examples: + cargo clippy --workspace --examples -- -D warnings + clippy-wasm: cargo clippy --manifest-path clients/webassembly/Cargo.toml --target wasm32-unknown-unknown --workspace -- -D warnings @@ -37,6 +43,9 @@ clippy-all-wallet: clippy-all-connect: cargo clippy --workspace --manifest-path nym-connect/Cargo.toml --all-features -- -D warnings +clippy-all-connect-android: + cargo clippy --workspace --manifest-path nym-connect-android/src-tauri/Cargo.toml --all-features -- -D warnings + clippy-all-wasm-client: cargo clippy --workspace --manifest-path clients/webassembly/Cargo.toml --all-features --target wasm32-unknown-unknown -- -D warnings @@ -64,9 +73,18 @@ test-connect: test-connect-expensive: cargo test --manifest-path nym-connect/Cargo.toml --all-features -- --ignored +test-connect-android: + cargo test --manifest-path nym-connect-android/src-tauri/Cargo.toml --all-features + +test-connect-android-expensive: + cargo test --manifest-path nym-connect-android/src-tauri/Cargo.toml --all-features -- --ignored + build-main: cargo build --workspace +build-main-examples: + cargo build --workspace --examples + build-contracts: cargo build --manifest-path contracts/Cargo.toml --workspace @@ -76,6 +94,9 @@ build-wallet: build-connect: cargo build --manifest-path nym-connect/Cargo.toml --workspace +build-connect-android: + cargo build --manifest-path nym-connect-android/src-tauri/Cargo.toml --workspace + build-explorer-api: cargo build --manifest-path explorer-api/Cargo.toml --workspace @@ -97,6 +118,9 @@ fmt-wallet: fmt-connect: cargo fmt --manifest-path nym-connect/Cargo.toml --all +fmt-connect-android: + cargo fmt --manifest-path nym-connect-android/src-tauri/Cargo.toml --all + fmt-wasm-client: cargo fmt --manifest-path clients/webassembly/Cargo.toml --all @@ -111,4 +135,4 @@ generate-typescript: yarn types:lint:fix run-validator-tests: - cd nym-api/tests/functional_test && yarn test:qa \ No newline at end of file + cd nym-api/tests/functional_test && yarn test:qa diff --git a/clients/credential/Cargo.toml b/clients/credential/Cargo.toml index a693c20d5a..91bfd5de60 100644 --- a/clients/credential/Cargo.toml +++ b/clients/credential/Cargo.toml @@ -17,11 +17,10 @@ tokio = { version = "1.24.1", features = ["rt-multi-thread", "net", "signal", "m coconut-interface = { path = "../../common/coconut-interface" } config = { path = "../../common/config" } -completions = { path = "../../common/completions" } credentials = { path = "../../common/credentials" } credential-storage = { path = "../../common/credential-storage" } nym-crypto = { path = "../../common/crypto", features = ["rand", "asymmetric", "symmetric", "aes", "hashing"] } -logging = { path = "../../common/logging"} +nym-bin-common = { path = "../../common/bin-common"} network-defaults = { path = "../../common/network-defaults" } nym-pemstore = { path = "../../common/pemstore" } validator-client = { path = "../../common/client-libs/validator-client", features = ["nyxd-client"] } diff --git a/clients/credential/src/commands.rs b/clients/credential/src/commands.rs index 7cd3831e3a..9351384216 100644 --- a/clients/credential/src/commands.rs +++ b/clients/credential/src/commands.rs @@ -2,8 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 use clap::{ArgGroup, Args, Subcommand}; -use completions::ArgShell; use log::*; +use nym_bin_common::completions::ArgShell; use rand::rngs::OsRng; use std::str::FromStr; diff --git a/clients/credential/src/main.rs b/clients/credential/src/main.rs index 0a9107e076..caa9a480c8 100644 --- a/clients/credential/src/main.rs +++ b/clients/credential/src/main.rs @@ -8,16 +8,16 @@ mod recovery_storage; mod state; use commands::*; -use completions::fig_generate; use config::{DATA_DIR, DB_FILE_NAME}; use error::Result; use log::*; use network_defaults::{setup_env, NymNetworkDetails}; +use nym_bin_common::completions::fig_generate; use std::process::exit; use std::time::{Duration, SystemTime}; use clap::{CommandFactory, Parser}; -use logging::setup_logging; +use nym_bin_common::logging::setup_logging; use validator_client::nyxd::traits::DkgQueryClient; use validator_client::nyxd::CosmWasmClient; use validator_client::Config; diff --git a/clients/native/Cargo.toml b/clients/native/Cargo.toml index c101e4bcf8..104da1e222 100644 --- a/clients/native/Cargo.toml +++ b/clients/native/Cargo.toml @@ -34,16 +34,14 @@ tokio = { version = "1.24.1", features = ["rt-multi-thread", "net", "signal"] } tokio-tungstenite = "0.14" # websocket ## internal -build-information = { path = "../../common/build-information" } +nym-bin-common = { path = "../../common/bin-common" } client-core = { path = "../client-core", features = ["fs-surb-storage"] } client-connections = { path = "../../common/client-connections" } coconut-interface = { path = "../../common/coconut-interface" } config = { path = "../../common/config" } -completions = { path = "../../common/completions" } credential-storage = { path = "../../common/credential-storage" } credentials = { path = "../../common/credentials" } nym-crypto = { path = "../../common/crypto" } -logging = { path = "../../common/logging"} gateway-client = { path = "../../common/client-libs/gateway-client" } gateway-requests = { path = "../../gateway/gateway-requests" } network-defaults = { path = "../../common/network-defaults" } @@ -52,7 +50,6 @@ nym-pemstore = { path = "../../common/pemstore" } nym-task = { path = "../../common/task" } nym-topology = { path = "../../common/topology" } validator-client = { path = "../../common/client-libs/validator-client", features = ["nyxd-client"] } -nym-version-checker = { path = "../../common/version-checker" } websocket-requests = { path = "websocket-requests" } [dev-dependencies] diff --git a/clients/native/src/commands/mod.rs b/clients/native/src/commands/mod.rs index 5e651a5f0b..1bedb2cfba 100644 --- a/clients/native/src/commands/mod.rs +++ b/clients/native/src/commands/mod.rs @@ -2,12 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 use crate::client::config::{BaseConfig, Config}; -use build_information::BinaryBuildInformation; use clap::CommandFactory; use clap::{Parser, Subcommand}; -use completions::{fig_generate, ArgShell}; use config::OptionalSet; use lazy_static::lazy_static; +use nym_bin_common::build_information::BinaryBuildInformation; +use nym_bin_common::completions::{fig_generate, ArgShell}; use std::error::Error; use std::net::IpAddr; diff --git a/clients/native/src/commands/run.rs b/clients/native/src/commands/run.rs index 39d98516c1..0c001fc892 100644 --- a/clients/native/src/commands/run.rs +++ b/clients/native/src/commands/run.rs @@ -13,8 +13,8 @@ use crate::{ use clap::Args; use config::NymConfig; use log::*; +use nym_bin_common::version_checker::is_minor_version_compatible; use nym_crypto::asymmetric::identity; -use nym_version_checker::is_minor_version_compatible; #[derive(Args, Clone)] pub(crate) struct Run { diff --git a/clients/native/src/commands/upgrade.rs b/clients/native/src/commands/upgrade.rs index 2e67e6e62b..a959c2d701 100644 --- a/clients/native/src/commands/upgrade.rs +++ b/clients/native/src/commands/upgrade.rs @@ -4,7 +4,7 @@ use crate::client::config::{Config, MISSING_VALUE}; use config::NymConfig; -use nym_version_checker::Version; +use nym_bin_common::version_checker::Version; use clap::Args; use std::fmt::Display; diff --git a/clients/native/src/main.rs b/clients/native/src/main.rs index f8fd2df71b..8e476419d4 100644 --- a/clients/native/src/main.rs +++ b/clients/native/src/main.rs @@ -4,8 +4,8 @@ use std::error::Error; use clap::{crate_name, crate_version, Parser}; -use logging::setup_logging; use network_defaults::setup_env; +use nym_bin_common::logging::{banner, setup_logging}; pub mod client; pub mod commands; @@ -15,7 +15,7 @@ pub mod websocket; #[tokio::main] async fn main() -> Result<(), Box> { setup_logging(); - println!("{}", logging::banner(crate_name!(), crate_version!())); + println!("{}", banner(crate_name!(), crate_version!())); let args = commands::Cli::parse(); setup_env(args.config_env_file.as_ref()); diff --git a/clients/socks5/Cargo.toml b/clients/socks5/Cargo.toml index 51e33b97ce..ab59a1dc76 100644 --- a/clients/socks5/Cargo.toml +++ b/clients/socks5/Cargo.toml @@ -27,17 +27,15 @@ tokio = { version = "1.24.1", features = ["rt-multi-thread", "net", "signal"] } url = "2.2" # internal -build-information = { path = "../../common/build-information" } +nym-bin-common = { path = "../../common/bin-common" } client-core = { path = "../client-core", features = ["fs-surb-storage"] } client-connections = { path = "../../common/client-connections" } coconut-interface = { path = "../../common/coconut-interface" } config = { path = "../../common/config" } -completions = { path = "../../common/completions" } credential-storage = { path = "../../common/credential-storage", optional = true } mobile-storage = { path = "../../common/mobile-storage", optional = true } credentials = { path = "../../common/credentials" } nym-crypto = { path = "../../common/crypto" } -logging = { path = "../../common/logging"} gateway-client = { path = "../../common/client-libs/gateway-client" } gateway-requests = { path = "../../gateway/gateway-requests" } network-defaults = { path = "../../common/network-defaults" } @@ -50,7 +48,6 @@ socks5-requests = { path = "../../common/socks5/requests" } nym-task = { path = "../../common/task" } nym-topology = { path = "../../common/topology" } validator-client = { path = "../../common/client-libs/validator-client", features = ["nyxd-client"] } -nym-version-checker = { path = "../../common/version-checker" } [features] default = ["credential-storage"] diff --git a/clients/socks5/src/commands/mod.rs b/clients/socks5/src/commands/mod.rs index 8f459c25c8..12c0cee7c0 100644 --- a/clients/socks5/src/commands/mod.rs +++ b/clients/socks5/src/commands/mod.rs @@ -2,12 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 use crate::client::config::{BaseConfig, Config}; -use build_information::BinaryBuildInformation; use clap::CommandFactory; use clap::{Parser, Subcommand}; -use completions::{fig_generate, ArgShell}; use config::OptionalSet; use lazy_static::lazy_static; +use nym_bin_common::build_information::BinaryBuildInformation; +use nym_bin_common::completions::{fig_generate, ArgShell}; use std::error::Error; pub mod init; diff --git a/clients/socks5/src/commands/run.rs b/clients/socks5/src/commands/run.rs index 95fbcc0970..d31388547c 100644 --- a/clients/socks5/src/commands/run.rs +++ b/clients/socks5/src/commands/run.rs @@ -10,9 +10,9 @@ use crate::{ use clap::Args; use config::NymConfig; use log::*; +use nym_bin_common::version_checker::is_minor_version_compatible; use nym_crypto::asymmetric::identity; use nym_sphinx::addressing::clients::Recipient; -use nym_version_checker::is_minor_version_compatible; #[derive(Args, Clone)] pub(crate) struct Run { diff --git a/clients/socks5/src/commands/upgrade.rs b/clients/socks5/src/commands/upgrade.rs index 151d21059e..25f5802102 100644 --- a/clients/socks5/src/commands/upgrade.rs +++ b/clients/socks5/src/commands/upgrade.rs @@ -4,7 +4,7 @@ use crate::client::config::{Config, MISSING_VALUE}; use config::NymConfig; -use nym_version_checker::Version; +use nym_bin_common::version_checker::Version; use clap::Args; use std::{fmt::Display, process}; diff --git a/clients/socks5/src/main.rs b/clients/socks5/src/main.rs index 9c8fcdb87a..e9a5811b3d 100644 --- a/clients/socks5/src/main.rs +++ b/clients/socks5/src/main.rs @@ -4,8 +4,8 @@ use std::error::Error; use clap::{crate_name, crate_version, Parser}; -use logging::setup_logging; use network_defaults::setup_env; +use nym_bin_common::logging::{banner, setup_logging}; pub mod client; mod commands; @@ -15,7 +15,7 @@ pub mod socks; #[tokio::main] async fn main() -> Result<(), Box> { setup_logging(); - println!("{}", logging::banner(crate_name!(), crate_version!())); + println!("{}", banner(crate_name!(), crate_version!())); let args = commands::Cli::parse(); setup_env(args.config_env_file.as_ref()); diff --git a/common/version-checker/.gitignore b/common/bin-common/.gitignore similarity index 100% rename from common/version-checker/.gitignore rename to common/bin-common/.gitignore diff --git a/common/bin-common/Cargo.toml b/common/bin-common/Cargo.toml new file mode 100644 index 0000000000..531709ab48 --- /dev/null +++ b/common/bin-common/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "nym-bin-common" +version = "0.1.0" +description = "Common code for nym binaries" +edition = { workspace = true } +authors = { workspace = true } +license = { workspace = true } +repository = { workspace = true } + +[dependencies] +clap = { version = "4.0", features = ["derive"] } +clap_complete = "4.0" +clap_complete_fig = "4.0" +log = { workspace = true } +pretty_env_logger = "0.4.0" +semver = "0.11" +serde = { workspace = true, features = ["derive"], optional = true } + +[build-dependencies] +vergen = { version = "7", default-features = false, features = ["build", "git", "rustc", "cargo"] } + +[features] +default = [] diff --git a/common/build-information/build.rs b/common/bin-common/build.rs similarity index 100% rename from common/build-information/build.rs rename to common/bin-common/build.rs diff --git a/common/build-information/src/lib.rs b/common/bin-common/src/build_information/mod.rs similarity index 100% rename from common/build-information/src/lib.rs rename to common/bin-common/src/build_information/mod.rs diff --git a/common/completions/src/lib.rs b/common/bin-common/src/completions/mod.rs similarity index 100% rename from common/completions/src/lib.rs rename to common/bin-common/src/completions/mod.rs diff --git a/common/bin-common/src/lib.rs b/common/bin-common/src/lib.rs new file mode 100644 index 0000000000..eed7b4f998 --- /dev/null +++ b/common/bin-common/src/lib.rs @@ -0,0 +1,7 @@ +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 + +pub mod build_information; +pub mod completions; +pub mod logging; +pub mod version_checker; diff --git a/common/logging/src/lib.rs b/common/bin-common/src/logging/mod.rs similarity index 100% rename from common/logging/src/lib.rs rename to common/bin-common/src/logging/mod.rs diff --git a/common/version-checker/src/lib.rs b/common/bin-common/src/version_checker/mod.rs similarity index 100% rename from common/version-checker/src/lib.rs rename to common/bin-common/src/version_checker/mod.rs diff --git a/common/build-information/Cargo.toml b/common/build-information/Cargo.toml deleted file mode 100644 index e76a5002c9..0000000000 --- a/common/build-information/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "build-information" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -serde = { workspace = true, features = ["derive"], optional = true } - -[build-dependencies] -vergen = { version = "7", default-features = false, features = ["build", "git", "rustc", "cargo"] } - -[features] -default = [] \ No newline at end of file diff --git a/common/completions/Cargo.toml b/common/completions/Cargo.toml deleted file mode 100644 index 53a5fa1eed..0000000000 --- a/common/completions/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "completions" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -clap = { version = "4.0", features = ["derive"] } -clap_complete = "4.0" -clap_complete_fig = "4.0" \ No newline at end of file diff --git a/common/logging/Cargo.toml b/common/logging/Cargo.toml deleted file mode 100644 index 491caa6b74..0000000000 --- a/common/logging/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "logging" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -log = { workspace = true } -pretty_env_logger = "0.4.0" diff --git a/common/mixnode-common/Cargo.toml b/common/mixnode-common/Cargo.toml index e6bfbc764a..d443e28a17 100644 --- a/common/mixnode-common/Cargo.toml +++ b/common/mixnode-common/Cargo.toml @@ -28,4 +28,4 @@ nym-sphinx-params = { path = "../nymsphinx/params" } nym-sphinx-types = { path = "../nymsphinx/types" } nym-task = { path = "../task" } validator-client = { path = "../client-libs/validator-client", features = ["nyxd-client"]} -nym-version-checker = { path = "../version-checker" } +nym-bin-common = { path = "../bin-common" } diff --git a/common/mixnode-common/src/verloc/mod.rs b/common/mixnode-common/src/verloc/mod.rs index 48fe45c5b1..0831606ef1 100644 --- a/common/mixnode-common/src/verloc/mod.rs +++ b/common/mixnode-common/src/verloc/mod.rs @@ -7,9 +7,9 @@ use futures::stream::FuturesUnordered; use futures::StreamExt; use log::*; use network_defaults::mainnet::NYM_API; +use nym_bin_common::version_checker::{self, parse_version}; use nym_crypto::asymmetric::identity; use nym_task::TaskClient; -use nym_version_checker::parse_version; use rand::seq::SliceRandom; use rand::thread_rng; use std::net::SocketAddr; @@ -44,7 +44,7 @@ const DEFAULT_RETRY_TIMEOUT: Duration = Duration::from_secs(60 * 30); #[derive(Clone, Debug)] pub struct Config { /// Minimum semver version of a node (gateway or mixnode) that is capable of replying to echo packets. - minimum_compatible_node_version: nym_version_checker::Version, + minimum_compatible_node_version: version_checker::Version, /// Socket address of this node on which it will be listening for the measurement packets. listening_address: SocketAddr, @@ -89,10 +89,7 @@ impl ConfigBuilder { Self::default() } - pub fn minimum_compatible_node_version( - mut self, - version: nym_version_checker::Version, - ) -> Self { + pub fn minimum_compatible_node_version(mut self, version: version_checker::Version) -> Self { self.0.minimum_compatible_node_version = version; self } diff --git a/common/topology/Cargo.toml b/common/topology/Cargo.toml index 91217b8101..70c8e2db9a 100644 --- a/common/topology/Cargo.toml +++ b/common/topology/Cargo.toml @@ -22,4 +22,4 @@ nym-crypto = { path = "../crypto" } nym-mixnet-contract-common = { path = "../cosmwasm-smart-contracts/mixnet-contract" } nym-sphinx-addressing = { path = "../nymsphinx/addressing" } nym-sphinx-types = { path = "../nymsphinx/types" } -nym-version-checker = { path = "../version-checker" } +nym-bin-common = { path = "../bin-common" } diff --git a/common/topology/src/filter.rs b/common/topology/src/filter.rs index fdbbc9b119..4d8d977d9e 100644 --- a/common/topology/src/filter.rs +++ b/common/topology/src/filter.rs @@ -1,6 +1,7 @@ // Copyright 2021 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 +use nym_bin_common::version_checker; use std::collections::HashMap; use std::hash::Hash; @@ -20,7 +21,7 @@ where fn filter_by_version(&self, expected_version: &str) -> Self { self.iter() .filter(|node| { - nym_version_checker::is_minor_version_compatible(&node.version(), expected_version) + version_checker::is_minor_version_compatible(&node.version(), expected_version) }) .cloned() .collect() diff --git a/common/version-checker/Cargo.toml b/common/version-checker/Cargo.toml deleted file mode 100644 index bc626fd8c8..0000000000 --- a/common/version-checker/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "nym-version-checker" -version = "0.1.0" -edition = { workspace = true } -authors = { workspace = true } -license = { workspace = true } -repository = { workspace = true } -readme = { workspace = true } -homepage = { workspace = true } -documentation = { workspace = true } - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -semver = "0.11" diff --git a/explorer-api/Cargo.toml b/explorer-api/Cargo.toml index 94dc7a4ec2..e5f5aaa2ac 100644 --- a/explorer-api/Cargo.toml +++ b/explorer-api/Cargo.toml @@ -32,6 +32,6 @@ rand_pcg = "0.3.1" nym-mixnet-contract-common = { path = "../common/cosmwasm-smart-contracts/mixnet-contract" } nym-contracts-common = { path = "../common/cosmwasm-smart-contracts/contracts-common" } network-defaults = { path = "../common/network-defaults" } -logging = { path = "../common/logging"} +nym-bin-common = { path = "../common/bin-common"} nym-task = { path = "../common/task" } validator-client = { path = "../common/client-libs/validator-client", features=["nyxd-client"] } diff --git a/explorer-api/src/main.rs b/explorer-api/src/main.rs index 208eaae3b9..4fa35f2dbe 100644 --- a/explorer-api/src/main.rs +++ b/explorer-api/src/main.rs @@ -6,8 +6,8 @@ extern crate rocket_okapi; use clap::Parser; use dotenv::dotenv; use log::info; -use logging::setup_logging; use network_defaults::setup_env; +use nym_bin_common::logging::setup_logging; use nym_task::TaskManager; pub(crate) mod cache; diff --git a/gateway/Cargo.toml b/gateway/Cargo.toml index 2db8b0fd1f..c40f5e042b 100644 --- a/gateway/Cargo.toml +++ b/gateway/Cargo.toml @@ -52,13 +52,11 @@ tokio-util = { version = "0.7.4", features = ["codec"] } url = { version = "2.2", features = ["serde"] } # internal -build-information = { path = "../common/build-information" } coconut-interface = { path = "../common/coconut-interface" } credentials = { path = "../common/credentials" } config = { path = "../common/config" } nym-crypto = { path = "../common/crypto" } -completions = { path = "../common/completions" } -logging = { path = "../common/logging" } +nym-bin-common = { path = "../common/bin-common" } gateway-requests = { path = "gateway-requests" } mixnet-client = { path = "../common/client-libs/mixnet-client" } mixnode-common = { path = "../common/mixnode-common" } @@ -71,7 +69,6 @@ nym-task = { path = "../common/task" } validator-client = { path = "../common/client-libs/validator-client", features = [ "nyxd-client", ] } -nym-version-checker = { path = "../common/version-checker" } nym-types = { path = "../common/types" } serde_json = "1" atty = "0.2" diff --git a/gateway/src/commands/mod.rs b/gateway/src/commands/mod.rs index 17b38a5967..ccc47dfe86 100644 --- a/gateway/src/commands/mod.rs +++ b/gateway/src/commands/mod.rs @@ -5,10 +5,11 @@ use crate::error::GatewayError; use crate::{config::Config, Cli}; use clap::CommandFactory; use clap::Subcommand; -use completions::{fig_generate, ArgShell}; use config::OptionalSet; use network_defaults::var_names::NYXD; use network_defaults::var_names::{BECH32_PREFIX, NYM_API, STATISTICS_SERVICE_DOMAIN_ADDRESS}; +use nym_bin_common::completions::{fig_generate, ArgShell}; +use nym_bin_common::version_checker; use std::error::Error; use std::net::IpAddr; use std::path::PathBuf; @@ -155,7 +156,7 @@ pub(crate) fn ensure_config_version_compatibility(cfg: &Config) -> Result<(), Ga if binary_version == config_version { Ok(()) - } else if nym_version_checker::is_minor_version_compatible(binary_version, config_version) { + } else if version_checker::is_minor_version_compatible(binary_version, config_version) { log::warn!( "The gateway binary has different version than what is specified in config file! {binary_version} and {config_version}. \ But, they are still semver compatible. However, consider running the `upgrade` command."); diff --git a/gateway/src/commands/upgrade.rs b/gateway/src/commands/upgrade.rs index abab75caa7..a77fe9ee07 100644 --- a/gateway/src/commands/upgrade.rs +++ b/gateway/src/commands/upgrade.rs @@ -4,7 +4,7 @@ use crate::config::{Config, MISSING_VALUE}; use clap::Args; use config::NymConfig; -use nym_version_checker::Version; +use nym_bin_common::version_checker::Version; use std::fmt::Display; use std::process; diff --git a/gateway/src/main.rs b/gateway/src/main.rs index bb7740fb72..a76214a3f3 100644 --- a/gateway/src/main.rs +++ b/gateway/src/main.rs @@ -1,13 +1,13 @@ // Copyright 2020 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -use build_information::BinaryBuildInformation; use clap::{crate_name, crate_version, Parser, ValueEnum}; use colored::Colorize; use lazy_static::lazy_static; use log::error; -use logging::setup_logging; use network_defaults::setup_env; +use nym_bin_common::logging::setup_logging; +use nym_bin_common::{build_information::BinaryBuildInformation, logging::banner}; use std::error::Error; mod commands; @@ -66,7 +66,7 @@ impl Cli { async fn main() -> Result<(), Box> { setup_logging(); if atty::is(atty::Stream::Stdout) { - println!("{}", logging::banner(crate_name!(), crate_version!())); + println!("{}", banner(crate_name!(), crate_version!())); } let args = Cli::parse(); diff --git a/mixnode/Cargo.toml b/mixnode/Cargo.toml index fd57ab1775..f813412ff1 100644 --- a/mixnode/Cargo.toml +++ b/mixnode/Cargo.toml @@ -40,11 +40,8 @@ url = { version = "2.2", features = ["serde"] } atty = "0.2" ## internal -build-information = { path = "../common/build-information" } config = { path="../common/config" } nym-crypto = { path="../common/crypto" } -completions = { path="../common/completions" } -logging = { path="../common/logging" } mixnet-client = { path="../common/client-libs/mixnet-client" } mixnode-common = { path="../common/mixnode-common" } nonexhaustive-delayqueue = { path="../common/nonexhaustive-delayqueue" } @@ -54,7 +51,7 @@ nym-task = { path = "../common/task" } nym-types = { path = "../common/types" } nym-topology = { path="../common/topology" } validator-client = { path="../common/client-libs/validator-client" } -nym-version-checker = { path="../common/version-checker" } +nym-bin-common = { path="../common/bin-common" } [dev-dependencies] tokio = { version="1.21.2", features = ["rt-multi-thread", "net", "signal", "test-util"] } diff --git a/mixnode/src/commands/mod.rs b/mixnode/src/commands/mod.rs index e2c0f39aed..a3796080d6 100644 --- a/mixnode/src/commands/mod.rs +++ b/mixnode/src/commands/mod.rs @@ -5,9 +5,10 @@ use crate::{config::Config, Cli}; use clap::CommandFactory; use clap::Subcommand; use colored::Colorize; -use completions::{fig_generate, ArgShell}; use config::defaults::var_names::{BECH32_PREFIX, NYM_API}; use config::OptionalSet; +use nym_bin_common::completions::{fig_generate, ArgShell}; +use nym_bin_common::version_checker; use nym_crypto::bech32_address_validation; use std::net::IpAddr; use std::process; @@ -141,7 +142,7 @@ pub(crate) fn version_check(cfg: &Config) -> bool { true } else { warn!("The mixnode binary has different version than what is specified in config file! {} and {}", binary_version, config_version); - if nym_version_checker::is_minor_version_compatible(binary_version, config_version) { + if version_checker::is_minor_version_compatible(binary_version, config_version) { info!("but they are still semver compatible. However, consider running the `upgrade` command"); true } else { diff --git a/mixnode/src/commands/upgrade.rs b/mixnode/src/commands/upgrade.rs index bef202b651..b69b418181 100644 --- a/mixnode/src/commands/upgrade.rs +++ b/mixnode/src/commands/upgrade.rs @@ -4,7 +4,7 @@ use crate::config::{missing_string_value, Config}; use clap::Args; use config::NymConfig; -use nym_version_checker::Version; +use nym_bin_common::version_checker::Version; use std::fmt::Display; use std::process; diff --git a/mixnode/src/main.rs b/mixnode/src/main.rs index adb9556530..d5bf1ed947 100644 --- a/mixnode/src/main.rs +++ b/mixnode/src/main.rs @@ -5,10 +5,10 @@ extern crate rocket; use ::config::defaults::setup_env; -use build_information::BinaryBuildInformation; use clap::{crate_name, crate_version, Parser, ValueEnum}; use lazy_static::lazy_static; -use logging::setup_logging; +use nym_bin_common::logging::setup_logging; +use nym_bin_common::{build_information::BinaryBuildInformation, logging::banner}; mod commands; mod config; @@ -64,7 +64,7 @@ impl Cli { async fn main() { setup_logging(); if atty::is(atty::Stream::Stdout) { - println!("{}", logging::banner(crate_name!(), crate_version!())); + println!("{}", banner(crate_name!(), crate_version!())); } let args = Cli::parse(); diff --git a/mixnode/src/node/mod.rs b/mixnode/src/node/mod.rs index 5bc0c73d35..b2443aff71 100644 --- a/mixnode/src/node/mod.rs +++ b/mixnode/src/node/mod.rs @@ -22,9 +22,9 @@ use colored::Colorize; use config::NymConfig; use log::{error, info, warn}; use mixnode_common::verloc::{self, AtomicVerlocResult, VerlocMeasurer}; +use nym_bin_common::version_checker::parse_version; use nym_crypto::asymmetric::{encryption, identity}; use nym_task::{TaskClient, TaskManager}; -use nym_version_checker::parse_version; use rand::seq::SliceRandom; use rand::thread_rng; use std::net::SocketAddr; diff --git a/nym-api/Cargo.toml b/nym-api/Cargo.toml index 2a9f60630f..ea2a6b4776 100644 --- a/nym-api/Cargo.toml +++ b/nym-api/Cargo.toml @@ -65,7 +65,6 @@ rocket_okapi = { version = "0.8.0-rc.2", features = ["swagger"] } schemars = { version = "0.8", features = ["preserve_order"] } ## internal -build-information = { path = "../common/build-information" } coconut-bandwidth-contract-common = { path = "../common/cosmwasm-smart-contracts/coconut-bandwidth-contract" } coconut-dkg-common = { path = "../common/cosmwasm-smart-contracts/coconut-dkg" } coconut-interface = { path = "../common/coconut-interface" } @@ -74,7 +73,6 @@ cosmwasm-std = "1.0.0" credential-storage = { path = "../common/credential-storage" } credentials = { path = "../common/credentials" } nym-crypto = { path = "../common/crypto" } -logging = { path = "../common/logging"} cw3 = { version = "0.13.4" } cw4 = { version = "0.13.4" } dkg = { path = "../common/dkg" } @@ -93,7 +91,7 @@ nym-api-requests = { path = "nym-api-requests" } validator-client = { path = "../common/client-libs/validator-client", features = [ "nyxd-client", ] } -nym-version-checker = { path = "../common/version-checker" } +nym-bin-common = { path = "../common/bin-common" } [features] no-reward = [] diff --git a/nym-api/src/main.rs b/nym-api/src/main.rs index 7711db94ca..c950e25032 100644 --- a/nym-api/src/main.rs +++ b/nym-api/src/main.rs @@ -18,8 +18,8 @@ use clap::Parser; use coconut::dkg::controller::DkgController; use config::NymConfig; use log::info; -use logging::setup_logging; use node_status_api::NodeStatusCache; +use nym_bin_common::logging::setup_logging; use nym_contract_cache::cache::NymContractCache; use nym_task::TaskManager; use rand::rngs::OsRng; diff --git a/nym-api/src/support/cli/mod.rs b/nym-api/src/support/cli/mod.rs index 292c7e9047..3bc86cdb50 100644 --- a/nym-api/src/support/cli/mod.rs +++ b/nym-api/src/support/cli/mod.rs @@ -4,10 +4,10 @@ use super::config::Config; use ::config::defaults::var_names::{MIXNET_CONTRACT_ADDRESS, VESTING_CONTRACT_ADDRESS}; use anyhow::Result; -use build_information::BinaryBuildInformation; use clap::Parser; use config::{NymConfig, OptionalSet}; use lazy_static::lazy_static; +use nym_bin_common::build_information::BinaryBuildInformation; use std::fs; use validator_client::nyxd; diff --git a/nym-connect-android/src-tauri/Cargo.lock b/nym-connect-android/src-tauri/Cargo.lock index 36202e1a32..02aa333473 100644 --- a/nym-connect-android/src-tauri/Cargo.lock +++ b/nym-connect-android/src-tauri/Cargo.lock @@ -405,14 +405,6 @@ dependencies = [ "serde", ] -[[package]] -name = "build-information" -version = "0.1.0" -dependencies = [ - "serde", - "vergen 7.5.1", -] - [[package]] name = "bumpalo" version = "3.12.0" @@ -785,15 +777,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "completions" -version = "0.1.0" -dependencies = [ - "clap", - "clap_complete", - "clap_complete_fig", -] - [[package]] name = "config" version = "0.1.0" @@ -3175,14 +3158,6 @@ dependencies = [ "serde", ] -[[package]] -name = "logging" -version = "0.1.0" -dependencies = [ - "log", - "pretty_env_logger", -] - [[package]] name = "loom" version = "0.5.6" @@ -3541,6 +3516,20 @@ dependencies = [ "serde", ] +[[package]] +name = "nym-bin-common" +version = "0.1.0" +dependencies = [ + "clap", + "clap_complete", + "clap_complete_fig", + "log", + "pretty_env_logger", + "semver 0.11.0", + "serde", + "vergen 7.5.1", +] + [[package]] name = "nym-connect-android" version = "1.1.9" @@ -3557,8 +3546,8 @@ dependencies = [ "futures", "itertools", "log", - "logging", "nym-api-requests", + "nym-bin-common", "nym-contracts-common", "nym-crypto", "nym-socks5-client", @@ -3643,12 +3632,10 @@ dependencies = [ name = "nym-socks5-client" version = "1.1.9" dependencies = [ - "build-information", "clap", "client-connections", "client-core", "coconut-interface", - "completions", "config", "credentials", "dirs", @@ -3657,15 +3644,14 @@ dependencies = [ "gateway-requests", "lazy_static", "log", - "logging", "mobile-storage", "network-defaults", + "nym-bin-common", "nym-crypto", "nym-pemstore", "nym-sphinx", "nym-task", "nym-topology", - "nym-version-checker", "ordered-buffer", "pin-project", "pretty_env_logger", @@ -3825,22 +3811,15 @@ version = "0.1.0" dependencies = [ "bs58", "log", + "nym-bin-common", "nym-crypto", "nym-mixnet-contract-common", "nym-sphinx-addressing", "nym-sphinx-types", - "nym-version-checker", "rand 0.7.3", "thiserror", ] -[[package]] -name = "nym-version-checker" -version = "0.1.0" -dependencies = [ - "semver 0.11.0", -] - [[package]] name = "nym-vesting-contract" version = "1.1.3" @@ -5362,8 +5341,8 @@ name = "service-providers-common" version = "0.1.0" dependencies = [ "async-trait", - "build-information", "log", + "nym-bin-common", "nym-sphinx-anonymous-replies", "serde", "serde_json", diff --git a/nym-connect-android/src-tauri/Cargo.toml b/nym-connect-android/src-tauri/Cargo.toml index 2971937987..7db18d789b 100644 --- a/nym-connect-android/src-tauri/Cargo.toml +++ b/nym-connect-android/src-tauri/Cargo.toml @@ -51,7 +51,7 @@ nym-api-requests = { path = "../../nym-api/nym-api-requests" } nym-contracts-common = { path = "../../common/cosmwasm-smart-contracts/contracts-common"} config-common = { path = "../../common/config", package = "config" } nym-crypto = { path = "../../common/crypto" } -logging = { path = "../../common/logging"} +nym-bin-common = { path = "../../common/bin-common"} nym-socks5-client = { path = "../../clients/socks5", features = ["mobile"], default-features = false } nym-task = { path = "../../common/task" } diff --git a/nym-connect/src-tauri/Cargo.toml b/nym-connect/src-tauri/Cargo.toml index 887360b22f..51a42283ab 100644 --- a/nym-connect/src-tauri/Cargo.toml +++ b/nym-connect/src-tauri/Cargo.toml @@ -49,7 +49,7 @@ nym-api-requests = { path = "../../nym-api/nym-api-requests" } nym-contracts-common = { path = "../../common/cosmwasm-smart-contracts/contracts-common"} config-common = { path = "../../common/config", package = "config" } nym-crypto = { path = "../../common/crypto" } -logging = { path = "../../common/logging"} +nym-bin-common = { path = "../../common/bin-common"} nym-socks5-client = { path = "../../clients/socks5" } nym-task = { path = "../../common/task" } diff --git a/nym-wallet/Cargo.lock b/nym-wallet/Cargo.lock index 33382ca8d8..6c4ef3310a 100644 --- a/nym-wallet/Cargo.lock +++ b/nym-wallet/Cargo.lock @@ -517,6 +517,25 @@ dependencies = [ "termcolor", ] +[[package]] +name = "clap_complete" +version = "4.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd125be87bf4c255ebc50de0b7f4d2a6201e8ac3dc86e39c0ad081dc5e7236fe" +dependencies = [ + "clap", +] + +[[package]] +name = "clap_complete_fig" +version = "4.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63a06158a72dbb088f864887b4409fd22600ba379f3cee3040f842234cc5c2d0" +dependencies = [ + "clap", + "clap_complete", +] + [[package]] name = "clap_derive" version = "4.1.0" @@ -1336,7 +1355,16 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2953d1df47ac0eb70086ccabf0275aa8da8591a28bd358ee2b52bd9f9e3ff9e9" dependencies = [ - "enum-iterator-derive", + "enum-iterator-derive 0.8.1", +] + +[[package]] +name = "enum-iterator" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ea166b3f7dc1032f7866d13f8d8e02c8d87507b61750176b86554964dc6a7bf" +dependencies = [ + "enum-iterator-derive 1.1.0", ] [[package]] @@ -1350,6 +1378,17 @@ dependencies = [ "syn", ] +[[package]] +name = "enum-iterator-derive" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "828de45d0ca18782232dfb8f3ea9cc428e8ced380eb26a520baaacfc70de39ce" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "env_logger" version = "0.7.1" @@ -2597,14 +2636,6 @@ dependencies = [ "serde", ] -[[package]] -name = "logging" -version = "0.1.0" -dependencies = [ - "log", - "pretty_env_logger", -] - [[package]] name = "loom" version = "0.5.6" @@ -2908,6 +2939,19 @@ dependencies = [ "serde", ] +[[package]] +name = "nym-bin-common" +version = "0.1.0" +dependencies = [ + "clap", + "clap_complete", + "clap_complete_fig", + "log", + "pretty_env_logger", + "semver 0.11.0", + "vergen 7.5.1", +] + [[package]] name = "nym-contracts-common" version = "0.1.0" @@ -2981,7 +3025,7 @@ dependencies = [ "schemars", "serde", "thiserror", - "vergen", + "vergen 5.1.17", ] [[package]] @@ -3006,7 +3050,7 @@ dependencies = [ "bip39", "clap", "log", - "logging", + "nym-bin-common", "pretty_env_logger", "serde_json", ] @@ -5569,7 +5613,7 @@ dependencies = [ "anyhow", "cfg-if", "chrono", - "enum-iterator", + "enum-iterator 0.8.1", "getset", "git2", "rustc_version 0.4.0", @@ -5577,6 +5621,23 @@ dependencies = [ "thiserror", ] +[[package]] +name = "vergen" +version = "7.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f21b881cd6636ece9735721cf03c1fe1e774fe258683d084bb2812ab67435749" +dependencies = [ + "anyhow", + "cfg-if", + "enum-iterator 1.3.0", + "getset", + "git2", + "rustc_version 0.4.0", + "rustversion", + "thiserror", + "time 0.3.17", +] + [[package]] name = "version-compare" version = "0.0.11" diff --git a/nym-wallet/nym-wallet-recovery-cli/Cargo.toml b/nym-wallet/nym-wallet-recovery-cli/Cargo.toml index 3f2569adfd..30d478d3b3 100644 --- a/nym-wallet/nym-wallet-recovery-cli/Cargo.toml +++ b/nym-wallet/nym-wallet-recovery-cli/Cargo.toml @@ -16,4 +16,4 @@ log = "0.4" pretty_env_logger = "0.4" serde_json = "1.0.0" -logging = { path = "../../common/logging" } \ No newline at end of file +nym-bin-common = { path = "../../common/bin-common" } diff --git a/nym-wallet/nym-wallet-recovery-cli/src/main.rs b/nym-wallet/nym-wallet-recovery-cli/src/main.rs index 08146d6234..d12d2bbaf7 100644 --- a/nym-wallet/nym-wallet-recovery-cli/src/main.rs +++ b/nym-wallet/nym-wallet-recovery-cli/src/main.rs @@ -12,7 +12,7 @@ use aes_gcm::{aead::Aead, Aes256Gcm, Key, NewAead, Nonce}; use anyhow::{anyhow, Result}; use argon2::{Algorithm, Argon2, Params, Version}; use clap::Parser; -use logging::setup_logging; +use nym_bin_common::logging::setup_logging; use serde_json::Value; // Mostly defaults diff --git a/sdk/rust/nym-sdk/Cargo.toml b/sdk/rust/nym-sdk/Cargo.toml index 67bad0b816..253cb76716 100644 --- a/sdk/rust/nym-sdk/Cargo.toml +++ b/sdk/rust/nym-sdk/Cargo.toml @@ -27,4 +27,4 @@ toml = "0.5.10" [dev-dependencies] pretty_env_logger = "0.4.0" tokio = { version = "1", features = ["full"] } -logging = { path = "../../../common/logging" } +nym-bin-common = { path = "../../../common/bin-common" } diff --git a/sdk/rust/nym-sdk/examples/builder.rs b/sdk/rust/nym-sdk/examples/builder.rs index 73606a7894..87e6461418 100644 --- a/sdk/rust/nym-sdk/examples/builder.rs +++ b/sdk/rust/nym-sdk/examples/builder.rs @@ -2,7 +2,7 @@ use nym_sdk::mixnet; #[tokio::main] async fn main() { - logging::setup_logging(); + nym_bin_common::logging::setup_logging(); // Create client builder, including ephemeral keys. The builder can be usable in the context // where you don't want to connect just yet. diff --git a/sdk/rust/nym-sdk/examples/builder_with_storage.rs b/sdk/rust/nym-sdk/examples/builder_with_storage.rs index f51ff4c156..c6ff57627b 100644 --- a/sdk/rust/nym-sdk/examples/builder_with_storage.rs +++ b/sdk/rust/nym-sdk/examples/builder_with_storage.rs @@ -4,7 +4,7 @@ use nym_sdk::mixnet; #[tokio::main] async fn main() { - logging::setup_logging(); + nym_bin_common::logging::setup_logging(); // Specify some config options let config_dir = PathBuf::from("/tmp/mixnet-client"); diff --git a/sdk/rust/nym-sdk/examples/manually_handle_keys_and_config.rs b/sdk/rust/nym-sdk/examples/manually_handle_keys_and_config.rs index b29a8f9037..8c40e86870 100644 --- a/sdk/rust/nym-sdk/examples/manually_handle_keys_and_config.rs +++ b/sdk/rust/nym-sdk/examples/manually_handle_keys_and_config.rs @@ -2,7 +2,7 @@ use nym_sdk::mixnet; #[tokio::main] async fn main() { - logging::setup_logging(); + nym_bin_common::logging::setup_logging(); let user_chosen_gateway_id = None; let nym_api_endpoints = vec!["https://validator.nymtech.net/api/".parse().unwrap()]; diff --git a/sdk/rust/nym-sdk/examples/simple.rs b/sdk/rust/nym-sdk/examples/simple.rs index 73d4aba821..f2325e6048 100644 --- a/sdk/rust/nym-sdk/examples/simple.rs +++ b/sdk/rust/nym-sdk/examples/simple.rs @@ -2,7 +2,7 @@ use nym_sdk::mixnet; #[tokio::main] async fn main() { - logging::setup_logging(); + nym_bin_common::logging::setup_logging(); // Passing no config makes the client fire up an ephemeral session and figure shit out on its own let mut client = mixnet::MixnetClient::connect_new().await.unwrap(); diff --git a/service-providers/common/Cargo.toml b/service-providers/common/Cargo.toml index 94c3bcc814..e180849ccb 100644 --- a/service-providers/common/Cargo.toml +++ b/service-providers/common/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -build-information = { path = "../../common/build-information", features = ["serde"] } +nym-bin-common = { path = "../../common/bin-common", features = ["serde"] } nym-sphinx-anonymous-replies = { path = "../../common/nymsphinx/anonymous-replies" } async-trait = { workspace = true } diff --git a/service-providers/common/src/interface/control.rs b/service-providers/common/src/interface/control.rs index 2cb2c11120..3d7f151f1c 100644 --- a/service-providers/common/src/interface/control.rs +++ b/service-providers/common/src/interface/control.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 use crate::interface::{Serializable, ServiceProviderMessagingError}; -use build_information::BinaryBuildInformationOwned; +use nym_bin_common::build_information::BinaryBuildInformationOwned; use serde::{Deserialize, Serialize}; #[derive(Debug)] diff --git a/service-providers/network-requester/Cargo.toml b/service-providers/network-requester/Cargo.toml index 42b8a7a6f9..0bb058fe6e 100644 --- a/service-providers/network-requester/Cargo.toml +++ b/service-providers/network-requester/Cargo.toml @@ -31,13 +31,11 @@ tokio-tungstenite = "0.17.2" url = { workspace = true } # internal -build-information = { path = "../../common/build-information" } client-connections = { path = "../../common/client-connections" } client-core = { path = "../../clients/client-core" } -completions = { path = "../../common/completions" } config = { path = "../../common/config" } nym-crypto = { path = "../../common/crypto" } -logging = { path = "../../common/logging"} +nym-bin-common = { path = "../../common/bin-common"} network-defaults = { path = "../../common/network-defaults" } nym-sdk = { path = "../../sdk/rust/nym-sdk" } nym-sphinx = { path = "../../common/nymsphinx" } @@ -47,5 +45,4 @@ service-providers-common = { path = "../common" } socks5-requests = { path = "../../common/socks5/requests" } statistics-common = { path = "../../common/statistics" } nym-task = { path = "../../common/task" } -nym-version-checker = { path = "../../common/version-checker" } websocket-requests = { path = "../../clients/native/websocket-requests" } diff --git a/service-providers/network-requester/src/cli/mod.rs b/service-providers/network-requester/src/cli/mod.rs index 37471c4fea..3185d52c50 100644 --- a/service-providers/network-requester/src/cli/mod.rs +++ b/service-providers/network-requester/src/cli/mod.rs @@ -1,9 +1,9 @@ // Copyright 2023 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -use build_information::BinaryBuildInformation; use clap::{CommandFactory, Parser, Subcommand}; -use completions::{fig_generate, ArgShell}; +use nym_bin_common::build_information::BinaryBuildInformation; +use nym_bin_common::completions::{fig_generate, ArgShell}; use crate::{ config::{BaseConfig, Config}, diff --git a/service-providers/network-requester/src/cli/run.rs b/service-providers/network-requester/src/cli/run.rs index 7dd5fef982..d4d2a9952b 100644 --- a/service-providers/network-requester/src/cli/run.rs +++ b/service-providers/network-requester/src/cli/run.rs @@ -8,6 +8,7 @@ use crate::{ }; use clap::Args; use config::NymConfig; +use nym_bin_common::version_checker; use nym_sphinx::addressing::clients::Recipient; const ENABLE_STATISTICS: &str = "enable-statistics"; @@ -73,7 +74,7 @@ fn version_check(cfg: &Config) -> bool { binary_version, config_version ); - if nym_version_checker::is_minor_version_compatible(binary_version, config_version) { + if version_checker::is_minor_version_compatible(binary_version, config_version) { log::info!( "but they are still semver compatible. \ However, consider running the `upgrade` command" diff --git a/service-providers/network-requester/src/core.rs b/service-providers/network-requester/src/core.rs index da0e8821f6..e05f8bbeb0 100644 --- a/service-providers/network-requester/src/core.rs +++ b/service-providers/network-requester/src/core.rs @@ -9,10 +9,10 @@ use crate::reply::MixnetMessage; use crate::statistics::ServiceStatisticsCollector; use crate::{reply, socks5}; use async_trait::async_trait; -use build_information::BinaryBuildInformation; use client_connections::LaneQueueLengths; use futures::channel::mpsc; use log::warn; +use nym_bin_common::build_information::BinaryBuildInformation; use nym_sphinx::addressing::clients::Recipient; use nym_sphinx::anonymous_replies::requests::AnonymousSenderTag; use nym_task::{TaskClient, TaskManager}; diff --git a/service-providers/network-requester/src/main.rs b/service-providers/network-requester/src/main.rs index d1987048c1..ca25899bf3 100644 --- a/service-providers/network-requester/src/main.rs +++ b/service-providers/network-requester/src/main.rs @@ -2,8 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 use clap::{crate_name, crate_version, Parser}; -use logging::setup_logging; use network_defaults::setup_env; +use nym_bin_common::logging::{banner, setup_logging}; use error::NetworkRequesterError; @@ -19,7 +19,7 @@ mod statistics; #[tokio::main] async fn main() -> Result<(), NetworkRequesterError> { setup_logging(); - println!("{}", logging::banner(crate_name!(), crate_version!())); + println!("{}", banner(crate_name!(), crate_version!())); let args = cli::Cli::parse(); setup_env(args.config_env_file.as_ref()); diff --git a/service-providers/network-statistics/Cargo.toml b/service-providers/network-statistics/Cargo.toml index 18c482c3c0..bff7abd293 100644 --- a/service-providers/network-statistics/Cargo.toml +++ b/service-providers/network-statistics/Cargo.toml @@ -14,7 +14,7 @@ serde = { version = "1.0", features = ["derive"] } sqlx = { version = "0.5", features = ["runtime-tokio-rustls", "sqlite", "macros", "migrate", "chrono"]} thiserror = "1" tokio = { version = "1.4", features = [ "net", "rt-multi-thread", "macros", "time" ] } -logging = { path = "../../common/logging"} +nym-bin-common = { path = "../../common/bin-common"} statistics-common = { path = "../../common/statistics" } [build-dependencies] diff --git a/service-providers/network-statistics/src/main.rs b/service-providers/network-statistics/src/main.rs index d9dab909e4..e9ced2c1ef 100644 --- a/service-providers/network-statistics/src/main.rs +++ b/service-providers/network-statistics/src/main.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 use api::NetworkStatisticsAPI; -use logging::setup_logging; +use nym_bin_common::logging::setup_logging; use std::path::PathBuf; mod api; diff --git a/tools/nym-cli/Cargo.toml b/tools/nym-cli/Cargo.toml index ef0c22404b..79a03ea268 100644 --- a/tools/nym-cli/Cargo.toml +++ b/tools/nym-cli/Cargo.toml @@ -21,6 +21,6 @@ anyhow = "1" tap = "1" nym-cli-commands = { path = "../../common/commands" } -logging = { path = "../../common/logging"} +nym-bin-common = { path = "../../common/bin-common"} validator-client = { path = "../../common/client-libs/validator-client", features = ["nyxd-client"] } network-defaults = { path = "../../common/network-defaults" } diff --git a/tools/nym-cli/src/main.rs b/tools/nym-cli/src/main.rs index 49183df58a..6007a3501f 100644 --- a/tools/nym-cli/src/main.rs +++ b/tools/nym-cli/src/main.rs @@ -3,7 +3,7 @@ use clap::{CommandFactory, Parser, Subcommand}; use log::{error, warn}; -use logging::setup_logging; +use nym_bin_common::logging::setup_logging; use nym_cli_commands::context::{get_network_details, ClientArgs}; use validator_client::nyxd::AccountId;