Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use export_to_env from upstream #1775

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
78 changes: 1 addition & 77 deletions nym-vpn-core/crates/nym-vpn-network-config/src/nym_network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl NymNetwork {
}

pub(super) fn export_to_env(&self) {
export_nym_network_details_to_env(self.network.clone())
self.network.clone().export_to_env()
}
}

Expand All @@ -88,82 +88,6 @@ impl From<NymNetworkDetails> for NymNetwork {
}
}

// TODO: move this to the NymNetworkDetails struct in the nym repo
fn export_nym_network_details_to_env(network_details: NymNetworkDetails) {
fn set_optional_var(var_name: &str, value: Option<String>) {
if let Some(value) = value {
env::set_var(var_name, value);
}
}

env::set_var(var_names::NETWORK_NAME, network_details.network_name);
env::set_var(
var_names::BECH32_PREFIX,
network_details.chain_details.bech32_account_prefix,
);

env::set_var(
var_names::MIX_DENOM,
network_details.chain_details.mix_denom.base,
);
env::set_var(
var_names::MIX_DENOM_DISPLAY,
network_details.chain_details.mix_denom.display,
);

env::set_var(
var_names::STAKE_DENOM,
network_details.chain_details.stake_denom.base,
);
env::set_var(
var_names::STAKE_DENOM_DISPLAY,
network_details.chain_details.stake_denom.display,
);

env::set_var(
var_names::DENOMS_EXPONENT,
network_details
.chain_details
.mix_denom
.display_exponent
.to_string(),
);

if let Some(e) = network_details.endpoints.first() {
env::set_var(var_names::NYXD, e.nyxd_url.clone());
set_optional_var(var_names::NYM_API, e.api_url.clone());
set_optional_var(var_names::NYXD_WEBSOCKET, e.websocket_url.clone());
}

set_optional_var(
var_names::MIXNET_CONTRACT_ADDRESS,
network_details.contracts.mixnet_contract_address,
);
set_optional_var(
var_names::VESTING_CONTRACT_ADDRESS,
network_details.contracts.vesting_contract_address,
);
set_optional_var(
var_names::ECASH_CONTRACT_ADDRESS,
network_details.contracts.ecash_contract_address,
);
set_optional_var(
var_names::GROUP_CONTRACT_ADDRESS,
network_details.contracts.group_contract_address,
);
set_optional_var(
var_names::MULTISIG_CONTRACT_ADDRESS,
network_details.contracts.multisig_contract_address,
);
set_optional_var(
var_names::COCONUT_DKG_CONTRACT_ADDRESS,
network_details.contracts.coconut_dkg_contract_address,
);

set_optional_var(var_names::EXPLORER_API, network_details.explorer_api);
set_optional_var(var_names::NYM_VPN_API, network_details.nym_vpn_api_url);
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
Loading