Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions price-service/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion price-service/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pythnetwork/pyth-price-service",
"version": "2.3.1",
"version": "2.3.2",
"description": "Pyth Price Service",
"main": "index.js",
"scripts": {
Expand Down
18 changes: 5 additions & 13 deletions price-service/src/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,15 @@ export class RestAPI {
"/api/latest_vaas",
validate(latestVaasInputSchema),
(req: Request, res: Response) => {
const priceIds = req.query.ids as string[];
const priceIds = (req.query.ids as string[]).map(removeLeading0x);

// Multiple price ids might share same vaa, we use sequence number as
// key of a vaa and deduplicate using a map of seqnum to vaa bytes.
const vaaMap = new Map<number, Buffer>();

const notFoundIds: string[] = [];

for (let id of priceIds) {
if (id.startsWith("0x")) {
id = id.substring(2);
}

for (const id of priceIds) {
const latestPriceInfo = this.priceFeedVaaInfo.getLatestPriceInfo(id);

if (latestPriceInfo === undefined) {
Expand Down Expand Up @@ -181,7 +177,7 @@ export class RestAPI {
"/api/get_vaa",
validate(getVaaInputSchema),
asyncWrapper(async (req: Request, res: Response) => {
const priceFeedId = req.query.id as string;
const priceFeedId = removeLeading0x(req.query.id as string);
const publishTime = Number(req.query.publish_time as string);

if (
Expand Down Expand Up @@ -275,7 +271,7 @@ export class RestAPI {
"/api/latest_price_feeds",
validate(latestPriceFeedsInputSchema),
(req: Request, res: Response) => {
const priceIds = req.query.ids as string[];
const priceIds = (req.query.ids as string[]).map(removeLeading0x);
// verbose is optional, default to false
const verbose = req.query.verbose === "true";
// binary is optional, default to false
Expand All @@ -285,11 +281,7 @@ export class RestAPI {

const notFoundIds: string[] = [];

for (let id of priceIds) {
if (id.startsWith("0x")) {
id = id.substring(2);
}

for (const id of priceIds) {
const latestPriceInfo = this.priceFeedVaaInfo.getLatestPriceInfo(id);

if (latestPriceInfo === undefined) {
Expand Down