28
28
Deserialize ,
29
29
Serialize ,
30
30
} ,
31
+ std:: {
32
+ collections:: BTreeMap ,
33
+ fmt:: {
34
+ Display ,
35
+ Formatter ,
36
+ Result as FmtResult ,
37
+ } ,
38
+ } ,
31
39
utoipa:: ToSchema ,
32
40
wormhole_sdk:: Chain ,
33
41
} ;
@@ -52,7 +60,7 @@ impl From<PriceIdInput> for PriceIdentifier {
52
60
53
61
type Base64String = String ;
54
62
55
- #[ derive( Debug , Clone , serde :: Serialize , serde :: Deserialize , ToSchema ) ]
63
+ #[ derive( Debug , Clone , Serialize , Deserialize , ToSchema ) ]
56
64
pub struct RpcPriceFeedMetadata {
57
65
#[ schema( value_type = Option <u64 >, example=85480034 ) ]
58
66
pub slot : Option < Slot > ,
@@ -64,7 +72,7 @@ pub struct RpcPriceFeedMetadata {
64
72
pub prev_publish_time : Option < UnixTimestamp > ,
65
73
}
66
74
67
- #[ derive( Debug , Clone , serde :: Serialize , serde :: Deserialize , ToSchema ) ]
75
+ #[ derive( Debug , Clone , Serialize , Deserialize , ToSchema ) ]
68
76
pub struct RpcPriceFeedMetadataV2 {
69
77
#[ schema( value_type = Option <u64 >, example=85480034 ) ]
70
78
pub slot : Option < Slot > ,
@@ -74,7 +82,7 @@ pub struct RpcPriceFeedMetadataV2 {
74
82
pub prev_publish_time : Option < UnixTimestamp > ,
75
83
}
76
84
77
- #[ derive( Debug , Clone , serde :: Serialize , serde :: Deserialize , ToSchema ) ]
85
+ #[ derive( Debug , Clone , Serialize , Deserialize , ToSchema ) ]
78
86
pub struct RpcPriceFeed {
79
87
pub id : RpcPriceIdentifier ,
80
88
pub price : RpcPrice ,
@@ -142,8 +150,8 @@ impl RpcPriceFeed {
142
150
Eq ,
143
151
BorshSerialize ,
144
152
BorshDeserialize ,
145
- serde :: Serialize ,
146
- serde :: Deserialize ,
153
+ Serialize ,
154
+ Deserialize ,
147
155
ToSchema ,
148
156
) ]
149
157
pub struct RpcPrice {
@@ -178,8 +186,8 @@ pub struct RpcPrice {
178
186
Hash ,
179
187
BorshSerialize ,
180
188
BorshDeserialize ,
181
- serde :: Serialize ,
182
- serde :: Deserialize ,
189
+ Serialize ,
190
+ Deserialize ,
183
191
ToSchema ,
184
192
) ]
185
193
#[ repr( C ) ]
@@ -204,7 +212,7 @@ impl From<PriceIdentifier> for RpcPriceIdentifier {
204
212
}
205
213
}
206
214
207
- #[ derive( Clone , Copy , Debug , Default , serde :: Deserialize , serde :: Serialize , ToSchema ) ]
215
+ #[ derive( Clone , Copy , Debug , Default , Deserialize , Serialize , ToSchema ) ]
208
216
pub enum EncodingType {
209
217
#[ default]
210
218
#[ serde( rename = "hex" ) ]
@@ -222,13 +230,13 @@ impl EncodingType {
222
230
}
223
231
}
224
232
225
- #[ derive( Debug , Clone , serde :: Serialize , serde :: Deserialize , ToSchema ) ]
233
+ #[ derive( Debug , Clone , Serialize , Deserialize , ToSchema ) ]
226
234
pub struct BinaryPriceUpdate {
227
235
pub encoding : EncodingType ,
228
236
pub data : Vec < String > ,
229
237
}
230
238
231
- #[ derive( Debug , Clone , serde :: Serialize , serde :: Deserialize , ToSchema ) ]
239
+ #[ derive( Debug , Clone , Serialize , Deserialize , ToSchema ) ]
232
240
pub struct ParsedPriceUpdate {
233
241
pub id : RpcPriceIdentifier ,
234
242
pub price : RpcPrice ,
@@ -263,7 +271,7 @@ impl From<PriceFeedUpdate> for ParsedPriceUpdate {
263
271
}
264
272
}
265
273
266
- #[ derive( Debug , Clone , serde :: Serialize , serde :: Deserialize , ToSchema ) ]
274
+ #[ derive( Debug , Clone , Serialize , Deserialize , ToSchema ) ]
267
275
pub struct PriceUpdate {
268
276
pub binary : BinaryPriceUpdate ,
269
277
#[ serde( skip_serializing_if = "Option::is_none" ) ]
@@ -316,3 +324,27 @@ impl TryFrom<PriceUpdate> for PriceFeedsWithUpdateData {
316
324
} )
317
325
}
318
326
}
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