Skip to content

Commit

Permalink
refactor(profit): Simplified debug assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
KirilMihaylov committed Jun 8, 2023
1 parent 40b61d5 commit d9d10ac
Showing 1 changed file with 3 additions and 35 deletions.
38 changes: 3 additions & 35 deletions contracts/profit/src/state/buy_back.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,9 @@ impl BuyBack {
coins: Vec<CoinDTO<PaymentGroup>>,
) -> Self {
debug_assert!(
coins.iter().all(|coin_dto: &CoinDTO<PaymentGroup>| {
<
currency::non_native_payment::NonNativePaymentGroup as finance::currency::Group
>::maybe_visit_on_ticker(
coin_dto.ticker(),
BlankVisitor
)
.is_ok()
}),
coins
.iter()
.all(|coin_dto: &CoinDTO<PaymentGroup>| coin_dto.ticker() != Nls::TICKER),
"{:?}",
coins
);
Expand Down Expand Up @@ -176,29 +170,3 @@ where
}

impl<I> TryFind for I where I: Iterator + ?Sized {}

#[cfg(debug_assertions)]
#[derive(Debug)]
struct BlankVisitor;

#[cfg(debug_assertions)]
mod blank_visitor_impl {
use serde::{de::DeserializeOwned, Serialize};

use finance::currency::{AnyVisitor, AnyVisitorResult, Currency};
use platform::never::Never;

use super::BlankVisitor;

impl AnyVisitor for BlankVisitor {
type Output = ();
type Error = Never;

fn on<C>(self) -> AnyVisitorResult<Self>
where
C: Currency + Serialize + DeserializeOwned,
{
Ok(())
}
}
}

0 comments on commit d9d10ac

Please sign in to comment.