Skip to content

Commit

Permalink
small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
darioAnongba committed Dec 6, 2024
1 parent f32e629 commit cf3957c
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Cargo.lock
/.vscode
.idea
*.swp
.cargo
/.cargo
.npmrc

bin/
pkg/
Expand Down
8 changes: 3 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/bitcoin/esplora_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand All @@ -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(())
}
Expand Down
4 changes: 2 additions & 2 deletions src/bitcoin/snap_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand All @@ -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(())
}
Expand Down
4 changes: 2 additions & 2 deletions src/storage/snap_persister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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())
}
Expand Down
8 changes: 4 additions & 4 deletions src/types/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}")]
Expand Down
4 changes: 2 additions & 2 deletions src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ mod descriptor;
mod error;
mod keychain;
mod network;
mod slip_10;
mod slip10;

pub use address::*;
pub use balance::*;
pub use descriptor::*;
pub use error::*;
pub use keychain::*;
pub use network::*;
pub use slip_10::*;
pub use slip10::*;
4 changes: 2 additions & 2 deletions src/types/network.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
File renamed without changes.

0 comments on commit cf3957c

Please sign in to comment.