Skip to content

Commit 88dc269

Browse files
committed
use isHex
1 parent ec483a0 commit 88dc269

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/api/vaas.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { enabledChains } from "../chains.ts";
22
import { mockWormhole } from "../mockGuardian.ts";
33
import { type Request, type Response } from "express";
4-
import type { Hex } from "viem";
4+
import { type Hex, isHex } from "viem";
55

66
export const vaasHandler = async (req: Request, res: Response) => {
77
let txHash = req.query["txHash"];
@@ -11,14 +11,22 @@ export const vaasHandler = async (req: Request, res: Response) => {
1111
return;
1212
}
1313

14+
if (!isHex(txHash)) {
15+
res.status(400).send("txHash must be a valid hex string.");
16+
return;
17+
}
18+
1419
// Loop through enabledChains and try mockWormhole for each one, returning the first signed VAA
1520
// that mockWormhole returns.
1621
for (const chainConfig of Object.values(enabledChains)) {
1722
try {
23+
if (!isHex(chainConfig.coreContractAddress)) {
24+
continue;
25+
}
1826
const result = await mockWormhole(
1927
chainConfig.rpc,
20-
txHash as Hex,
21-
chainConfig.coreContractAddress as Hex,
28+
txHash,
29+
chainConfig.coreContractAddress,
2230
"",
2331
);
2432

0 commit comments

Comments
 (0)