diff --git a/bindings/wasm/CHANGELOG.md b/bindings/wasm/CHANGELOG.md index cfd61b10a2..3ca213d91e 100644 --- a/bindings/wasm/CHANGELOG.md +++ b/bindings/wasm/CHANGELOG.md @@ -19,6 +19,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Security --> +## 1.0.4 - 2023-08-01 + +### Fixed + +- Clients returning the default protocol parameters when multiple Client instances are used; + ## 1.0.3 - 2023-07-31 Same changes as https://github.com/iotaledger/iota-sdk/blob/develop/bindings/nodejs/CHANGELOG.md. diff --git a/bindings/wasm/package.json b/bindings/wasm/package.json index ff18407752..8bfedb80c4 100644 --- a/bindings/wasm/package.json +++ b/bindings/wasm/package.json @@ -1,6 +1,6 @@ { "name": "@iota/sdk-wasm", - "version": "1.0.3", + "version": "1.0.4", "description": "WebAssembly bindings for the IOTA SDK library", "repository": { "type": "git", diff --git a/sdk/src/client/builder.rs b/sdk/src/client/builder.rs index 5a31a0bf0f..576042a576 100644 --- a/sdk/src/client/builder.rs +++ b/sdk/src/client/builder.rs @@ -310,6 +310,7 @@ impl ClientBuilder { sender: RwLock::new(mqtt_event_tx), receiver: RwLock::new(mqtt_event_rx), }, + last_sync: tokio::sync::Mutex::new(None), }), }; diff --git a/sdk/src/client/core.rs b/sdk/src/client/core.rs index f50f59590e..fb34c5764c 100644 --- a/sdk/src/client/core.rs +++ b/sdk/src/client/core.rs @@ -54,6 +54,8 @@ pub struct ClientInner { pub(crate) pow_worker_count: RwLock>, #[cfg(feature = "mqtt")] pub(crate) mqtt: MqttInner, + #[cfg(target_family = "wasm")] + pub(crate) last_sync: tokio::sync::Mutex>, } #[derive(Default)] @@ -104,11 +106,8 @@ impl ClientInner { // create invalid transactions/blocks. #[cfg(target_family = "wasm")] { - lazy_static::lazy_static! { - static ref LAST_SYNC: std::sync::Mutex> = std::sync::Mutex::new(None); - }; let current_time = crate::utils::unix_timestamp_now().as_secs() as u32; - if let Some(last_sync) = *LAST_SYNC.lock().unwrap() { + if let Some(last_sync) = *self.last_sync.lock().await { if current_time < last_sync { return Ok(self.network_info.read().await.clone()); } @@ -116,8 +115,7 @@ impl ClientInner { let info = self.get_info().await?.node_info; let mut client_network_info = self.network_info.write().await; client_network_info.protocol_parameters = info.protocol.clone(); - - *LAST_SYNC.lock().unwrap() = Some(current_time + CACHE_NETWORK_INFO_TIMEOUT_IN_SECONDS); + *self.last_sync.lock().await = Some(current_time + CACHE_NETWORK_INFO_TIMEOUT_IN_SECONDS); } Ok(self.network_info.read().await.clone())