11use crate :: pyth:: mock:: DecodeDataType ;
22use crate :: pyth:: types:: {
3- getEmaPriceNoOlderThanCall, getEmaPriceUnsafeCall, getPriceNoOlderThanCall,
4- getPriceUnsafeCall , getUpdateFeeCall, getValidTimePeriodCall,
5- parsePriceFeedUpdatesCall , parsePriceFeedUpdatesUniqueCall ,
6- updatePriceFeedsCall , updatePriceFeedsIfNecessaryCall , Price , PriceFeed ,
3+ getEmaPriceNoOlderThanCall, getEmaPriceUnsafeCall, getPriceNoOlderThanCall, getPriceUnsafeCall ,
4+ getUpdateFeeCall, getValidTimePeriodCall, parsePriceFeedUpdatesCall ,
5+ parsePriceFeedUpdatesUniqueCall , updatePriceFeedsCall , updatePriceFeedsIfNecessaryCall , Price ,
6+ PriceFeed ,
77} ;
88use crate :: utils:: { call_helper, delegate_call_helper} ;
99use alloc:: vec:: Vec ;
@@ -27,11 +27,7 @@ pub fn get_price_no_older_than(
2727 id : B256 ,
2828 age : U256 ,
2929) -> Result < Price , Vec < u8 > > {
30- let price_call = call_helper :: < getPriceNoOlderThanCall > (
31- storage,
32- pyth_address,
33- ( id, age) ,
34- ) ?;
30+ let price_call = call_helper :: < getPriceNoOlderThanCall > ( storage, pyth_address, ( id, age) ) ?;
3531 Ok ( price_call. price )
3632}
3733
@@ -49,8 +45,7 @@ pub fn get_update_fee(
4945 pyth_address : Address ,
5046 update_data : Vec < Bytes > ,
5147) -> Result < U256 , Vec < u8 > > {
52- let update_fee_call =
53- call_helper :: < getUpdateFeeCall > ( storage, pyth_address, ( update_data, ) ) ?;
48+ let update_fee_call = call_helper :: < getUpdateFeeCall > ( storage, pyth_address, ( update_data, ) ) ?;
5449 Ok ( update_fee_call. feeAmount )
5550}
5651
@@ -68,8 +63,7 @@ pub fn get_ema_price_unsafe(
6863 pyth_address : Address ,
6964 id : B256 ,
7065) -> Result < Price , Vec < u8 > > {
71- let ema_price =
72- call_helper :: < getEmaPriceUnsafeCall > ( storage, pyth_address, ( id, ) ) ?;
66+ let ema_price = call_helper :: < getEmaPriceUnsafeCall > ( storage, pyth_address, ( id, ) ) ?;
7367 Ok ( ema_price. price )
7468}
7569
@@ -89,11 +83,7 @@ pub fn get_ema_price_no_older_than(
8983 id : B256 ,
9084 age : U256 ,
9185) -> Result < Price , Vec < u8 > > {
92- let ema_price = call_helper :: < getEmaPriceNoOlderThanCall > (
93- storage,
94- pyth_address,
95- ( id, age) ,
96- ) ?;
86+ let ema_price = call_helper :: < getEmaPriceNoOlderThanCall > ( storage, pyth_address, ( id, age) ) ?;
9787 Ok ( ema_price. price )
9888}
9989
@@ -111,8 +101,7 @@ pub fn get_price_unsafe(
111101 pyth_address : Address ,
112102 id : B256 ,
113103) -> Result < Price , Vec < u8 > > {
114- let price =
115- call_helper :: < getPriceUnsafeCall > ( storage, pyth_address, ( id, ) ) ?;
104+ let price = call_helper :: < getPriceUnsafeCall > ( storage, pyth_address, ( id, ) ) ?;
116105 let price = Price {
117106 price : price. _0 ,
118107 conf : price. _1 ,
@@ -134,8 +123,7 @@ pub fn get_valid_time_period(
134123 storage : & mut impl TopLevelStorage ,
135124 pyth_address : Address ,
136125) -> Result < U256 , Vec < u8 > > {
137- let valid_time_period =
138- call_helper :: < getValidTimePeriodCall > ( storage, pyth_address, ( ) ) ?;
126+ let valid_time_period = call_helper :: < getValidTimePeriodCall > ( storage, pyth_address, ( ) ) ?;
139127 Ok ( valid_time_period. validTimePeriod )
140128}
141129
@@ -153,11 +141,7 @@ pub fn update_price_feeds(
153141 pyth_address : Address ,
154142 update_data : Vec < Bytes > ,
155143) -> Result < ( ) , Vec < u8 > > {
156- delegate_call_helper :: < updatePriceFeedsCall > (
157- storage,
158- pyth_address,
159- ( update_data, ) ,
160- ) ?;
144+ delegate_call_helper :: < updatePriceFeedsCall > ( storage, pyth_address, ( update_data, ) ) ?;
161145 Ok ( ( ) )
162146}
163147
@@ -207,12 +191,11 @@ pub fn parse_price_feed_updates(
207191 min_publish_time : u64 ,
208192 max_publish_time : u64 ,
209193) -> Result < Vec < PriceFeed > , Vec < u8 > > {
210- let parse_price_feed_updates_call =
211- delegate_call_helper :: < parsePriceFeedUpdatesCall > (
212- storage,
213- pyth_address,
214- ( update_data, price_ids, min_publish_time, max_publish_time) ,
215- ) ?;
194+ let parse_price_feed_updates_call = delegate_call_helper :: < parsePriceFeedUpdatesCall > (
195+ storage,
196+ pyth_address,
197+ ( update_data, price_ids, min_publish_time, max_publish_time) ,
198+ ) ?;
216199 Ok ( parse_price_feed_updates_call. priceFeeds )
217200}
218201
@@ -236,12 +219,11 @@ pub fn parse_price_feed_updates_unique(
236219 min_publish_time : u64 ,
237220 max_publish_time : u64 ,
238221) -> Result < Vec < PriceFeed > , Vec < u8 > > {
239- let parse_price_feed_updates_call =
240- delegate_call_helper :: < parsePriceFeedUpdatesUniqueCall > (
241- storage,
242- pyth_address,
243- ( update_data, price_ids, min_publish_time, max_publish_time) ,
244- ) ?;
222+ let parse_price_feed_updates_call = delegate_call_helper :: < parsePriceFeedUpdatesUniqueCall > (
223+ storage,
224+ pyth_address,
225+ ( update_data, price_ids, min_publish_time, max_publish_time) ,
226+ ) ?;
245227 Ok ( parse_price_feed_updates_call. priceFeeds )
246228}
247229
@@ -270,11 +252,24 @@ pub fn create_price_feed_update_data(
270252 publish_time : U256 ,
271253 prev_publish_time : u64 ,
272254) -> Vec < u8 > {
273- let price = Price { price, conf, expo, publish_time } ;
274- let ema_price =
275- Price { price : ema_price, conf : ema_conf, expo, publish_time } ;
255+ let price = Price {
256+ price,
257+ conf,
258+ expo,
259+ publish_time,
260+ } ;
261+ let ema_price = Price {
262+ price : ema_price,
263+ conf : ema_conf,
264+ expo,
265+ publish_time,
266+ } ;
276267
277- let price_feed_data = PriceFeed { id, price, ema_price } ;
268+ let price_feed_data = PriceFeed {
269+ id,
270+ price,
271+ ema_price,
272+ } ;
278273
279274 let price_feed_data_encoding = ( price_feed_data, prev_publish_time) ;
280275 return DecodeDataType :: abi_encode ( & price_feed_data_encoding) ;
0 commit comments