Skip to content

Commit

Permalink
core: services: change network based on url for wasm target.
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Perchanov <demisrael@gmail.com>
  • Loading branch information
demisrael committed Sep 24, 2024
1 parent 60de7f9 commit 856e079
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion core/src/runtime/services/kaspa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ cfg_if! {
#[cfg(target_arch = "wasm32")]
use wasm_bindgen::prelude::*;
use web_sys::window;
use url::Url;

#[wasm_bindgen]
pub fn get_wrpc_url() -> Option<String> {
Expand Down Expand Up @@ -609,6 +608,12 @@ impl KaspaService {
} else {
self.stop_all_services().await?;

let url = get_wrpc_url().unwrap_or_else(|| "".to_string());
let network = match url.as_str() {
u if u.contains("testnet-10") => Network::Testnet10,
u if u.contains("testnet-11") => Network::Testnet11,
_ => Network::Mainnet,
};
self.handle_network_change(network).await?;

let rpc = Self::create_rpc_client(&rpc_config, network)
Expand Down

0 comments on commit 856e079

Please sign in to comment.