Skip to content

Commit e4963f4

Browse files
authored
[price-service] Hotfix leading 0x problem (#507)
1 parent 0eac724 commit e4963f4

File tree

3 files changed

+8
-16
lines changed

3 files changed

+8
-16
lines changed

price-service/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

price-service/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pythnetwork/pyth-price-service",
3-
"version": "2.3.1",
3+
"version": "2.3.2",
44
"description": "Pyth Price Service",
55
"main": "index.js",
66
"scripts": {

price-service/src/rest.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)