Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ec2 committed Sep 16, 2024
1 parent 8da3639 commit 2e10257
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 deletions.
10 changes: 5 additions & 5 deletions examples/message-board-sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ async fn main() {
Network::MainNetwork,
NonZeroU32::try_from(1).unwrap(),
)
.unwrap();
.unwrap();

let s = zcash_keys::encoding::decode_extended_full_viewing_key(
constants::mainnet::HRP_SAPLING_EXTENDED_FULL_VIEWING_KEY,
&SAPLING_EFVK.trim(),
)
.unwrap();
.unwrap();

let ufvk = UnifiedFullViewingKey::from_sapling_extended_full_viewing_key(s).unwrap();
let id = w.import_ufvk(ufvk, Some(2477329)).await.unwrap();
Expand All @@ -67,11 +67,11 @@ async fn main() {
w.sync(|scanned_to, tip| {
println!("Scanned: {}/{}", scanned_to, tip);
})
.await
.unwrap();
.await
.unwrap();

tracing::info!("Syncing complete :)");

let summary = w.get_wallet_summary().unwrap();
tracing::info!("Wallet summary: {:?}", summary);
}
}
13 changes: 4 additions & 9 deletions src/bindgen/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,11 @@ pub struct WebWallet {
}

impl WebWallet {
fn network_from_str (
network: &str
) -> Result<consensus::Network, Error> {
fn network_from_str(network: &str) -> Result<consensus::Network, Error> {
match network {
"main" => Ok(consensus::Network::MainNetwork),
"test" => Ok(consensus::Network::TestNetwork),
_ => {
Err(Error::InvalidNetwork(network.to_string()))
}
_ => Err(Error::InvalidNetwork(network.to_string())),
}
}
}
Expand Down Expand Up @@ -75,7 +71,6 @@ impl WebWallet {
})
}


/// Add a new account to the wallet
///
/// # Arguments
Expand All @@ -99,8 +94,8 @@ impl WebWallet {
key: &str,
birthday_height: Option<u32>,
) -> Result<String, Error> {

let ufvk = UnifiedFullViewingKey::decode(&self.inner.network, key).map_err(Error::KeyParseError)?;
let ufvk = UnifiedFullViewingKey::decode(&self.inner.network, key)
.map_err(Error::KeyParseError)?;

self.inner.import_ufvk(&ufvk, birthday_height).await
}
Expand Down
8 changes: 4 additions & 4 deletions tests/message-board-sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use wasm_bindgen_test::*;
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);

use std::sync::Once;
use webz_core::bindgen::wallet::WebWallet;
use zcash_keys::keys::UnifiedFullViewingKey;
use zcash_primitives::consensus::Network;
use zcash_primitives::constants;
use webz_core::bindgen::wallet::WebWallet;

// Required to initialize the logger and panic hooks only once
static INIT: Once = Once::new();
Expand All @@ -26,7 +26,7 @@ async fn test_message_board() {
constants::mainnet::HRP_SAPLING_EXTENDED_FULL_VIEWING_KEY,
&SAPLING_EFVK.trim(),
)
.unwrap();
.unwrap();

let ufvk = UnifiedFullViewingKey::from_sapling_extended_full_viewing_key(s).unwrap();
let ufvk_str = ufvk.encode(&Network::MainNetwork);
Expand All @@ -38,8 +38,8 @@ async fn test_message_board() {
"scanned_to, tip",
"console.log('Scanned: ', scanned_to, '/', tip)",
))
.await
.unwrap();
.await
.unwrap();
tracing::info!("Syncing complete :)");

let summary = w.get_wallet_summary().unwrap();
Expand Down
1 change: 0 additions & 1 deletion tests/simple-sync-and-send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,3 @@ async fn test_get_and_scan_range() {
let summary = w.get_wallet_summary().unwrap();
tracing::info!("Wallet summary: {:?}", summary);
}

0 comments on commit 2e10257

Please sign in to comment.