Add NC .env configuration

This commit is contained in:
Bogdan-Ștefan Neacșu
2023-08-14 13:39:43 +03:00
parent 83d5cc9bf4
commit c6519ffdff
10 changed files with 48 additions and 23 deletions
@@ -7,11 +7,11 @@ use nym_api_requests::coconut::{
BlindSignRequestBody, BlindedSignatureResponse, VerifyCredentialBody, VerifyCredentialResponse,
};
use nym_api_requests::models::{
ComputeRewardEstParam, GatewayCoreStatusResponse, GatewayStatusReportResponse,
GatewayUptimeHistoryResponse, InclusionProbabilityResponse, MixNodeBondAnnotated,
MixnodeCoreStatusResponse, MixnodeStatusReportResponse, MixnodeStatusResponse,
MixnodeUptimeHistoryResponse, RequestError, RewardEstimationResponse, StakeSaturationResponse,
UptimeResponse,
ComputeRewardEstParam, GatewayBondAnnotated, GatewayCoreStatusResponse,
GatewayStatusReportResponse, GatewayUptimeHistoryResponse, InclusionProbabilityResponse,
MixNodeBondAnnotated, MixnodeCoreStatusResponse, MixnodeStatusReportResponse,
MixnodeStatusResponse, MixnodeUptimeHistoryResponse, RequestError, RewardEstimationResponse,
StakeSaturationResponse, UptimeResponse,
};
use nym_mixnet_contract_common::mixnode::MixNodeDetails;
use nym_mixnet_contract_common::{GatewayBond, IdentityKeyRef, MixId};
@@ -148,6 +148,19 @@ impl Client {
.await
}
pub async fn get_gateways_detailed(&self) -> Result<Vec<GatewayBondAnnotated>, NymAPIError> {
self.query_nym_api(
&[
routes::API_VERSION,
routes::STATUS,
routes::GATEWAYS,
routes::DETAILED,
],
NO_PARAMS,
)
.await
}
pub async fn get_mixnodes_detailed_unfiltered(
&self,
) -> Result<Vec<MixNodeBondAnnotated>, NymAPIError> {
-6
View File
@@ -290,12 +290,6 @@ dependencies = [
"libc",
]
[[package]]
name = "crunchy"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
[[package]]
name = "crypto-bigint"
version = "0.4.9"
+1 -1
View File
@@ -20,6 +20,6 @@ SERVICE_PROVIDER_DIRECTORY_CONTRACT_ADDRESS=n1qsn2655eflc0nx2uwqtwyv5kad5dwm4c0g
NAME_SERVICE_CONTRACT_ADDRESS=n1cm2u5vfjd3zalfw0p65xyh4tcrw3hjlm0960gzhewga449h4mgas77mjkl
STATISTICS_SERVICE_DOMAIN_ADDRESS="https://mainnet-stats.nymte.ch:8090"
NYXD="https://qwerty-validator.qa.nymte.ch/"
NYM_API="https://qwerty-validator-api.qa.nymte.ch/api"
NYM_API="https://qwerty-validator-api.qa.nymte.ch/api/"
DKG_TIME_CONFIGURATION="600,300,300,60,60,1209600"
+1 -1
View File
@@ -18,6 +18,6 @@ COCONUT_DKG_CONTRACT_ADDRESS=n17p9rzwnnfxcjp32un9ug7yhhzgtkhvl988qccs
REWARDING_VALIDATOR_ADDRESS=n1tfzd4qz3a45u8p4mr5zmzv66457uwjgcl05jdq
STATISTICS_SERVICE_DOMAIN_ADDRESS="http://0.0.0.0"
NYXD="https://qa-validator.nymtech.net"
NYM_API="https://qa-validator-api.nymtech.net/api"
NYM_API="https://qa-validator-api.nymtech.net/api/"
DKG_TIME_CONFIGURATION="600,300,300,60,60,1209600"
+1 -1
View File
@@ -20,4 +20,4 @@ COCONUT_DKG_CONTRACT_ADDRESS=n1ahg0erc2fs6xx3j5m8sfx3ryuzdjh6kf6qm9plsf865flteky
STATISTICS_SERVICE_DOMAIN_ADDRESS="http://0.0.0.0"
NYXD="https://sandbox-validator1.nymtech.net"
NYM_API="https://sandbox-nym-api1.nymtech.net/api"
NYM_API="https://sandbox-nym-api1.nymtech.net/api/"
+2 -1
View File
@@ -3656,7 +3656,7 @@ dependencies = [
[[package]]
name = "nym-connect"
version = "1.1.15"
version = "1.1.16"
dependencies = [
"anyhow",
"bip39",
@@ -3678,6 +3678,7 @@ dependencies = [
"nym-socks5-client-core",
"nym-sphinx",
"nym-task",
"nym-validator-client",
"pretty_env_logger",
"rand 0.8.5",
"reqwest",
+1
View File
@@ -58,6 +58,7 @@ nym-bin-common = { path = "../../../common/bin-common"}
nym-socks5-client-core = { path = "../../../common/socks5-client-core" }
nym-sphinx = { path = "../../../common/nymsphinx" }
nym-task = { path = "../../../common/task" }
nym-validator-client = { path = "../../../common/client-libs/validator-client" }
[dev-dependencies]
ts-rs = "6.1.2"
@@ -45,6 +45,21 @@ pub enum BackendError {
#[from]
source: crate::operations::growth::api_client::ApiClientError,
},
#[error("{source}")]
EnvError {
#[from]
source: std::env::VarError,
},
#[error("{source}")]
UrlError {
#[from]
source: url::ParseError,
},
#[error("{source}")]
APIError {
#[from]
source: nym_validator_client::nym_api::error::NymAPIError,
},
#[error("could not send disconnect signal to the SOCKS5 client")]
CoundNotSendDisconnectSignal,
+3 -1
View File
@@ -4,6 +4,7 @@
)]
use std::env;
use std::path::PathBuf;
use std::sync::Arc;
use nym_config::defaults::setup_env;
@@ -30,7 +31,8 @@ mod window;
fn main() {
dotenvy::dotenv().ok();
setup_env(None);
setup_env(env::args().nth(1).map(PathBuf::from).as_ref());
println!("Starting up...");
// As per breaking change description here
@@ -8,9 +8,13 @@ use crate::{
};
use itertools::Itertools;
use nym_api_requests::models::GatewayBondAnnotated;
use nym_config::defaults::var_names::NYM_API;
use nym_contracts_common::types::Percent;
use nym_validator_client::nym_api::Client as ApiClient;
use std::str::FromStr;
use std::sync::Arc;
use tokio::sync::RwLock;
use url::Url;
static SERVICE_PROVIDER_WELLKNOWN_URL: &str =
"https://nymtech.net/.wellknown/connect/service-providers.json";
@@ -25,9 +29,6 @@ static HARBOUR_MASTER_URL: &str = "https://harbourmaster.nymtech.net/v1/services
// We only consider network requesters with a routing score above this threshold
const SERVICE_ROUTING_SCORE_THRESHOLD: f32 = 0.9;
static GATEWAYS_DETAILED_URL: &str =
"https://validator.nymtech.net/api/v1/status/gateways/detailed";
// Only use gateways with a performnnce score above this
const GATEWAY_PERFORMANCE_SCORE_THRESHOLD: u64 = 90;
@@ -116,10 +117,8 @@ fn filter_out_inactive_services(
}
async fn fetch_gateways() -> Result<Vec<GatewayBondAnnotated>> {
Ok(reqwest::get(GATEWAYS_DETAILED_URL)
.await?
.json::<Vec<GatewayBondAnnotated>>()
.await?)
let api_client = ApiClient::new(Url::from_str(&std::env::var(NYM_API)?)?);
Ok(api_client.get_gateways_detailed().await?)
}
#[tauri::command]