[price-service] Hotfix leading 0x problem (#507)
This commit is contained in:
parent
0eac7246bd
commit
e4963f4df3
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "@pythnetwork/pyth-price-service",
|
"name": "@pythnetwork/pyth-price-service",
|
||||||
"version": "2.3.1",
|
"version": "2.3.2",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@pythnetwork/pyth-price-service",
|
"name": "@pythnetwork/pyth-price-service",
|
||||||
"version": "2.3.1",
|
"version": "2.3.2",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@certusone/wormhole-sdk": "^0.9.9",
|
"@certusone/wormhole-sdk": "^0.9.9",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@pythnetwork/pyth-price-service",
|
"name": "@pythnetwork/pyth-price-service",
|
||||||
"version": "2.3.1",
|
"version": "2.3.2",
|
||||||
"description": "Pyth Price Service",
|
"description": "Pyth Price Service",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -130,7 +130,7 @@ export class RestAPI {
|
||||||
"/api/latest_vaas",
|
"/api/latest_vaas",
|
||||||
validate(latestVaasInputSchema),
|
validate(latestVaasInputSchema),
|
||||||
(req: Request, res: Response) => {
|
(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
|
// 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.
|
// key of a vaa and deduplicate using a map of seqnum to vaa bytes.
|
||||||
|
@ -138,11 +138,7 @@ export class RestAPI {
|
||||||
|
|
||||||
const notFoundIds: string[] = [];
|
const notFoundIds: string[] = [];
|
||||||
|
|
||||||
for (let id of priceIds) {
|
for (const id of priceIds) {
|
||||||
if (id.startsWith("0x")) {
|
|
||||||
id = id.substring(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
const latestPriceInfo = this.priceFeedVaaInfo.getLatestPriceInfo(id);
|
const latestPriceInfo = this.priceFeedVaaInfo.getLatestPriceInfo(id);
|
||||||
|
|
||||||
if (latestPriceInfo === undefined) {
|
if (latestPriceInfo === undefined) {
|
||||||
|
@ -181,7 +177,7 @@ export class RestAPI {
|
||||||
"/api/get_vaa",
|
"/api/get_vaa",
|
||||||
validate(getVaaInputSchema),
|
validate(getVaaInputSchema),
|
||||||
asyncWrapper(async (req: Request, res: Response) => {
|
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);
|
const publishTime = Number(req.query.publish_time as string);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -275,7 +271,7 @@ export class RestAPI {
|
||||||
"/api/latest_price_feeds",
|
"/api/latest_price_feeds",
|
||||||
validate(latestPriceFeedsInputSchema),
|
validate(latestPriceFeedsInputSchema),
|
||||||
(req: Request, res: Response) => {
|
(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
|
// verbose is optional, default to false
|
||||||
const verbose = req.query.verbose === "true";
|
const verbose = req.query.verbose === "true";
|
||||||
// binary is optional, default to false
|
// binary is optional, default to false
|
||||||
|
@ -285,11 +281,7 @@ export class RestAPI {
|
||||||
|
|
||||||
const notFoundIds: string[] = [];
|
const notFoundIds: string[] = [];
|
||||||
|
|
||||||
for (let id of priceIds) {
|
for (const id of priceIds) {
|
||||||
if (id.startsWith("0x")) {
|
|
||||||
id = id.substring(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
const latestPriceInfo = this.priceFeedVaaInfo.getLatestPriceInfo(id);
|
const latestPriceInfo = this.priceFeedVaaInfo.getLatestPriceInfo(id);
|
||||||
|
|
||||||
if (latestPriceInfo === undefined) {
|
if (latestPriceInfo === undefined) {
|
||||||
|
|
Loading…
Reference in New Issue