Accept hex addresses with 0x in price service (#203)

This commit is contained in:
Ali Behjati 2022-05-09 14:11:28 +04:30 committed by GitHub
parent a1e50ae636
commit d997a9bcf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -66,7 +66,7 @@ export class RestAPI {
const latestVaasInputSchema: schema = {
query: Joi.object({
ids: Joi.array().items(Joi.string().regex(/^[a-f0-9]{64}$/))
ids: Joi.array().items(Joi.string().regex(/^(0x)?[a-f0-9]{64}$/))
})
}
app.get("/latest_vaas", validate(latestVaasInputSchema), (req: Request, res: Response) => {
@ -79,6 +79,10 @@ export class RestAPI {
let notFoundIds: string[] = [];
for (let id of priceIds) {
if (id.startsWith("0x")) {
id = id.substring(2);
}
let latestPriceInfo = this.priceFeedVaaInfo.getLatestPriceInfo(id);
if (latestPriceInfo === undefined) {
@ -106,7 +110,7 @@ export class RestAPI {
const latestPriceFeedsInputSchema: schema = {
query: Joi.object({
ids: Joi.array().items(Joi.string().regex(/^[a-f0-9]{64}$/))
ids: Joi.array().items(Joi.string().regex(/^(0x)?[a-f0-9]{64}$/))
})
}
app.get("/latest_price_feeds", validate(latestPriceFeedsInputSchema), (req: Request, res: Response) => {
@ -117,6 +121,10 @@ export class RestAPI {
let notFoundIds: string[] = [];
for (let id of priceIds) {
if (id.startsWith("0x")) {
id = id.substring(2);
}
let latestPriceInfo = this.priceFeedVaaInfo.getLatestPriceInfo(id);
if (latestPriceInfo === undefined) {