@@ -130,19 +130,15 @@ export class RestAPI {
130
130
"/api/latest_vaas" ,
131
131
validate ( latestVaasInputSchema ) ,
132
132
( req : Request , res : Response ) => {
133
- const priceIds = req . query . ids as string [ ] ;
133
+ const priceIds = ( req . query . ids as string [ ] ) . map ( removeLeading0x ) ;
134
134
135
135
// Multiple price ids might share same vaa, we use sequence number as
136
136
// key of a vaa and deduplicate using a map of seqnum to vaa bytes.
137
137
const vaaMap = new Map < number , Buffer > ( ) ;
138
138
139
139
const notFoundIds : string [ ] = [ ] ;
140
140
141
- for ( let id of priceIds ) {
142
- if ( id . startsWith ( "0x" ) ) {
143
- id = id . substring ( 2 ) ;
144
- }
145
-
141
+ for ( const id of priceIds ) {
146
142
const latestPriceInfo = this . priceFeedVaaInfo . getLatestPriceInfo ( id ) ;
147
143
148
144
if ( latestPriceInfo === undefined ) {
@@ -181,7 +177,7 @@ export class RestAPI {
181
177
"/api/get_vaa" ,
182
178
validate ( getVaaInputSchema ) ,
183
179
asyncWrapper ( async ( req : Request , res : Response ) => {
184
- const priceFeedId = req . query . id as string ;
180
+ const priceFeedId = removeLeading0x ( req . query . id as string ) ;
185
181
const publishTime = Number ( req . query . publish_time as string ) ;
186
182
187
183
if (
@@ -275,7 +271,7 @@ export class RestAPI {
275
271
"/api/latest_price_feeds" ,
276
272
validate ( latestPriceFeedsInputSchema ) ,
277
273
( req : Request , res : Response ) => {
278
- const priceIds = req . query . ids as string [ ] ;
274
+ const priceIds = ( req . query . ids as string [ ] ) . map ( removeLeading0x ) ;
279
275
// verbose is optional, default to false
280
276
const verbose = req . query . verbose === "true" ;
281
277
// binary is optional, default to false
@@ -285,11 +281,7 @@ export class RestAPI {
285
281
286
282
const notFoundIds : string [ ] = [ ] ;
287
283
288
- for ( let id of priceIds ) {
289
- if ( id . startsWith ( "0x" ) ) {
290
- id = id . substring ( 2 ) ;
291
- }
292
-
284
+ for ( const id of priceIds ) {
293
285
const latestPriceInfo = this . priceFeedVaaInfo . getLatestPriceInfo ( id ) ;
294
286
295
287
if ( latestPriceInfo === undefined ) {
0 commit comments