Skip to content

Commit

Permalink
[r2r] hotfix to disable spv in wasm (#1479)
Browse files Browse the repository at this point in the history
* disable spv in wasm

* set enable_spv_proof to false in wasm

* change seed for solana_prerequisites test to generate a new address with 0 balance
  • Loading branch information
shamardy authored Sep 20, 2022
1 parent 1438bf9 commit 2ec13a6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
6 changes: 3 additions & 3 deletions mm2src/coins/solana/solana_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ fn solana_prerequisites() {
// same test as trustwallet
{
let fin = generate_key_pair_from_seed(
"shoot island position soft burden budget tooth cruel issue economy destroy above".to_string(),
"hood vacant left trim hard mushroom device flavor ask better arrest again".to_string(),
);
let public_address = fin.pubkey().to_string();
let priv_key = &fin.secret().to_bytes()[..].to_base58();
assert_eq!(public_address.len(), 44);
assert_eq!(public_address, "2bUBiBNZyD29gP1oV6de7nxowMLoDBtopMMTGgMvjG5m");
assert_eq!(priv_key, "F6czu7fdefbsCDH52JesQrBSJS5Sz25AkPLWFf8zUWhm");
assert_eq!(public_address, "4rmosKwMH7zeaXGbej1PFybZBUyuUNQLf8RfyzCcYvkx");
assert_eq!(priv_key, "CZtxt17aTfDrJrzwBWdVqcmFwVVptW8EX7RRnth9tT3M");
let client = solana_client::rpc_client::RpcClient::new("https://api.testnet.solana.com/".to_string());
let balance = client.get_balance(&fin.pubkey()).expect("Expect to retrieve balance");
assert_eq!(balance, 0);
Expand Down
15 changes: 14 additions & 1 deletion mm2src/coins/utxo/utxo_builder/utxo_coin_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use common::log::{error, info};
use common::small_rng;
use crypto::{Bip32DerPathError, Bip44DerPathError, Bip44PathToCoin, CryptoCtx, CryptoInitError, HwWalletType};
use derive_more::Display;
use futures::channel::mpsc::{channel, unbounded, Receiver as AsyncReceiver, UnboundedReceiver};
use futures::channel::mpsc::{unbounded, Receiver as AsyncReceiver, UnboundedReceiver};
use futures::compat::Future01CompatExt;
use futures::lock::Mutex as AsyncMutex;
use futures::StreamExt;
Expand All @@ -36,6 +36,7 @@ cfg_native! {
use crate::utxo::coin_daemon_data_dir;
use crate::utxo::rpc_clients::{ConcurrentRequestMap, NativeClient, NativeClientImpl};
use dirs::home_dir;
use futures::channel::mpsc::channel;
use std::path::{Path, PathBuf};
}

Expand Down Expand Up @@ -576,6 +577,18 @@ pub trait UtxoCoinBuilderCommonOps {
#[cfg(not(target_arch = "wasm32"))]
fn tx_cache_path(&self) -> PathBuf { self.ctx().dbdir().join("TX_CACHE") }

// Todo: implement spv for wasm to merge the block_header_status_channel functions
#[cfg(target_arch = "wasm32")]
fn block_header_status_channel(
&self,
) -> (
Option<UtxoSyncStatusLoopHandle>,
Option<AsyncMutex<AsyncReceiver<UtxoSyncStatus>>>,
) {
(None, None)
}

#[cfg(not(target_arch = "wasm32"))]
fn block_header_status_channel(
&self,
) -> (
Expand Down
5 changes: 5 additions & 0 deletions mm2src/coins/utxo/utxo_builder/utxo_conf_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ impl<'a> UtxoConfBuilder<'a> {

fn trezor_coin(&self) -> Option<String> { self.conf["trezor_coin"].as_str().map(|coin| coin.to_string()) }

// Todo: implement spv for wasm
#[cfg(target_arch = "wasm32")]
fn enable_spv_proof(&self) -> bool { false }

#[cfg(not(target_arch = "wasm32"))]
fn enable_spv_proof(&self) -> bool { self.conf["enable_spv_proof"].as_bool().unwrap_or(false) }

fn block_headers_verification_params(&self) -> Option<BlockHeaderVerificationParams> {
Expand Down

0 comments on commit 2ec13a6

Please sign in to comment.