diff --git a/core/src/runtime/services/kaspa/mod.rs b/core/src/runtime/services/kaspa/mod.rs index 383d66f..2308681 100644 --- a/core/src/runtime/services/kaspa/mod.rs +++ b/core/src/runtime/services/kaspa/mod.rs @@ -187,7 +187,7 @@ impl KaspaService { encoding, resolver_urls, } => { - let mut resolver_or_none = match url { + let resolver_or_none = match url { Some(_) => None, None => { if resolver_urls.is_none() { @@ -198,13 +198,7 @@ impl KaspaService { } }; - let wrpc_url = get_wrpc_url().unwrap_or_else(|| "".to_string()); - let url = if !wrpc_url.is_empty() { - resolver_or_none = None; - wrpc_url.clone() - } else { - url.clone().unwrap_or_else(|| "127.0.0.1".to_string()) - }; + let url = url.clone().unwrap_or_else(|| "127.0.0.1".to_string()); let url = KaspaRpcClient::parse_url(url, *encoding, NetworkId::from(network).into())?; @@ -608,14 +602,27 @@ impl KaspaService { } else { self.stop_all_services().await?; + #[cfg(not(target_arch = "wasm32"))] + let url = "".to_string(); + #[cfg(target_arch = "wasm32")] 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, + _ => network, }; + self.handle_network_change(network).await?; + let rpc_config = if url.is_empty() { + rpc_config.clone() + } else { + RpcConfig::Wrpc { + url: url.into(), + encoding: WrpcEncoding::Borsh, + resolver_urls: None, + } + }; let rpc = Self::create_rpc_client(&rpc_config, network) .expect("Kaspad Service - unable to create wRPC client"); self.start_all_services(Some(rpc), network).await?;