From bf3885fda4b959e9b6fc08eddcb587750ba30561 Mon Sep 17 00:00:00 2001 From: Marko Bencun Date: Tue, 4 Jun 2024 13:37:31 +0200 Subject: [PATCH] add version() method To retrieve the version that is available even before `deviceInfo()` can be called. --- Cargo.lock | 2 +- Cargo.toml | 2 +- NPM_VERSION | 2 +- sandbox/src/App.tsx | 3 ++- src/lib.rs | 5 +++++ src/wasm/mod.rs | 6 ++++++ 6 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2583523..5b09ee7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -125,7 +125,7 @@ checksum = "98f7eed2b2781a6f0b5c903471d48e15f56fb4e1165df8a9a2337fd1a59d45ea" [[package]] name = "bitbox-api" -version = "0.3.1" +version = "0.4.0" dependencies = [ "async-trait", "base32", diff --git a/Cargo.toml b/Cargo.toml index 7ab4e82..683d4c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bitbox-api" authors = ["Marko Bencun "] -version = "0.3.1" +version = "0.4.0" homepage = "https://bitbox.swiss/" repository = "https://github.com/BitBoxSwiss/bitbox-api-rs/" readme = "README-rust.md" diff --git a/NPM_VERSION b/NPM_VERSION index 60a2d3e..79a2734 100644 --- a/NPM_VERSION +++ b/NPM_VERSION @@ -1 +1 @@ -0.4.0 \ No newline at end of file +0.5.0 \ No newline at end of file diff --git a/sandbox/src/App.tsx b/sandbox/src/App.tsx index 1ccd9b0..ab8108e 100644 --- a/sandbox/src/App.tsx +++ b/sandbox/src/App.tsx @@ -58,7 +58,8 @@ function App() {

BitBox02 sandbox

- Connected product: {bb02.product()} +

Connected product: {bb02.product()}

+

Connected firmware version: {bb02.version()}

 

diff --git a/src/lib.rs b/src/lib.rs index b35a3df..e314b00 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -331,6 +331,11 @@ impl PairedBitBox { self.communication.info.product } + /// Returns the firmware version. + pub fn version(&self) -> &semver::Version { + &self.communication.info.version + } + /// Returns the hex-encoded 4-byte root fingerprint. pub async fn root_fingerprint(&self) -> Result { match self diff --git a/src/wasm/mod.rs b/src/wasm/mod.rs index 7803f0a..da58d44 100644 --- a/src/wasm/mod.rs +++ b/src/wasm/mod.rs @@ -209,6 +209,12 @@ impl PairedBitBox { } } + /// Returns the firmware version, e.g. "9.18.0". + #[wasm_bindgen(js_name = version)] + pub fn version(&self) -> String { + self.device.version().to_string() + } + /// Returns the hex-encoded 4-byte root fingerprint. #[wasm_bindgen(js_name = rootFingerprint)] pub async fn root_fingerprint(&self) -> Result {