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

[r2r] hotfix to disable spv in wasm #1479

Merged
merged 3 commits into from
Sep 20, 2022
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
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