From cf3957c52627fffd5d9ba0a8996d1bb639b2e7d1 Mon Sep 17 00:00:00 2001 From: Dario Anongba Varela Date: Fri, 6 Dec 2024 16:20:40 +0100 Subject: [PATCH] small changes --- .gitignore | 3 ++- Cargo.toml | 8 +++----- src/bitcoin/esplora_wallet.rs | 4 ++-- src/bitcoin/snap_wallet.rs | 4 ++-- src/storage/snap_persister.rs | 4 ++-- src/types/error.rs | 8 ++++---- src/types/mod.rs | 4 ++-- src/types/network.rs | 4 ++-- src/types/{slip_10.rs => slip10.rs} | 0 9 files changed, 19 insertions(+), 20 deletions(-) rename src/types/{slip_10.rs => slip10.rs} (100%) diff --git a/.gitignore b/.gitignore index cfd8b1e..dc0077c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,8 @@ Cargo.lock /.vscode .idea *.swp -.cargo +/.cargo +.npmrc bin/ pkg/ diff --git a/Cargo.toml b/Cargo.toml index 176fdc4..99e2508 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,8 +43,8 @@ getrandom = { version = "0.2.15", features = ["js"] } ring = { version = "0.17.8", features = ["wasm32_unknown_unknown_js"] } # Bitcoin dependencies -bdk_wallet = { git = "https://github.com/bitcoindevkit/bdk", branch = "master" } -bdk_esplora = { git = "https://github.com/bitcoindevkit/bdk", branch = "master", default-features = false, features = [ +bdk_wallet = { version = "1.0.0-beta.5" } +bdk_esplora = { version = "0.19", default-features = false, features = [ "async-https", ], optional = true } bitcoin = { version = "0.32.4", default-features = false } @@ -57,9 +57,7 @@ console_error_panic_hook = { version = "0.1.7", optional = true } [dev-dependencies] wasm-bindgen-test = "0.3.45" web-sys = { version = "0.3.72", features = ["console"] } -bdk_wallet = { git = "https://github.com/bitcoindevkit/bdk", branch = "master", features = [ - "keys-bip39", -] } +bdk_wallet = { version = "1.0.0-beta.5", features = ["keys-bip39"] } [profile.release] # Tell `rustc` to optimize for small code size. diff --git a/src/bitcoin/esplora_wallet.rs b/src/bitcoin/esplora_wallet.rs index 0ed66c0..2a6b488 100644 --- a/src/bitcoin/esplora_wallet.rs +++ b/src/bitcoin/esplora_wallet.rs @@ -124,7 +124,7 @@ impl EsploraWallet { .await?; let now = (Date::now() / 1000.0) as u64; - self.wallet.apply_update_at(update, now)?; + self.wallet.apply_update_at(update, Some(now))?; Ok(()) } @@ -134,7 +134,7 @@ impl EsploraWallet { let update = self.client.sync(request, parallel_requests).await?; let now = (Date::now() / 1000.0) as u64; - self.wallet.apply_update_at(update, now)?; + self.wallet.apply_update_at(update, Some(now))?; Ok(()) } diff --git a/src/bitcoin/snap_wallet.rs b/src/bitcoin/snap_wallet.rs index 932af70..5ee27c7 100644 --- a/src/bitcoin/snap_wallet.rs +++ b/src/bitcoin/snap_wallet.rs @@ -134,7 +134,7 @@ impl SnapWallet { .await?; let now = (Date::now() / 1000.0) as u64; - self.wallet.apply_update_at(update, now)?; + self.wallet.apply_update_at(update, Some(now))?; Ok(()) } @@ -144,7 +144,7 @@ impl SnapWallet { let update = self.client.sync(request, parallel_requests).await?; let now = (Date::now() / 1000.0) as u64; - self.wallet.apply_update_at(update, now)?; + self.wallet.apply_update_at(update, Some(now))?; Ok(()) } diff --git a/src/storage/snap_persister.rs b/src/storage/snap_persister.rs index 50a7b2c..6eb507c 100644 --- a/src/storage/snap_persister.rs +++ b/src/storage/snap_persister.rs @@ -34,7 +34,7 @@ impl SnapPersister { let mut changeset = self.extract_changeset(&state)?; changeset.merge(new_changeset.clone()); - let state_bytes = rmp_serde::to_vec(&changeset).map_err(SnapPersisterError::EncodeMRP)?; + let state_bytes = rmp_serde::to_vec(&changeset).map_err(SnapPersisterError::EncodeMP)?; let state_b64 = BASE64_STANDARD.encode(&state_bytes); state.insert(self.key.clone(), state_b64); @@ -80,7 +80,7 @@ impl SnapPersister { let state_bytes = BASE64_STANDARD .decode(state_b64) .map_err(SnapPersisterError::DecodeBase64)?; - rmp_serde::from_slice(&state_bytes).map_err(SnapPersisterError::DecodeMRP) + rmp_serde::from_slice(&state_bytes).map_err(SnapPersisterError::DecodeMP) } else { Ok(ChangeSet::default()) } diff --git a/src/types/error.rs b/src/types/error.rs index 44d8a13..1828ece 100644 --- a/src/types/error.rs +++ b/src/types/error.rs @@ -9,10 +9,10 @@ pub enum SnapPersisterError { ReadSnapState(JsValue), #[error("Failed to write snap state: {:?}", 0)] WriteSnapState(JsValue), - #[error("Failed to encode MRP: {0}")] - EncodeMRP(#[source] rmp_serde::encode::Error), - #[error("Failed to decode RMP: {0}")] - DecodeMRP(#[source] rmp_serde::decode::Error), + #[error("Failed to encode MessagePack: {0}")] + EncodeMP(#[source] rmp_serde::encode::Error), + #[error("Failed to decode MessagePack: {0}")] + DecodeMP(#[source] rmp_serde::decode::Error), #[error("Failed to decode base64: {0}")] DecodeBase64(#[source] bitcoin::base64::DecodeError), #[error("Failed to deserialize: {0}")] diff --git a/src/types/mod.rs b/src/types/mod.rs index 983d19f..448b19c 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -4,7 +4,7 @@ mod descriptor; mod error; mod keychain; mod network; -mod slip_10; +mod slip10; pub use address::*; pub use balance::*; @@ -12,4 +12,4 @@ pub use descriptor::*; pub use error::*; pub use keychain::*; pub use network::*; -pub use slip_10::*; +pub use slip10::*; diff --git a/src/types/network.rs b/src/types/network.rs index 81aacb7..8c08f33 100644 --- a/src/types/network.rs +++ b/src/types/network.rs @@ -1,9 +1,9 @@ use bitcoin::{Network as BdkNetwork, NetworkKind}; -use wasm_bindgen::prelude::wasm_bindgen; +use wasm_bindgen::prelude::*; /// The cryptocurrency network to act on. #[wasm_bindgen] -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Clone, Copy)] pub enum Network { /// Mainnet Bitcoin. Bitcoin, diff --git a/src/types/slip_10.rs b/src/types/slip10.rs similarity index 100% rename from src/types/slip_10.rs rename to src/types/slip10.rs