Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e7213bb54a | |||
| 005d074209 |
@@ -5,6 +5,7 @@ fn main() {
|
||||
match option_env!("NETWORK") {
|
||||
None | Some("mainnet") => println!("cargo:rustc-cfg=network=\"mainnet\"",),
|
||||
Some("sandbox") => println!("cargo:rustc-cfg=network=\"sandbox\"",),
|
||||
Some("sandbox2") => println!("cargo:rustc-cfg=network=\"sandbox2\"",),
|
||||
Some("qa") => println!("cargo:rustc-cfg=network=\"qa\""),
|
||||
_ => panic!("No such network"),
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
use crate::{
|
||||
DefaultNetworkDetails, DenomDetailsOwned, NymNetworkDetails, ValidatorDetails,
|
||||
MAINNET_DEFAULTS, QA_DEFAULTS, SANDBOX_DEFAULTS,
|
||||
MAINNET_DEFAULTS, QA_DEFAULTS, SANDBOX_DEFAULTS, SANDBOX2_DEFAULTS
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{collections::HashMap, fmt, str::FromStr};
|
||||
@@ -21,6 +21,7 @@ pub enum NetworkDefaultsError {
|
||||
pub enum Network {
|
||||
QA,
|
||||
SANDBOX,
|
||||
SANDBOX2,
|
||||
MAINNET,
|
||||
CUSTOM { details: NymNetworkDetails },
|
||||
}
|
||||
@@ -34,6 +35,7 @@ impl Network {
|
||||
match self {
|
||||
Self::QA => (&*QA_DEFAULTS).into(),
|
||||
Self::SANDBOX => (&*SANDBOX_DEFAULTS).into(),
|
||||
Self::SANDBOX2 => (&*SANDBOX2_DEFAULTS).into(),
|
||||
Self::MAINNET => (&*MAINNET_DEFAULTS).into(),
|
||||
// I dislike the clone here, but for compatibility reasons we cannot define other networks with `NymNetworkDetails` directly yet
|
||||
Self::CUSTOM { details } => details.clone(),
|
||||
@@ -89,6 +91,7 @@ impl Network {
|
||||
match self {
|
||||
Network::QA => crate::qa::REWARDING_VALIDATOR_ADDRESS,
|
||||
Network::SANDBOX => crate::sandbox::REWARDING_VALIDATOR_ADDRESS,
|
||||
Network::SANDBOX2 => crate::sandbox2::REWARDING_VALIDATOR_ADDRESS,
|
||||
Network::MAINNET => crate::mainnet::REWARDING_VALIDATOR_ADDRESS,
|
||||
Network::CUSTOM { .. } => {
|
||||
panic!("rewarding validator address is unavailable for a custom network")
|
||||
@@ -114,6 +117,7 @@ impl FromStr for Network {
|
||||
match s.to_lowercase().as_str() {
|
||||
"qa" => Ok(Network::QA),
|
||||
"sandbox" => Ok(Network::SANDBOX),
|
||||
"sandbox2" => Ok(Network::SANDBOX2),
|
||||
"mainnet" => Ok(Network::MAINNET),
|
||||
_ => Err(NetworkDefaultsError::MalformedNetworkProvided(
|
||||
s.to_string(),
|
||||
@@ -127,6 +131,7 @@ impl fmt::Display for Network {
|
||||
match *self {
|
||||
Network::QA => f.write_str("QA"),
|
||||
Network::SANDBOX => f.write_str("Sandbox"),
|
||||
Network::SANDBOX2 => f.write_str("Sandbox2"),
|
||||
Network::MAINNET => f.write_str("Mainnet"),
|
||||
Network::CUSTOM { .. } => f.write_str("Custom"),
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ pub mod eth_contract;
|
||||
pub mod mainnet;
|
||||
pub mod qa;
|
||||
pub mod sandbox;
|
||||
pub mod sandbox2;
|
||||
|
||||
// The set of defaults that are decided at compile time. Ideally we want to reduce these to a
|
||||
// minimum.
|
||||
@@ -38,6 +39,13 @@ cfg_if::cfg_if! {
|
||||
|
||||
pub const ETH_CONTRACT_ADDRESS: [u8; 20] = sandbox::_ETH_CONTRACT_ADDRESS;
|
||||
pub const ETH_ERC20_CONTRACT_ADDRESS: [u8; 20] = sandbox::_ETH_ERC20_CONTRACT_ADDRESS;
|
||||
} else if #[cfg(network = "sandbox2")] {
|
||||
pub const DEFAULT_NETWORK: all::Network = all::Network::SANDBOX2;
|
||||
pub const MIX_DENOM: DenomDetails = sandbox2::MIX_DENOM;
|
||||
pub const STAKE_DENOM: DenomDetails = sandbox2::STAKE_DENOM;
|
||||
|
||||
pub const ETH_CONTRACT_ADDRESS: [u8; 20] = sandbox2::_ETH_CONTRACT_ADDRESS;
|
||||
pub const ETH_ERC20_CONTRACT_ADDRESS: [u8; 20] = sandbox2::_ETH_ERC20_CONTRACT_ADDRESS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,6 +243,20 @@ static SANDBOX_DEFAULTS: Lazy<DefaultNetworkDetails> = Lazy::new(|| DefaultNetwo
|
||||
validators: sandbox::validators(),
|
||||
});
|
||||
|
||||
static SANDBOX2_DEFAULTS: Lazy<DefaultNetworkDetails> = Lazy::new(|| DefaultNetworkDetails {
|
||||
bech32_prefix: sandbox2::BECH32_PREFIX,
|
||||
mix_denom: sandbox2::MIX_DENOM,
|
||||
stake_denom: sandbox2::STAKE_DENOM,
|
||||
mixnet_contract_address: sandbox2::MIXNET_CONTRACT_ADDRESS,
|
||||
vesting_contract_address: sandbox2::VESTING_CONTRACT_ADDRESS,
|
||||
bandwidth_claim_contract_address: sandbox2::BANDWIDTH_CLAIM_CONTRACT_ADDRESS,
|
||||
coconut_bandwidth_contract_address: sandbox2::COCONUT_BANDWIDTH_CONTRACT_ADDRESS,
|
||||
multisig_contract_address: sandbox2::MULTISIG_CONTRACT_ADDRESS,
|
||||
rewarding_validator_address: sandbox2::REWARDING_VALIDATOR_ADDRESS,
|
||||
statistics_service_url: sandbox2::STATISTICS_SERVICE_DOMAIN_ADDRESS,
|
||||
validators: sandbox2::validators(),
|
||||
});
|
||||
|
||||
static QA_DEFAULTS: Lazy<DefaultNetworkDetails> = Lazy::new(|| DefaultNetworkDetails {
|
||||
bech32_prefix: qa::BECH32_PREFIX,
|
||||
mix_denom: qa::MIX_DENOM,
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::{DenomDetails, ValidatorDetails};
|
||||
|
||||
pub(crate) const BECH32_PREFIX: &str = "ns";
|
||||
|
||||
pub const MIX_DENOM: DenomDetails = DenomDetails::new("unymt", "nymt", 6);
|
||||
pub const STAKE_DENOM: DenomDetails = DenomDetails::new("unyxt", "nyxt", 6);
|
||||
|
||||
pub(crate) const MIXNET_CONTRACT_ADDRESS: &str = "ns17p9rzwnnfxcjp32un9ug7yhhzgtkhvl9jfksztgw5uh69wac2pgsrtzqqx";
|
||||
pub(crate) const VESTING_CONTRACT_ADDRESS: &str = "ns1aakfpghcanxtc45gpqlx8j3rq0zcpyf49qmhm9mdjrfx036h4z5sptexdf";
|
||||
pub(crate) const BANDWIDTH_CLAIM_CONTRACT_ADDRESS: &str =
|
||||
"";
|
||||
pub(crate) const COCONUT_BANDWIDTH_CONTRACT_ADDRESS: &str =
|
||||
"";
|
||||
pub(crate) const MULTISIG_CONTRACT_ADDRESS: &str = "";
|
||||
pub(crate) const _ETH_CONTRACT_ADDRESS: [u8; 20] =
|
||||
hex_literal::hex!("8e0DcFF7F3085235C32E845f3667aEB3f1e83133");
|
||||
pub(crate) const _ETH_ERC20_CONTRACT_ADDRESS: [u8; 20] =
|
||||
hex_literal::hex!("E8883BAeF3869e14E4823F46662e81D4F7d2A81F");
|
||||
pub(crate) const REWARDING_VALIDATOR_ADDRESS: &str = "ns1a4542dv9tvsa95zyztqsev6erjd2l3ywxhxnpg";
|
||||
|
||||
pub(crate) const STATISTICS_SERVICE_DOMAIN_ADDRESS: &str = "";
|
||||
pub(crate) fn validators() -> Vec<ValidatorDetails> {
|
||||
vec![ValidatorDetails::new(
|
||||
"https://sandbox2-validator1.nymtech.net",
|
||||
Some("https://sandbox2-validator-api1.nymte.ch/api"),
|
||||
)]
|
||||
}
|
||||
Generated
+3
-12
@@ -590,7 +590,7 @@ version = "1.0.1"
|
||||
dependencies = [
|
||||
"config",
|
||||
"crypto",
|
||||
"dirs 3.0.2",
|
||||
"dirs",
|
||||
"futures",
|
||||
"gateway-client",
|
||||
"gateway-requests",
|
||||
@@ -1295,15 +1295,6 @@ dependencies = [
|
||||
"subtle 2.4.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "3.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309"
|
||||
dependencies = [
|
||||
"dirs-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "4.0.0"
|
||||
@@ -3386,7 +3377,7 @@ dependencies = [
|
||||
"bip39",
|
||||
"client-core",
|
||||
"config",
|
||||
"dirs 4.0.0",
|
||||
"dirs",
|
||||
"eyre",
|
||||
"fix-path-env",
|
||||
"futures",
|
||||
@@ -3418,7 +3409,7 @@ dependencies = [
|
||||
"config",
|
||||
"credential-storage",
|
||||
"crypto",
|
||||
"dirs 3.0.2",
|
||||
"dirs",
|
||||
"dotenv",
|
||||
"futures",
|
||||
"gateway-client",
|
||||
|
||||
Reference in New Issue
Block a user