From 158d4bee07201219231e4b0032afbeedc37d24d4 Mon Sep 17 00:00:00 2001 From: Anton Yemelyanov Date: Sun, 20 Oct 2024 18:08:27 +0300 Subject: [PATCH 1/2] add missing setNetworkId to wasm Wallet() --- rpc/wrpc/wasm/src/client.rs | 4 ++-- wallet/core/src/wasm/wallet/wallet.rs | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/rpc/wrpc/wasm/src/client.rs b/rpc/wrpc/wasm/src/client.rs index ccd9cb284b..63382fcca2 100644 --- a/rpc/wrpc/wasm/src/client.rs +++ b/rpc/wrpc/wasm/src/client.rs @@ -351,8 +351,8 @@ impl RpcClient { /// Set the network id for the RPC client. /// This setting will take effect on the next connection. #[wasm_bindgen(js_name = setNetworkId)] - pub fn set_network_id(&self, network_id: &NetworkId) -> Result<()> { - self.inner.client.set_network_id(network_id)?; + pub fn set_network_id(&self, network_id: &NetworkIdT) -> Result<()> { + self.inner.client.set_network_id(&network_id.try_into_owned()?)?; Ok(()) } diff --git a/wallet/core/src/wasm/wallet/wallet.rs b/wallet/core/src/wasm/wallet/wallet.rs index bd91bedf22..57f5a817f5 100644 --- a/wallet/core/src/wasm/wallet/wallet.rs +++ b/wallet/core/src/wasm/wallet/wallet.rs @@ -3,6 +3,7 @@ use crate::storage::local::interface::LocalStore; use crate::storage::WalletDescriptor; use crate::wallet as native; use crate::wasm::notify::{WalletEventTarget, WalletNotificationCallback, WalletNotificationTypeOrCallback}; +use kaspa_consensus_core::network::NetworkIdT; use kaspa_wallet_macros::declare_typescript_wasm_interface as declare; use kaspa_wasm_core::events::{get_event_targets, Sink}; use kaspa_wrpc_wasm::{IConnectOptions, Resolver, RpcClient, RpcConfig, WrpcEncoding}; @@ -264,6 +265,12 @@ impl Wallet { } Ok(()) } + + #[wasm_bindgen(js_name = "setNetworkId")] + pub fn set_network_id(&self, network_id: NetworkIdT) -> Result<()> { + self.inner.wallet.set_network_id(&network_id.try_into_owned()?)?; + Ok(()) + } } impl Wallet { From 79cebc0be23ee561d9ec4479de8c135ceb215ebb Mon Sep 17 00:00:00 2001 From: Anton Yemelyanov Date: Sun, 20 Oct 2024 18:23:53 +0300 Subject: [PATCH 2/2] rust 1.82 updates --- cli/src/cli.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/src/cli.rs b/cli/src/cli.rs index 5ca1997ea3..a32956740a 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -1016,7 +1016,7 @@ mod panic_handler { fn stack(error: &Error) -> String; } - pub fn process(info: &std::panic::PanicInfo) -> String { + pub fn process(info: &std::panic::PanicHookInfo) -> String { let mut msg = info.to_string(); // Add the error stack to our message. @@ -1053,7 +1053,7 @@ mod panic_handler { impl KaspaCli { pub fn init_panic_hook(self: &Arc) { let this = self.clone(); - let handler = move |info: &std::panic::PanicInfo| { + let handler = move |info: &std::panic::PanicHookInfo| { let msg = panic_handler::process(info); this.term().writeln(msg.crlf()); panic_handler::console_error(msg);