Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions common/network-defaults/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub struct NymNetworkDetails {
pub endpoints: Vec<ValidatorDetails>,
pub contracts: NymContracts,
pub explorer_api: Option<String>,
pub nym_vpn_api_url: Option<String>,
}

// by default we assume the same defaults as mainnet, i.e. same prefixes and denoms
Expand Down Expand Up @@ -71,6 +72,7 @@ impl NymNetworkDetails {
endpoints: Default::default(),
contracts: Default::default(),
explorer_api: Default::default(),
nym_vpn_api_url: Default::default(),
}
}

Expand Down Expand Up @@ -126,6 +128,7 @@ impl NymNetworkDetails {
.with_multisig_contract(get_optional_env(var_names::MULTISIG_CONTRACT_ADDRESS))
.with_coconut_dkg_contract(get_optional_env(var_names::COCONUT_DKG_CONTRACT_ADDRESS))
.with_explorer_api(get_optional_env(var_names::EXPLORER_API))
.with_nym_vpn_api_url(get_optional_env(var_names::NYM_VPN_API))
}

pub fn new_mainnet() -> Self {
Expand Down Expand Up @@ -155,6 +158,7 @@ impl NymNetworkDetails {
),
},
explorer_api: parse_optional_str(mainnet::EXPLORER_API),
nym_vpn_api_url: parse_optional_str(mainnet::NYM_VPN_API),
}
}

Expand Down Expand Up @@ -263,6 +267,19 @@ impl NymNetworkDetails {
self.explorer_api = endpoint.map(Into::into);
self
}

#[must_use]
pub fn with_nym_vpn_api_url<S: Into<String>>(mut self, endpoint: Option<S>) -> Self {
self.nym_vpn_api_url = endpoint.map(Into::into);
self
}

pub fn nym_vpn_api_url(&self) -> Option<Url> {
self.nym_vpn_api_url.as_ref().map(|url| {
url.parse()
.expect("the provided nym-vpn api url is invalid!")
})
}
}

#[derive(Debug, Copy, Serialize, Deserialize, Clone, PartialEq, Eq)]
Expand Down
3 changes: 3 additions & 0 deletions common/network-defaults/src/mainnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub const NYXD_URL: &str = "https://rpc.nymtech.net";
pub const NYM_API: &str = "https://validator.nymtech.net/api/";
pub const NYXD_WS: &str = "wss://rpc.nymtech.net/websocket";
pub const EXPLORER_API: &str = "https://explorer.nymtech.net/api/";
pub const NYM_VPN_API: &str = "https://nymvpn.net/api/";

// I'm making clippy mad on purpose, because that url HAS TO be updated and deployed before merging
pub const EXIT_POLICY_URL: &str =
Expand Down Expand Up @@ -114,6 +115,7 @@ pub fn export_to_env() {
set_var_to_default(var_names::NYXD_WEBSOCKET, NYXD_WS);
set_var_to_default(var_names::EXPLORER_API, EXPLORER_API);
set_var_to_default(var_names::EXIT_POLICY_URL, EXIT_POLICY_URL);
set_var_to_default(var_names::NYM_VPN_API, NYM_VPN_API);
}

pub fn export_to_env_if_not_set() {
Expand Down Expand Up @@ -155,4 +157,5 @@ pub fn export_to_env_if_not_set() {
set_var_conditionally_to_default(var_names::NYXD_WEBSOCKET, NYXD_WS);
set_var_conditionally_to_default(var_names::EXPLORER_API, EXPLORER_API);
set_var_conditionally_to_default(var_names::EXIT_POLICY_URL, EXIT_POLICY_URL);
set_var_conditionally_to_default(var_names::NYM_VPN_API, NYM_VPN_API);
}
1 change: 1 addition & 0 deletions common/network-defaults/src/var_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub const NYM_API: &str = "NYM_API";
pub const NYXD_WEBSOCKET: &str = "NYXD_WS";
pub const EXPLORER_API: &str = "EXPLORER_API";
pub const EXIT_POLICY_URL: &str = "EXIT_POLICY";
pub const NYM_VPN_API: &str = "NYM_VPN_API";

pub const DKG_TIME_CONFIGURATION: &str = "DKG_TIME_CONFIGURATION";

Expand Down
1 change: 1 addition & 0 deletions envs/canary.env
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ COCONUT_DKG_CONTRACT_ADDRESS=n1aakfpghcanxtc45gpqlx8j3rq0zcpyf49qmhm9mdjrfx036h4
EXPLORER_API=https://canary-explorer.performance.nymte.ch/api
NYXD="https://canary-validator.performance.nymte.ch"
NYM_API="https://canary-api.performance.nymte.ch/api"
NYM_VPN_API="https://foo/api"
1 change: 1 addition & 0 deletions envs/mainnet.env
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ NYXD="https://rpc.nymtech.net"
NYM_API="https://validator.nymtech.net/api/"
NYXD_WS="wss://rpc.nymtech.net/websocket"
EXPLORER_API="https://explorer.nymtech.net/api/"
NYM_VPN_API="https://nymvpn.com/api"
113 changes: 88 additions & 25 deletions nym-wallet/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions nym-wallet/nym-wallet-types/src/network/qa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ pub(crate) fn network_details() -> nym_network_defaults::NymNetworkDetails {
coconut_dkg_contract_address: parse_optional_str(COCONUT_DKG_CONTRACT_ADDRESS),
},
explorer_api: parse_optional_str(EXPLORER_API),
nym_vpn_api_url: None,
}
}
1 change: 1 addition & 0 deletions nym-wallet/nym-wallet-types/src/network/sandbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ pub(crate) fn network_details() -> nym_network_defaults::NymNetworkDetails {
coconut_dkg_contract_address: parse_optional_str(COCONUT_DKG_CONTRACT_ADDRESS),
},
explorer_api: parse_optional_str(EXPLORER_API),
nym_vpn_api_url: None,
}
}