|
1 |
| -import {enabledChains} from "../chains.ts"; |
2 |
| -import {mockWormhole} from "../mockGuardian.ts"; |
3 |
| -import {type Request, type Response} from "express"; |
4 |
| -import type {Hex} from "viem"; |
| 1 | +import { enabledChains } from "../chains.ts"; |
| 2 | +import { mockWormhole } from "../mockGuardian.ts"; |
| 3 | +import { type Request, type Response } from "express"; |
| 4 | +import type { Hex } from "viem"; |
5 | 5 |
|
6 | 6 | export const vaasHandler = async (req: Request, res: Response) => {
|
7 |
| - let txHash = req.query["txHash"]; |
| 7 | + let txHash = req.query["txHash"]; |
8 | 8 |
|
9 |
| - if (!txHash) { |
10 |
| - res.status(400).send("txHash is required."); |
11 |
| - return; |
12 |
| - } |
| 9 | + if (!txHash) { |
| 10 | + res.status(400).send("txHash is required."); |
| 11 | + return; |
| 12 | + } |
13 | 13 |
|
14 |
| - // Loop through enabledChains and try mockWormhole for each one, returning the first signed VAA |
15 |
| - // that mockWormhole returns. |
16 |
| - for (const chainConfig of Object.values(enabledChains)) { |
17 |
| - try { |
18 |
| - const result = await mockWormhole( |
19 |
| - chainConfig.rpc, |
20 |
| - txHash as Hex, |
21 |
| - chainConfig.coreContractAddress as Hex, |
22 |
| - "" |
23 |
| - ); |
| 14 | + // Loop through enabledChains and try mockWormhole for each one, returning the first signed VAA |
| 15 | + // that mockWormhole returns. |
| 16 | + for (const chainConfig of Object.values(enabledChains)) { |
| 17 | + try { |
| 18 | + const result = await mockWormhole( |
| 19 | + chainConfig.rpc, |
| 20 | + txHash as Hex, |
| 21 | + chainConfig.coreContractAddress as Hex, |
| 22 | + "", |
| 23 | + ); |
24 | 24 |
|
25 |
| - if (result !== undefined) { |
26 |
| - res.status(200).json({data: [{vaa: result}]}); |
27 |
| - return; |
28 |
| - } |
29 |
| - } catch (error) { |
30 |
| - // Continue to next chain if this one fails |
31 |
| - console.log(`Failed to get VAA from chain ${chainConfig.name}:`, error); |
32 |
| - } |
| 25 | + if (result !== undefined) { |
| 26 | + res.status(200).json({ data: [{ vaa: result }] }); |
| 27 | + return; |
| 28 | + } |
| 29 | + } catch (error) { |
| 30 | + // Continue to next chain if this one fails |
| 31 | + console.log(`Failed to get VAA from chain ${chainConfig.name}:`, error); |
33 | 32 | }
|
| 33 | + } |
34 | 34 |
|
35 |
| - res.status(200).json({ |
36 |
| - data: [] |
37 |
| - }); |
| 35 | + res.status(200).json({ |
| 36 | + data: [], |
| 37 | + }); |
38 | 38 | };
|
0 commit comments