@@ -17,7 +17,8 @@ use crate::{
1717#[ derive( Debug , Clone , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
1818#[ serde( rename_all = "camelCase" ) ]
1919pub struct LatestPriceRequest {
20- pub price_feed_ids : Vec < PriceFeedId > ,
20+ pub price_feed_ids : Option < Vec < PriceFeedId > > ,
21+ pub symbols : Option < Vec < String > > ,
2122 pub properties : Vec < PriceFeedProperty > ,
2223 // "chains" was renamed to "formats". "chains" is still supported for compatibility.
2324 #[ serde( alias = "chains" ) ]
@@ -35,7 +36,9 @@ pub struct LatestPriceRequest {
3536#[ serde( rename_all = "camelCase" ) ]
3637pub struct PriceRequest {
3738 pub timestamp : TimestampUs ,
38- pub price_feed_ids : Vec < PriceFeedId > ,
39+ // Either price feed ids or symbols must be specified.
40+ pub price_feed_ids : Option < Vec < PriceFeedId > > ,
41+ pub symbols : Option < Vec < String > > ,
3942 pub properties : Vec < PriceFeedProperty > ,
4043 pub formats : Vec < Format > ,
4144 #[ serde( default ) ]
@@ -181,7 +184,9 @@ impl<'de> Deserialize<'de> for Channel {
181184#[ derive( Debug , Clone , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
182185#[ serde( rename_all = "camelCase" ) ]
183186pub struct SubscriptionParamsRepr {
184- pub price_feed_ids : Vec < PriceFeedId > ,
187+ // Either price feed ids or symbols must be specified.
188+ pub price_feed_ids : Option < Vec < PriceFeedId > > ,
189+ pub symbols : Option < Vec < String > > ,
185190 pub properties : Vec < PriceFeedProperty > ,
186191 // "chains" was renamed to "formats". "chains" is still supported for compatibility.
187192 #[ serde( alias = "chains" ) ]
@@ -195,8 +200,9 @@ pub struct SubscriptionParamsRepr {
195200 #[ serde( default = "default_parsed" ) ]
196201 pub parsed : bool ,
197202 pub channel : Channel ,
198- #[ serde( default ) ]
199- pub ignore_invalid_feed_ids : bool ,
203+ // "ignoreInvalidFeedIds" was renamed to "ignoreInvalidFeeds". "ignoreInvalidFeedIds" is still supported for compatibility.
204+ #[ serde( default , alias = "ignoreInvalidFeedIds" ) ]
205+ pub ignore_invalid_feeds : bool ,
200206}
201207
202208#[ derive( Debug , Clone , PartialEq , Eq , Hash , Serialize ) ]
@@ -215,12 +221,28 @@ impl<'de> Deserialize<'de> for SubscriptionParams {
215221
216222impl SubscriptionParams {
217223 pub fn new ( value : SubscriptionParamsRepr ) -> Result < Self , & ' static str > {
218- if value. price_feed_ids . is_empty ( ) {
219- return Err ( "no price feed ids specified" ) ;
224+ if value. price_feed_ids . is_none ( ) && value. symbols . is_none ( ) {
225+ return Err ( "either price feed ids or symbols must be specified" ) ;
226+ }
227+
228+ if let Some ( ref ids) = value. price_feed_ids {
229+ if ids. is_empty ( ) {
230+ return Err ( "no price feed ids specified" ) ;
231+ }
232+ if !ids. iter ( ) . all_unique ( ) {
233+ return Err ( "duplicate price feed ids specified" ) ;
234+ }
220235 }
221- if !value. price_feed_ids . iter ( ) . all_unique ( ) {
222- return Err ( "duplicate price feed ids specified" ) ;
236+
237+ if let Some ( ref symbols) = value. symbols {
238+ if symbols. is_empty ( ) {
239+ return Err ( "no symbols specified" ) ;
240+ }
241+ if !symbols. iter ( ) . all_unique ( ) {
242+ return Err ( "duplicate symbols specified" ) ;
243+ }
223244 }
245+
224246 if !value. formats . iter ( ) . all_unique ( ) {
225247 return Err ( "duplicate formats or chains specified" ) ;
226248 }
@@ -442,6 +464,7 @@ pub struct SubscribedResponse {
442464#[ serde( rename_all = "camelCase" ) ]
443465pub struct InvalidFeedSubscriptionDetails {
444466 pub unknown_ids : Vec < PriceFeedId > ,
467+ pub unknown_symbols : Vec < String > ,
445468 pub unsupported_channels : Vec < PriceFeedId > ,
446469 pub unstable : Vec < PriceFeedId > ,
447470}
0 commit comments