@@ -125,6 +125,42 @@ pub async fn latest_price_feeds(
125
125
) )
126
126
}
127
127
128
+ #[ derive( Debug , serde:: Deserialize ) ]
129
+ pub struct GetPriceFeedQueryParams {
130
+ id : PriceIdInput ,
131
+ publish_time : UnixTimestamp ,
132
+ #[ serde( default ) ]
133
+ verbose : bool ,
134
+ #[ serde( default ) ]
135
+ binary : bool ,
136
+ }
137
+
138
+ pub async fn get_price_feed (
139
+ State ( state) : State < super :: State > ,
140
+ QsQuery ( params) : QsQuery < GetPriceFeedQueryParams > ,
141
+ ) -> Result < Json < RpcPriceFeed > , RestError > {
142
+ let price_id: PriceIdentifier = params. id . into ( ) ;
143
+
144
+ let price_feeds_with_update_data = state
145
+ . store
146
+ . get_price_feeds_with_update_data (
147
+ vec ! [ price_id] ,
148
+ RequestTime :: FirstAfter ( params. publish_time ) ,
149
+ )
150
+ . await
151
+ . map_err ( |_| RestError :: UpdateDataNotFound ) ?;
152
+
153
+ Ok ( Json ( RpcPriceFeed :: from_price_feed_update (
154
+ price_feeds_with_update_data
155
+ . price_feeds
156
+ . into_iter ( )
157
+ . next ( )
158
+ . ok_or ( RestError :: UpdateDataNotFound ) ?,
159
+ params. verbose ,
160
+ params. binary ,
161
+ ) ) )
162
+ }
163
+
128
164
#[ derive( Debug , serde:: Deserialize ) ]
129
165
pub struct GetVaaQueryParams {
130
166
id : PriceIdInput ,
@@ -133,9 +169,9 @@ pub struct GetVaaQueryParams {
133
169
134
170
#[ derive( Debug , serde:: Serialize ) ]
135
171
pub struct GetVaaResponse {
136
- pub vaa : String ,
172
+ vaa : String ,
137
173
#[ serde( rename = "publishTime" ) ]
138
- pub publish_time : UnixTimestamp ,
174
+ publish_time : UnixTimestamp ,
139
175
}
140
176
141
177
pub async fn get_vaa (
@@ -228,6 +264,7 @@ pub async fn index() -> impl IntoResponse {
228
264
"/api/price_feed_ids" ,
229
265
"/api/latest_price_feeds?ids[]=<price_feed_id>&ids[]=<price_feed_id_2>&..(&verbose=true)(&binary=true)" ,
230
266
"/api/latest_vaas?ids[]=<price_feed_id>&ids[]=<price_feed_id_2>&..." ,
267
+ "/api/get_price_feed?id=<price_feed_id>&publish_time=<publish_time_in_unix_timestamp>(&verbose=true)(&binary=true)" ,
231
268
"/api/get_vaa?id=<price_feed_id>&publish_time=<publish_time_in_unix_timestamp>" ,
232
269
"/api/get_vaa_ccip?data=<0x<price_feed_id_32_bytes>+<publish_time_unix_timestamp_be_8_bytes>>" ,
233
270
] )
0 commit comments