From fa09d920811c07fbf8dd3fca8d42c55a82151b65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Wed, 10 Jul 2024 17:15:21 +0300 Subject: [PATCH] Remove aggregator_proxy.rs --- .../src/aggregator_proxy.rs | 41 ------------------- common/fee-estimator-module/src/lib.rs | 21 +++++++--- 2 files changed, 16 insertions(+), 46 deletions(-) delete mode 100644 common/fee-estimator-module/src/aggregator_proxy.rs diff --git a/common/fee-estimator-module/src/aggregator_proxy.rs b/common/fee-estimator-module/src/aggregator_proxy.rs deleted file mode 100644 index 0db95b13..00000000 --- a/common/fee-estimator-module/src/aggregator_proxy.rs +++ /dev/null @@ -1,41 +0,0 @@ -use multiversx_sc::imports::*; - -pub const GWEI_STRING: &[u8] = b"GWEI"; - -pub type AggregatorResultAsMultiValue = - MultiValue6, ManagedBuffer, u64, BigUint, u8>; - -#[multiversx_sc::proxy] -pub trait Aggregator { - #[view(latestPriceFeedOptional)] - fn latest_price_feed_optional( - &self, - from: ManagedBuffer, - to: ManagedBuffer, - ) -> OptionalValue>; -} - -pub struct AggregatorResult { - pub round_id: u32, - pub from_token_name: ManagedBuffer, - pub to_token_name: ManagedBuffer, - pub timestamp: u64, - pub price: BigUint, - pub decimals: u8, -} - -impl From> for AggregatorResult { - fn from(multi_result: AggregatorResultAsMultiValue) -> Self { - let (round_id, from_token_name, to_token_name, timestamp, price, decimals) = - multi_result.into_tuple(); - - AggregatorResult { - round_id, - from_token_name, - to_token_name, - timestamp, - price, - decimals, - } - } -} diff --git a/common/fee-estimator-module/src/lib.rs b/common/fee-estimator-module/src/lib.rs index 3b82df30..4a02a865 100644 --- a/common/fee-estimator-module/src/lib.rs +++ b/common/fee-estimator-module/src/lib.rs @@ -1,11 +1,10 @@ #![no_std] use multiversx_sc::imports::*; - -mod aggregator_proxy; -pub use aggregator_proxy::*; mod price_aggregator_proxy; +pub const GWEI_STRING: &[u8] = b"GWEI"; + #[multiversx_sc::module] pub trait FeeEstimatorModule { #[only_owner] @@ -68,7 +67,19 @@ pub trait FeeEstimatorModule { let from_ticker = self.token_ticker(from).get(); let to_ticker = self.token_ticker(to).get(); - let result: OptionalValue> = self + // let result: OptionalValue> = self + // .tx() + // .to(fee_estimator_sc_address) + // .typed(price_aggregator_proxy::PriceAggregatorProxy) + // .latest_price_feed_optional(from_ticker, to_ticker) + // .returns(ReturnsResult) + // .sync_call(); + + // result + // .into_option() + // .map(|multi_result| AggregatorResult::from(multi_result).price) + + let result = self .tx() .to(fee_estimator_sc_address) .typed(price_aggregator_proxy::PriceAggregatorProxy) @@ -78,7 +89,7 @@ pub trait FeeEstimatorModule { result .into_option() - .map(|multi_result| AggregatorResult::from(multi_result).price) + .map(|multi_result| multi_result.into_tuple().4) } // storage