Skip to content
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
9 changes: 6 additions & 3 deletions mm2src/coins/tendermint/tendermint_coin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ pub struct TendermintCoinImpl {
/// My address
pub account_id: AccountId,
pub(super) account_prefix: String,
pub(super) activation_policy: TendermintActivationPolicy,
pub activation_policy: TendermintActivationPolicy,
pub(crate) decimals: u8,
pub(super) denom: Denom,
chain_id: ChainId,
Expand Down Expand Up @@ -439,8 +439,6 @@ pub enum TendermintInitErrorKind {
#[display(fmt = "avg_blocktime must be in-between '0' and '255'.")]
AvgBlockTimeInvalid,
BalanceStreamInitError(String),
#[display(fmt = "Watcher features can not be used with pubkey-only activation policy.")]
CantUseWatchersWithPubkeyPolicy,
}

/// TODO: Rename this into `ClientRpcError` because this is very
Expand Down Expand Up @@ -3562,6 +3560,11 @@ impl SwapOps for TendermintCoin {
.await
}

// TODO: release this function once watchers are supported
// fn is_supported_by_watchers(&self) -> bool {
// !matches!(self.activation_policy, TendermintActivationPolicy::PublicKey(_))
// }

async fn send_maker_spends_taker_payment(
&self,
maker_spends_payment_args: SpendPaymentArgs<'_>,
Expand Down
15 changes: 5 additions & 10 deletions mm2src/coins_activation/src/tendermint_with_assets_activation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,6 @@ impl PlatformCoinWithTokensActivationOps for TendermintCoin {
let is_keplr_from_ledger = activation_request.is_keplr_from_ledger && activation_request.with_pubkey.is_some();

let activation_policy = if let Some(pubkey) = activation_request.with_pubkey {
if ctx.is_watcher() || ctx.use_watchers() {
return MmError::err(TendermintInitError {
ticker: ticker.clone(),
kind: TendermintInitErrorKind::CantUseWatchersWithPubkeyPolicy,
});
}

TendermintActivationPolicy::with_public_key(pubkey)
} else {
let private_key_policy =
Expand All @@ -270,17 +263,19 @@ impl PlatformCoinWithTokensActivationOps for TendermintCoin {
TendermintActivationPolicy::with_private_key_policy(tendermint_private_key_policy)
};

TendermintCoin::init(
let coin = TendermintCoin::init(
&ctx,
ticker,
ticker.clone(),
conf,
protocol_conf,
activation_request.nodes,
activation_request.tx_history,
activation_policy,
is_keplr_from_ledger,
)
.await
.await?;

Ok(coin)
}

async fn enable_global_nft(
Expand Down
4 changes: 2 additions & 2 deletions mm2src/mm2_core/src/mm_ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,9 @@ impl MmCtx {
Ok(connection)
}

pub fn is_watcher(&self) -> bool { self.conf["is_watcher"].as_bool().unwrap_or_default() }
pub fn is_watcher(&self) -> bool { self.conf["is_watcher"].as_bool().unwrap_or(false) }

pub fn use_watchers(&self) -> bool { self.conf["use_watchers"].as_bool().unwrap_or(true) }
pub fn disable_watchers_globally(&self) -> bool { !self.conf["use_watchers"].as_bool().unwrap_or(true) }

pub fn netid(&self) -> u16 {
let netid = self.conf["netid"].as_u64().unwrap_or(0);
Expand Down
6 changes: 3 additions & 3 deletions mm2src/mm2_main/src/lp_swap/taker_swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ async fn save_my_taker_swap_event(ctx: &MmArc, swap: &TakerSwap, event: TakerSav
gui: ctx.gui().map(|g| g.to_owned()),
mm_version: Some(ctx.mm_version.to_owned()),
events: vec![],
success_events: if ctx.use_watchers()
success_events: if !ctx.disable_watchers_globally()
&& swap.taker_coin.is_supported_by_watchers()
&& swap.maker_coin.is_supported_by_watchers()
{
Expand Down Expand Up @@ -1590,7 +1590,7 @@ impl TakerSwap {
/// The preimages allow watchers to either complete the swap by spending the maker payment
/// or refund the taker payment if needed.
async fn process_watcher_logic(&self, transaction: &TransactionEnum) -> Option<TakerSwapEvent> {
let watchers_enabled_and_supported = self.ctx.use_watchers()
let watchers_enabled_and_supported = !self.ctx.disable_watchers_globally()
&& self.taker_coin.is_supported_by_watchers()
&& self.maker_coin.is_supported_by_watchers();

Expand Down Expand Up @@ -1774,7 +1774,7 @@ impl TakerSwap {
let mut watcher_broadcast_abort_handle = None;
// Watchers cannot be used for lightning swaps for now
// Todo: Check if watchers can work in some cases with lightning and implement it if it's possible, this part will probably work if only the taker is lightning since the preimage is available
if self.ctx.use_watchers()
if !self.ctx.disable_watchers_globally()
&& self.taker_coin.is_supported_by_watchers()
&& self.maker_coin.is_supported_by_watchers()
{
Expand Down
Loading