Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add version() method #71

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "bitbox-api"
authors = ["Marko Bencun <[email protected]>"]
version = "0.3.1"
version = "0.4.0"
homepage = "https://bitbox.swiss/"
repository = "https://github.com/BitBoxSwiss/bitbox-api-rs/"
readme = "README-rust.md"
Expand Down
2 changes: 1 addition & 1 deletion NPM_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.0
0.5.0
3 changes: 2 additions & 1 deletion sandbox/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ function App() {
<div className="contentContainer">
<h2 style={{textAlign: 'left'}}>BitBox02 sandbox</h2>
<h4 style={{textAlign: 'left'}}>
Connected product: {bb02.product()}
<p>Connected product: {bb02.product()}</p>
<p>Connected firmware version: {bb02.version()}</p>
&nbsp;
<button onClick={() => bb02.close()}>Close connection</button>
</h4>
Expand Down
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,11 @@ impl<R: Runtime> PairedBitBox<R> {
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<String, Error> {
match self
Expand Down
6 changes: 6 additions & 0 deletions src/wasm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, JavascriptError> {
Expand Down
Loading