@@ -130,19 +130,15 @@ export class RestAPI {
130130 "/api/latest_vaas" ,
131131 validate ( latestVaasInputSchema ) ,
132132 ( req : Request , res : Response ) => {
133- const priceIds = req . query . ids as string [ ] ;
133+ const priceIds = ( req . query . ids as string [ ] ) . map ( removeLeading0x ) ;
134134
135135 // Multiple price ids might share same vaa, we use sequence number as
136136 // key of a vaa and deduplicate using a map of seqnum to vaa bytes.
137137 const vaaMap = new Map < number , Buffer > ( ) ;
138138
139139 const notFoundIds : string [ ] = [ ] ;
140140
141- for ( let id of priceIds ) {
142- if ( id . startsWith ( "0x" ) ) {
143- id = id . substring ( 2 ) ;
144- }
145-
141+ for ( const id of priceIds ) {
146142 const latestPriceInfo = this . priceFeedVaaInfo . getLatestPriceInfo ( id ) ;
147143
148144 if ( latestPriceInfo === undefined ) {
@@ -181,7 +177,7 @@ export class RestAPI {
181177 "/api/get_vaa" ,
182178 validate ( getVaaInputSchema ) ,
183179 asyncWrapper ( async ( req : Request , res : Response ) => {
184- const priceFeedId = req . query . id as string ;
180+ const priceFeedId = removeLeading0x ( req . query . id as string ) ;
185181 const publishTime = Number ( req . query . publish_time as string ) ;
186182
187183 if (
@@ -275,7 +271,7 @@ export class RestAPI {
275271 "/api/latest_price_feeds" ,
276272 validate ( latestPriceFeedsInputSchema ) ,
277273 ( req : Request , res : Response ) => {
278- const priceIds = req . query . ids as string [ ] ;
274+ const priceIds = ( req . query . ids as string [ ] ) . map ( removeLeading0x ) ;
279275 // verbose is optional, default to false
280276 const verbose = req . query . verbose === "true" ;
281277 // binary is optional, default to false
@@ -285,11 +281,7 @@ export class RestAPI {
285281
286282 const notFoundIds : string [ ] = [ ] ;
287283
288- for ( let id of priceIds ) {
289- if ( id . startsWith ( "0x" ) ) {
290- id = id . substring ( 2 ) ;
291- }
292-
284+ for ( const id of priceIds ) {
293285 const latestPriceInfo = this . priceFeedVaaInfo . getLatestPriceInfo ( id ) ;
294286
295287 if ( latestPriceInfo === undefined ) {
0 commit comments