From e91e7a1f2cc6b0e829c01590c319dda3d680e3d4 Mon Sep 17 00:00:00 2001 From: Katerina Maneva Date: Thu, 8 Aug 2024 13:25:24 +0300 Subject: [PATCH] chore: merge --- platform/packages/finance/src/error.rs | 16 +--------------- .../oracle/src/contract/alarms/iter.rs | 18 +++++++----------- .../packages/marketprice/src/alarms/mod.rs | 4 ++-- 3 files changed, 10 insertions(+), 28 deletions(-) diff --git a/platform/packages/finance/src/error.rs b/platform/packages/finance/src/error.rs index 5e1fe6ca7..8ce960a4d 100644 --- a/platform/packages/finance/src/error.rs +++ b/platform/packages/finance/src/error.rs @@ -2,7 +2,7 @@ use std::{any::type_name, fmt::Debug}; use thiserror::Error; -use currency::{error::Error as CurrencyError, Currency}; +use currency::error::Error as CurrencyError; use sdk::cosmwasm_std::StdError; use crate::percent::Units as PercentUnits; @@ -54,20 +54,6 @@ impl Error { operand2: operand2.to_string(), } } - - pub fn no_funds() -> Self - where - C: Currency, - { - Self::NoFunds(C::TICKER.into()) - } - - pub fn unexpected_funds() -> Self - where - C: Currency, - { - Self::UnexpectedFunds(C::TICKER.into()) - } } pub type Result = core::result::Result; diff --git a/protocol/contracts/oracle/src/contract/alarms/iter.rs b/protocol/contracts/oracle/src/contract/alarms/iter.rs index 979ce6453..2bb57c916 100644 --- a/protocol/contracts/oracle/src/contract/alarms/iter.rs +++ b/protocol/contracts/oracle/src/contract/alarms/iter.rs @@ -131,17 +131,13 @@ where where C: Currency + MemberOf, { - Price::::try_from(self.price) - .map_err(ContractError::Finance) - .and_then(|price: Price| { - self.alarms - .alarms(price) - .map_err(ContractError::AlarmError) - .map(|alarms_iter| { - alarms_iter.map::, AlarmIterMapFn>( - |result: Result| result.map_err(ContractError::from), - ) - }) + self.alarms + .alarms(price) + .map_err(ContractError::AlarmError) + .map(|alarms_iter| { + alarms_iter.map::, AlarmIterMapFn>( + |result: Result| result.map_err(Into::into), + ) }) } } diff --git a/protocol/packages/marketprice/src/alarms/mod.rs b/protocol/packages/marketprice/src/alarms/mod.rs index bbc6689e0..b022e37a8 100644 --- a/protocol/packages/marketprice/src/alarms/mod.rs +++ b/protocol/packages/marketprice/src/alarms/mod.rs @@ -165,8 +165,8 @@ where { NormalizedPrice::new(&price).map(|norm_price| { AlarmsIterator( - self.iter_below::(&norm_price) - .chain(self.iter_above_or_equal::(&norm_price)), + self.iter_below(&norm_price) + .chain(self.iter_above_or_equal(&norm_price)), ) }) }