Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cb1e1f1f2f | |||
| 5fca0e2275 | |||
| 837909ea69 | |||
| b74490dc50 | |||
| 8113095ff5 | |||
| 2a4c1d96a4 | |||
| ed04ddf1c4 | |||
| 34b5d66df6 | |||
| 0a1a5c25f7 | |||
| 6bdba7046f | |||
| 428d91a536 | |||
| 88e0eaafcb | |||
| dd19cabf15 |
@@ -4,6 +4,7 @@
|
|||||||
use clap::{Args, Subcommand};
|
use clap::{Args, Subcommand};
|
||||||
|
|
||||||
pub mod update_config;
|
pub mod update_config;
|
||||||
|
pub mod update_cost_params;
|
||||||
pub mod vesting_update_config;
|
pub mod vesting_update_config;
|
||||||
|
|
||||||
#[derive(Debug, Args)]
|
#[derive(Debug, Args)]
|
||||||
@@ -20,7 +21,5 @@ pub enum MixnetOperatorsMixnodeSettingsCommands {
|
|||||||
/// Update mixnode configuration for a mixnode bonded with locked tokens
|
/// Update mixnode configuration for a mixnode bonded with locked tokens
|
||||||
VestingUpdateConfig(vesting_update_config::Args),
|
VestingUpdateConfig(vesting_update_config::Args),
|
||||||
/// Update mixnode cost parameters
|
/// Update mixnode cost parameters
|
||||||
UpdateCostParameters,
|
UpdateCostParameters(update_cost_params::Args),
|
||||||
/// Update mixnode cost parameters for a mixnode bonded with locked tokens
|
|
||||||
VestingUpdateCostParameters,
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
use crate::context::SigningClient;
|
||||||
|
use clap::Parser;
|
||||||
|
use cosmwasm_std::Uint128;
|
||||||
|
use log::info;
|
||||||
|
use nym_mixnet_contract_common::{MixNodeCostParams, Percent};
|
||||||
|
use nym_validator_client::nyxd::contract_traits::MixnetSigningClient;
|
||||||
|
use nym_validator_client::nyxd::CosmWasmCoin;
|
||||||
|
|
||||||
|
#[derive(Debug, Parser)]
|
||||||
|
pub struct Args {
|
||||||
|
#[clap(
|
||||||
|
long,
|
||||||
|
help = "input your profit margin as follows; (so it would be 10, rather than 0.1)"
|
||||||
|
)]
|
||||||
|
pub profit_margin_percent: Option<u8>,
|
||||||
|
|
||||||
|
#[clap(
|
||||||
|
long,
|
||||||
|
help = "operating cost in current DENOMINATION (so it would be 'unym', rather than 'nym')"
|
||||||
|
)]
|
||||||
|
pub interval_operating_cost: Option<u128>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn update_cost_params(args: Args, client: SigningClient) {
|
||||||
|
let denom = client.current_chain_details().mix_denom.base.as_str();
|
||||||
|
|
||||||
|
let cost_params = MixNodeCostParams {
|
||||||
|
profit_margin_percent: Percent::from_percentage_value(
|
||||||
|
args.profit_margin_percent.unwrap_or(10) as u64,
|
||||||
|
)
|
||||||
|
.unwrap(),
|
||||||
|
interval_operating_cost: CosmWasmCoin {
|
||||||
|
denom: denom.into(),
|
||||||
|
amount: Uint128::new(args.interval_operating_cost.unwrap_or(40_000_000)),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
info!("Starting mixnode params updating!");
|
||||||
|
let res = client
|
||||||
|
.update_mixnode_cost_params(cost_params, None)
|
||||||
|
.await
|
||||||
|
.expect("failed to update cost params");
|
||||||
|
|
||||||
|
info!("Cost params result: {:?}", res)
|
||||||
|
}
|
||||||
@@ -25,12 +25,20 @@ pub const DEFAULT_CONFIG_FILENAME: &str = "config.toml";
|
|||||||
|
|
||||||
#[cfg(feature = "dirs")]
|
#[cfg(feature = "dirs")]
|
||||||
pub fn must_get_home() -> PathBuf {
|
pub fn must_get_home() -> PathBuf {
|
||||||
dirs::home_dir().expect("Failed to evaluate $HOME value")
|
if let Some(home_dir) = std::env::var_os("NYM_HOME_DIR") {
|
||||||
|
home_dir.into()
|
||||||
|
} else {
|
||||||
|
dirs::home_dir().expect("Failed to evaluate $HOME value")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "dirs")]
|
#[cfg(feature = "dirs")]
|
||||||
pub fn may_get_home() -> Option<PathBuf> {
|
pub fn may_get_home() -> Option<PathBuf> {
|
||||||
dirs::home_dir()
|
if let Some(home_dir) = std::env::var_os("NYM_HOME_DIR") {
|
||||||
|
Some(home_dir.into())
|
||||||
|
} else {
|
||||||
|
dirs::home_dir()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait NymConfigTemplate: Serialize {
|
pub trait NymConfigTemplate: Serialize {
|
||||||
|
|||||||
@@ -81,3 +81,8 @@ cpucycles = [
|
|||||||
"opentelemetry",
|
"opentelemetry",
|
||||||
"nym-bin-common/tracing",
|
"nym-bin-common/tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[package.metadata.deb]
|
||||||
|
name = "nym-mixnode"
|
||||||
|
maintainer-scripts = "debian"
|
||||||
|
systemd-units = { enable = false }
|
||||||
|
|||||||
@@ -14,3 +14,27 @@ A Rust mixnode implementation.
|
|||||||
* `nym-mixnode run --layer 1 --host x.x.x.x` will start the mixnode in layer 1 and bind to the specified host IP address. Coordinate with other people in your network to find out which layer needs coverage.
|
* `nym-mixnode run --layer 1 --host x.x.x.x` will start the mixnode in layer 1 and bind to the specified host IP address. Coordinate with other people in your network to find out which layer needs coverage.
|
||||||
|
|
||||||
By default, the Nym Mixnode will start on port 1789. If desired, you can change the port using the `--port` option.
|
By default, the Nym Mixnode will start on port 1789. If desired, you can change the port using the `--port` option.
|
||||||
|
|
||||||
|
## Build debian package
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# cargo install cargo-deb
|
||||||
|
|
||||||
|
# Build package
|
||||||
|
cargo deb -p nym-mixnode
|
||||||
|
|
||||||
|
# Install
|
||||||
|
|
||||||
|
# This will init the mixnode to `/etc/nym` as `nym` user, and create a systemd service
|
||||||
|
sudo dpkg -i target/debian/<PACKAGE>
|
||||||
|
|
||||||
|
# Run
|
||||||
|
sudo systemctl start nym-mixnode
|
||||||
|
|
||||||
|
# Check status
|
||||||
|
sudo systemctl status nym-mixnode
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
journalctl -f -u nym-mixnode
|
||||||
|
|
||||||
|
```
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#DEBHELPER#
|
||||||
|
|
||||||
|
useradd nym
|
||||||
|
mkdir -p /etc/nym
|
||||||
|
chown -R nym /etc/nym
|
||||||
|
su nym -c 'NYM_HOME_DIR=/etc/nym nym-mixnode init --host 0.0.0.0 --id nym-mixnode'
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Nym Mixnode
|
||||||
|
After=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/bin/nym-mixnode run --id nym-mixnode
|
||||||
|
User=nym
|
||||||
|
Environment="NYM_HOME_DIR=/etc/nym"
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -13,7 +13,7 @@ This is the application UI layer for the next NymVPN clients.
|
|||||||
Some system libraries are required depending on the host platform.
|
Some system libraries are required depending on the host platform.
|
||||||
Follow the instructions for your specific OS [here](https://tauri.app/v1/guides/getting-started/prerequisites)
|
Follow the instructions for your specific OS [here](https://tauri.app/v1/guides/getting-started/prerequisites)
|
||||||
|
|
||||||
To install run
|
To install:
|
||||||
|
|
||||||
```
|
```
|
||||||
yarn
|
yarn
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ in combination with their own configuration. If you are trying to access somethi
|
|||||||
3. If you are using `mixFetch` in a web app with HTTPS you will need to use a gateway that has Secure Websockets to
|
3. If you are using `mixFetch` in a web app with HTTPS you will need to use a gateway that has Secure Websockets to
|
||||||
avoid getting a [mixed content](https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content) error.
|
avoid getting a [mixed content](https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content) error.
|
||||||
|
|
||||||
|
4. For now, mixfetch doesn't work with SURBS, altough this may change in the future.
|
||||||
|
|
||||||
|
|
||||||
Read [this article](https://blog.nymtech.net/mixfetch-like-the-fetch-api-but-via-the-mixnet-82acfd435c62) to learn more about mixFetch.
|
Read [this article](https://blog.nymtech.net/mixfetch-like-the-fetch-api-but-via-the-mixnet-82acfd435c62) to learn more about mixFetch.
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ pub(crate) trait ReleasePackage: Sized {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_nym_dependencies(&mut self, _: &HashSet<String>) -> anyhow::Result<()> {
|
fn update_nym_dependencies(&mut self, _: &HashSet<String>, _: bool) -> anyhow::Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -57,28 +57,29 @@ pub(crate) trait VersionBumpExt: Sized {
|
|||||||
fn try_remove_prerelease(&self) -> anyhow::Result<Self>;
|
fn try_remove_prerelease(&self) -> anyhow::Result<Self>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn try_bump_raw_prerelease(raw: &str) -> anyhow::Result<Prerelease> {
|
||||||
|
// ugh that's disgusting
|
||||||
|
let (rc_prefix, pre_version) = raw
|
||||||
|
.split_once('.')
|
||||||
|
.context("the prerelease version does not contain a valid rc.X suffix")?;
|
||||||
|
|
||||||
|
let parsed_version: u32 = pre_version.parse()?;
|
||||||
|
let updated_version = parsed_version + 1;
|
||||||
|
|
||||||
|
Ok(format!("{rc_prefix}.{updated_version}").parse()?)
|
||||||
|
}
|
||||||
|
|
||||||
impl VersionBumpExt for Version {
|
impl VersionBumpExt for Version {
|
||||||
fn try_bump_prerelease(&self) -> anyhow::Result<Self> {
|
fn try_bump_prerelease(&self) -> anyhow::Result<Self> {
|
||||||
if self.pre.is_empty() {
|
if self.pre.is_empty() {
|
||||||
bail!("the current version ({self}) does not have pre-release data set - are you sure you followed the release process correctly?")
|
bail!("the current version ({self}) does not have pre-release data set - are you sure you followed the release process correctly?")
|
||||||
}
|
}
|
||||||
|
|
||||||
// ugh that's disgusting
|
|
||||||
let (rc_prefix, pre_version) = self
|
|
||||||
.pre
|
|
||||||
.as_str()
|
|
||||||
.split_once('.')
|
|
||||||
.context("the prerelease version does not contain a valid rc.X suffix")?;
|
|
||||||
|
|
||||||
let parsed_version: u32 = pre_version.parse()?;
|
|
||||||
let updated_version = parsed_version + 1;
|
|
||||||
|
|
||||||
let pre = format!("{rc_prefix}.{updated_version}").parse()?;
|
|
||||||
Ok(Version {
|
Ok(Version {
|
||||||
major: self.major,
|
major: self.major,
|
||||||
minor: self.minor,
|
minor: self.minor,
|
||||||
patch: self.patch,
|
patch: self.patch,
|
||||||
pre,
|
pre: try_bump_raw_prerelease(self.pre.as_str())?,
|
||||||
build: self.build.clone(),
|
build: self.build.clone(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
use crate::helpers::try_bump_raw_prerelease;
|
||||||
use crate::json_types::DepsSet;
|
use crate::json_types::DepsSet;
|
||||||
use crate::{json_types, ReleasePackage};
|
use crate::{json_types, ReleasePackage};
|
||||||
use anyhow::{bail, Context};
|
use anyhow::{bail, Context};
|
||||||
@@ -14,10 +15,18 @@ pub struct PackageJson {
|
|||||||
inner: json_types::Package,
|
inner: json_types::Package,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_dependencies(deps: &mut DepsSet, names: &HashSet<String>) -> anyhow::Result<()> {
|
fn update_dependencies(
|
||||||
|
deps: &mut DepsSet,
|
||||||
|
names: &HashSet<String>,
|
||||||
|
pre_release: bool,
|
||||||
|
) -> anyhow::Result<()> {
|
||||||
for (package, version) in deps.iter_mut() {
|
for (package, version) in deps.iter_mut() {
|
||||||
if names.contains(package) {
|
if names.contains(package) {
|
||||||
let updated = try_bump_minor_version_req(version)?;
|
let updated = if pre_release {
|
||||||
|
try_bump_prerelease_version_req(version)?
|
||||||
|
} else {
|
||||||
|
try_bump_minor_version_req(version)?
|
||||||
|
};
|
||||||
|
|
||||||
println!("\t\t>>> updating '{package}' from {version} to {updated}");
|
println!("\t\t>>> updating '{package}' from {version} to {updated}");
|
||||||
*version = updated
|
*version = updated
|
||||||
@@ -52,21 +61,25 @@ impl ReleasePackage for PackageJson {
|
|||||||
self.inner.version = version.to_string()
|
self.inner.version = version.to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_nym_dependencies(&mut self, names: &HashSet<String>) -> anyhow::Result<()> {
|
fn update_nym_dependencies(
|
||||||
|
&mut self,
|
||||||
|
names: &HashSet<String>,
|
||||||
|
pre_release: bool,
|
||||||
|
) -> anyhow::Result<()> {
|
||||||
println!("\t>>> updating @nymproject dependencies...");
|
println!("\t>>> updating @nymproject dependencies...");
|
||||||
update_dependencies(&mut self.inner.dependencies, names)?;
|
update_dependencies(&mut self.inner.dependencies, names, pre_release)?;
|
||||||
|
|
||||||
println!("\t>>> updating @nymproject peerDependencies...");
|
println!("\t>>> updating @nymproject peerDependencies...");
|
||||||
update_dependencies(&mut self.inner.peer_dependencies, names)?;
|
update_dependencies(&mut self.inner.peer_dependencies, names, pre_release)?;
|
||||||
|
|
||||||
println!("\t>>> updating @nymproject devDependencies...");
|
println!("\t>>> updating @nymproject devDependencies...");
|
||||||
update_dependencies(&mut self.inner.dev_dependencies, names)?;
|
update_dependencies(&mut self.inner.dev_dependencies, names, pre_release)?;
|
||||||
|
|
||||||
println!("\t>>> updating @nymproject optionalDependencies...");
|
println!("\t>>> updating @nymproject optionalDependencies...");
|
||||||
update_dependencies(&mut self.inner.optional_dependencies, names)?;
|
update_dependencies(&mut self.inner.optional_dependencies, names, pre_release)?;
|
||||||
|
|
||||||
println!("\t>>> updating @nymproject bundledDependencies...");
|
println!("\t>>> updating @nymproject bundledDependencies...");
|
||||||
update_dependencies(&mut self.inner.bundled_dependencies, names)?;
|
update_dependencies(&mut self.inner.bundled_dependencies, names, pre_release)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -101,9 +114,9 @@ pub(crate) fn find_package_path(dir: &Path) -> anyhow::Result<PathBuf> {
|
|||||||
|
|
||||||
// expected structure: `>=X.Y.Z-rc.W || ^X`
|
// expected structure: `>=X.Y.Z-rc.W || ^X`
|
||||||
fn try_bump_minor_version_req(raw_req: &str) -> anyhow::Result<String> {
|
fn try_bump_minor_version_req(raw_req: &str) -> anyhow::Result<String> {
|
||||||
let (req, major) = raw_req
|
let (req, major) = raw_req.split_once("||").context(format!(
|
||||||
.split_once("||")
|
"'{raw_req}' is not a valid semver version requirement - we expect '`>=X.Y.Z-rc.W || ^X`'"
|
||||||
.context("invalid version requirement")?;
|
))?;
|
||||||
let parsed_req = VersionReq::parse(req)?;
|
let parsed_req = VersionReq::parse(req)?;
|
||||||
let parsed_major = VersionReq::parse(major)?;
|
let parsed_major = VersionReq::parse(major)?;
|
||||||
if parsed_req.comparators.len() != 1 {
|
if parsed_req.comparators.len() != 1 {
|
||||||
@@ -123,6 +136,30 @@ fn try_bump_minor_version_req(raw_req: &str) -> anyhow::Result<String> {
|
|||||||
Ok(format!("{updated} || {parsed_major}"))
|
Ok(format!("{updated} || {parsed_major}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// expected structure: `>=X.Y.Z-rc.W || ^X`
|
||||||
|
fn try_bump_prerelease_version_req(raw_req: &str) -> anyhow::Result<String> {
|
||||||
|
let (req, major) = raw_req.split_once("||").context(format!(
|
||||||
|
"'{raw_req}' is not a valid semver version requirement - we expect '`>=X.Y.Z-rc.W || ^X`'"
|
||||||
|
))?;
|
||||||
|
let parsed_req = VersionReq::parse(req)?;
|
||||||
|
let parsed_major = VersionReq::parse(major)?;
|
||||||
|
if parsed_req.comparators.len() != 1 {
|
||||||
|
bail!("wrong number of version requirements present in {parsed_req}")
|
||||||
|
}
|
||||||
|
|
||||||
|
let updated = VersionReq {
|
||||||
|
comparators: vec![Comparator {
|
||||||
|
op: parsed_req.comparators[0].op,
|
||||||
|
major: parsed_req.comparators[0].major,
|
||||||
|
minor: parsed_req.comparators[0].minor,
|
||||||
|
patch: parsed_req.comparators[0].patch,
|
||||||
|
pre: try_bump_raw_prerelease(parsed_req.comparators[0].pre.as_str())?,
|
||||||
|
}],
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(format!("{updated} || {parsed_major}"))
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use crate::cargo::CargoPackage;
|
|||||||
use crate::helpers::ReleasePackage;
|
use crate::helpers::ReleasePackage;
|
||||||
use crate::json::PackageJson;
|
use crate::json::PackageJson;
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
use std::collections::HashSet;
|
use std::collections::{HashMap, HashSet};
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
@@ -18,6 +18,48 @@ fn default_root() -> PathBuf {
|
|||||||
env::current_dir().unwrap()
|
env::current_dir().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct Summary {
|
||||||
|
cargo_results: HashMap<String, anyhow::Result<()>>,
|
||||||
|
|
||||||
|
json_results: HashMap<String, anyhow::Result<()>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Summary {
|
||||||
|
fn new(
|
||||||
|
cargo_results: HashMap<String, anyhow::Result<()>>,
|
||||||
|
json_results: HashMap<String, anyhow::Result<()>>,
|
||||||
|
) -> Self {
|
||||||
|
Summary {
|
||||||
|
cargo_results,
|
||||||
|
json_results,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn print(&self) {
|
||||||
|
let cargo_ok = self.cargo_results.values().filter(|p| p.is_ok()).count();
|
||||||
|
let json_ok = self.json_results.values().filter(|p| p.is_ok()).count();
|
||||||
|
|
||||||
|
println!("SUMMARY");
|
||||||
|
println!("inspected {} cargo packages", self.cargo_results.len());
|
||||||
|
println!("updated {cargo_ok} cargo packages");
|
||||||
|
for (package, res) in &self.cargo_results {
|
||||||
|
if let Err(err) = res {
|
||||||
|
println!(
|
||||||
|
"\t>>> ❌ FAILURE: cargo package '{package}' failed to get updated: {err}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("inspected {} json packages", self.json_results.len());
|
||||||
|
println!("updated {json_ok} json packages");
|
||||||
|
for (package, res) in &self.json_results {
|
||||||
|
if let Err(err) = res {
|
||||||
|
println!("\t>>> ❌ FAILURE: json package '{package}' failed to get updated: {err}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
struct Args {
|
struct Args {
|
||||||
#[arg(default_value=default_root().into_os_string())]
|
#[arg(default_value=default_root().into_os_string())]
|
||||||
@@ -36,12 +78,13 @@ enum Commands {
|
|||||||
/// It will also update the `@nymproject/...` dependencies from `">=X.Y.Z-rc.0 || ^X"` to `">=X.Y.(Z+1)-rc.0 || ^X"`
|
/// It will also update the `@nymproject/...` dependencies from `">=X.Y.Z-rc.0 || ^X"` to `">=X.Y.(Z+1)-rc.0 || ^X"`
|
||||||
BumpVersion {
|
BumpVersion {
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
/// If enabled, the packages will only have their rc version bumped and the dependencies won't get updated at all
|
/// If enabled, the packages will only have their rc version bumped and the dependencies
|
||||||
|
/// will get updated from `">=X.Y.Z-rc.W || ^X"` to `">=X.Y.Z-rc.(W+1) || ^X"`
|
||||||
pre_release: bool,
|
pre_release: bool,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_suffix<Pkg: ReleasePackage>(root: &Path, path: impl AsRef<Path>) {
|
fn remove_suffix<Pkg: ReleasePackage>(root: &Path, path: impl AsRef<Path>) -> anyhow::Result<()> {
|
||||||
let path = root.join(path);
|
let path = root.join(path);
|
||||||
println!(
|
println!(
|
||||||
">>> [{}] UPDATING PACKAGE {}: ",
|
">>> [{}] UPDATING PACKAGE {}: ",
|
||||||
@@ -51,8 +94,10 @@ fn remove_suffix<Pkg: ReleasePackage>(root: &Path, path: impl AsRef<Path>) {
|
|||||||
|
|
||||||
if let Err(err) = { remove_suffix_inner::<Pkg>(path) } {
|
if let Err(err) = { remove_suffix_inner::<Pkg>(path) } {
|
||||||
println!("\t>>> ❌ FAILURE: {err}");
|
println!("\t>>> ❌ FAILURE: {err}");
|
||||||
|
Err(err)
|
||||||
} else {
|
} else {
|
||||||
println!("\t>>> ✅ SUCCESS");
|
println!("\t>>> ✅ SUCCESS");
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +115,7 @@ fn bump_version<Pkg: ReleasePackage>(
|
|||||||
path: impl AsRef<Path>,
|
path: impl AsRef<Path>,
|
||||||
dependencies_to_update: &HashSet<String>,
|
dependencies_to_update: &HashSet<String>,
|
||||||
pre_release: bool,
|
pre_release: bool,
|
||||||
) {
|
) -> anyhow::Result<()> {
|
||||||
let path = root.join(path);
|
let path = root.join(path);
|
||||||
println!(
|
println!(
|
||||||
">>> [{}] UPDATING PACKAGE {}: ",
|
">>> [{}] UPDATING PACKAGE {}: ",
|
||||||
@@ -79,8 +124,10 @@ fn bump_version<Pkg: ReleasePackage>(
|
|||||||
);
|
);
|
||||||
if let Err(err) = { bump_version_inner::<Pkg>(path, dependencies_to_update, pre_release) } {
|
if let Err(err) = { bump_version_inner::<Pkg>(path, dependencies_to_update, pre_release) } {
|
||||||
println!("\t>>> ❌ FAILURE: {err}");
|
println!("\t>>> ❌ FAILURE: {err}");
|
||||||
|
Err(err)
|
||||||
} else {
|
} else {
|
||||||
println!("\t>>> ✅ SUCCESS");
|
println!("\t>>> ✅ SUCCESS");
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,9 +140,7 @@ fn bump_version_inner<Pkg: ReleasePackage>(
|
|||||||
let mut package = Pkg::open(path)?;
|
let mut package = Pkg::open(path)?;
|
||||||
package.bump_version(pre_release)?;
|
package.bump_version(pre_release)?;
|
||||||
|
|
||||||
if !pre_release {
|
package.update_nym_dependencies(dependencies_to_update, pre_release)?;
|
||||||
package.update_nym_dependencies(dependencies_to_update)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
println!("\t>>> saving the package file...");
|
println!("\t>>> saving the package file...");
|
||||||
package.save_changes()
|
package.save_changes()
|
||||||
@@ -132,34 +177,46 @@ impl InternalPackages {
|
|||||||
self.internal_js_dependencies.insert(name.into());
|
self.internal_js_dependencies.insert(name.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove_suffix(&self) {
|
pub fn remove_suffix(&self) -> Summary {
|
||||||
|
let mut cargo_results = HashMap::new();
|
||||||
for cargo_package in &self.cargo {
|
for cargo_package in &self.cargo {
|
||||||
remove_suffix::<CargoPackage>(&self.root, cargo_package);
|
let res = remove_suffix::<CargoPackage>(&self.root, cargo_package);
|
||||||
|
cargo_results.insert(cargo_package.clone(), res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut json_results = HashMap::new();
|
||||||
for package_json in &self.json {
|
for package_json in &self.json {
|
||||||
remove_suffix::<PackageJson>(&self.root, package_json);
|
let res = remove_suffix::<PackageJson>(&self.root, package_json);
|
||||||
|
json_results.insert(package_json.clone(), res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Summary::new(cargo_results, json_results)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bump_version(&self, pre_release: bool) {
|
pub fn bump_version(&self, pre_release: bool) -> Summary {
|
||||||
|
let mut cargo_results = HashMap::new();
|
||||||
for cargo_package in &self.cargo {
|
for cargo_package in &self.cargo {
|
||||||
bump_version::<CargoPackage>(
|
let res = bump_version::<CargoPackage>(
|
||||||
&self.root,
|
&self.root,
|
||||||
cargo_package,
|
cargo_package,
|
||||||
&Default::default(),
|
&Default::default(),
|
||||||
pre_release,
|
pre_release,
|
||||||
);
|
);
|
||||||
|
cargo_results.insert(cargo_package.clone(), res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut json_results = HashMap::new();
|
||||||
for package_json in &self.json {
|
for package_json in &self.json {
|
||||||
bump_version::<PackageJson>(
|
let res = bump_version::<PackageJson>(
|
||||||
&self.root,
|
&self.root,
|
||||||
package_json,
|
package_json,
|
||||||
&self.internal_js_dependencies,
|
&self.internal_js_dependencies,
|
||||||
pre_release,
|
pre_release,
|
||||||
);
|
);
|
||||||
|
json_results.insert(package_json.clone(), res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Summary::new(cargo_results, json_results)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,10 +283,12 @@ fn main() -> anyhow::Result<()> {
|
|||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
let packages = initialise_internal_packages(args.root);
|
let packages = initialise_internal_packages(args.root);
|
||||||
|
|
||||||
match args.command {
|
let summary = match args.command {
|
||||||
Commands::RemoveSuffix => packages.remove_suffix(),
|
Commands::RemoveSuffix => packages.remove_suffix(),
|
||||||
Commands::BumpVersion { pre_release } => packages.bump_version(pre_release),
|
Commands::BumpVersion { pre_release } => packages.bump_version(pre_release),
|
||||||
}
|
};
|
||||||
|
|
||||||
|
summary.print();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ pub(crate) async fn execute(
|
|||||||
nym_cli_commands::validator::mixnet::operators::mixnode::settings::MixnetOperatorsMixnodeSettingsCommands::UpdateConfig(args) => {
|
nym_cli_commands::validator::mixnet::operators::mixnode::settings::MixnetOperatorsMixnodeSettingsCommands::UpdateConfig(args) => {
|
||||||
nym_cli_commands::validator::mixnet::operators::mixnode::settings::update_config::update_config(args, create_signing_client(global_args, network_details)?).await
|
nym_cli_commands::validator::mixnet::operators::mixnode::settings::update_config::update_config(args, create_signing_client(global_args, network_details)?).await
|
||||||
}
|
}
|
||||||
|
nym_cli_commands::validator::mixnet::operators::mixnode::settings::MixnetOperatorsMixnodeSettingsCommands::UpdateCostParameters(args) => {
|
||||||
|
nym_cli_commands::validator::mixnet::operators::mixnode::settings::update_cost_params::update_cost_params(args, create_signing_client(global_args, network_details)?).await
|
||||||
|
}
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user