2828 Deserialize ,
2929 Serialize ,
3030 } ,
31+ std:: {
32+ collections:: BTreeMap ,
33+ fmt:: {
34+ Display ,
35+ Formatter ,
36+ Result as FmtResult ,
37+ } ,
38+ } ,
3139 utoipa:: ToSchema ,
3240 wormhole_sdk:: Chain ,
3341} ;
@@ -52,7 +60,7 @@ impl From<PriceIdInput> for PriceIdentifier {
5260
5361type Base64String = String ;
5462
55- #[ derive( Debug , Clone , serde :: Serialize , serde :: Deserialize , ToSchema ) ]
63+ #[ derive( Debug , Clone , Serialize , Deserialize , ToSchema ) ]
5664pub struct RpcPriceFeedMetadata {
5765 #[ schema( value_type = Option <u64 >, example=85480034 ) ]
5866 pub slot : Option < Slot > ,
@@ -64,7 +72,7 @@ pub struct RpcPriceFeedMetadata {
6472 pub prev_publish_time : Option < UnixTimestamp > ,
6573}
6674
67- #[ derive( Debug , Clone , serde :: Serialize , serde :: Deserialize , ToSchema ) ]
75+ #[ derive( Debug , Clone , Serialize , Deserialize , ToSchema ) ]
6876pub struct RpcPriceFeedMetadataV2 {
6977 #[ schema( value_type = Option <u64 >, example=85480034 ) ]
7078 pub slot : Option < Slot > ,
@@ -74,7 +82,7 @@ pub struct RpcPriceFeedMetadataV2 {
7482 pub prev_publish_time : Option < UnixTimestamp > ,
7583}
7684
77- #[ derive( Debug , Clone , serde :: Serialize , serde :: Deserialize , ToSchema ) ]
85+ #[ derive( Debug , Clone , Serialize , Deserialize , ToSchema ) ]
7886pub struct RpcPriceFeed {
7987 pub id : RpcPriceIdentifier ,
8088 pub price : RpcPrice ,
@@ -142,8 +150,8 @@ impl RpcPriceFeed {
142150 Eq ,
143151 BorshSerialize ,
144152 BorshDeserialize ,
145- serde :: Serialize ,
146- serde :: Deserialize ,
153+ Serialize ,
154+ Deserialize ,
147155 ToSchema ,
148156) ]
149157pub struct RpcPrice {
@@ -178,8 +186,8 @@ pub struct RpcPrice {
178186 Hash ,
179187 BorshSerialize ,
180188 BorshDeserialize ,
181- serde :: Serialize ,
182- serde :: Deserialize ,
189+ Serialize ,
190+ Deserialize ,
183191 ToSchema ,
184192) ]
185193#[ repr( C ) ]
@@ -204,7 +212,7 @@ impl From<PriceIdentifier> for RpcPriceIdentifier {
204212 }
205213}
206214
207- #[ derive( Clone , Copy , Debug , Default , serde :: Deserialize , serde :: Serialize , ToSchema ) ]
215+ #[ derive( Clone , Copy , Debug , Default , Deserialize , Serialize , ToSchema ) ]
208216pub enum EncodingType {
209217 #[ default]
210218 #[ serde( rename = "hex" ) ]
@@ -222,13 +230,13 @@ impl EncodingType {
222230 }
223231}
224232
225- #[ derive( Debug , Clone , serde :: Serialize , serde :: Deserialize , ToSchema ) ]
233+ #[ derive( Debug , Clone , Serialize , Deserialize , ToSchema ) ]
226234pub struct BinaryPriceUpdate {
227235 pub encoding : EncodingType ,
228236 pub data : Vec < String > ,
229237}
230238
231- #[ derive( Debug , Clone , serde :: Serialize , serde :: Deserialize , ToSchema ) ]
239+ #[ derive( Debug , Clone , Serialize , Deserialize , ToSchema ) ]
232240pub struct ParsedPriceUpdate {
233241 pub id : RpcPriceIdentifier ,
234242 pub price : RpcPrice ,
@@ -263,7 +271,7 @@ impl From<PriceFeedUpdate> for ParsedPriceUpdate {
263271 }
264272}
265273
266- #[ derive( Debug , Clone , serde :: Serialize , serde :: Deserialize , ToSchema ) ]
274+ #[ derive( Debug , Clone , Serialize , Deserialize , ToSchema ) ]
267275pub struct PriceUpdate {
268276 pub binary : BinaryPriceUpdate ,
269277 #[ serde( skip_serializing_if = "Option::is_none" ) ]
@@ -316,3 +324,27 @@ impl TryFrom<PriceUpdate> for PriceFeedsWithUpdateData {
316324 } )
317325 }
318326}
327+
328+ #[ derive( Debug , Clone , Serialize , Deserialize , ToSchema ) ]
329+ pub struct PriceFeedMetadata {
330+ pub id : PriceIdentifier ,
331+ // BTreeMap is used to automatically sort the keys to ensure consistent ordering of attributes in the JSON response.
332+ // This enhances user experience by providing a predictable structure, avoiding confusion from varying orders in different responses.
333+ pub attributes : BTreeMap < String , String > ,
334+ }
335+
336+ #[ derive( Debug , Serialize , Deserialize , PartialEq , ToSchema ) ]
337+ #[ serde( rename_all = "lowercase" ) ]
338+ pub enum AssetType {
339+ Crypto ,
340+ FX ,
341+ Equity ,
342+ Metals ,
343+ Rates ,
344+ }
345+
346+ impl Display for AssetType {
347+ fn fmt ( & self , f : & mut Formatter ) -> FmtResult {
348+ write ! ( f, "{:?}" , self )
349+ }
350+ }
0 commit comments