Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { quoteHandler } from "./quote";
export { statusHandler } from "./status";
export { capabilitiesHandler } from "./capabilities";
export { vaasHandler } from "./vaas.ts";
38 changes: 38 additions & 0 deletions src/api/vaas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {enabledChains} from "../chains.ts";
import {mockWormhole} from "../mockGuardian.ts";
import {type Request, type Response} from "express";
import type {Hex} from "viem";

export const vaasHandler = async (req: Request, res: Response) => {
let txHash = req.query["txHash"];

if (!txHash) {
res.status(400).send("txHash is required.");
return;
}

// Loop through enabledChains and try mockWormhole for each one, returning the first signed VAA
// that mockWormhole returns.
for (const chainConfig of Object.values(enabledChains)) {
try {
const result = await mockWormhole(
chainConfig.rpc,
txHash as Hex,
chainConfig.coreContractAddress as Hex,
""
);

if (result !== undefined) {
res.status(200).json({data: [{vaa: result}]});
return;
}
} catch (error) {
// Continue to next chain if this one fails
console.log(`Failed to get VAA from chain ${chainConfig.name}:`, error);
}
}

res.status(200).json({
data: []
});
};
5 changes: 4 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import express from "express";
import cors from "cors";
import { overrideGuardianSet } from "./overrideGuardianSet";
import { quoteHandler, statusHandler, capabilitiesHandler } from "./api";
import {quoteHandler, statusHandler, capabilitiesHandler, vaasHandler} from "./api";
import { enabledChains } from "./chains";
import { isHex } from "viem";

Expand All @@ -25,6 +25,9 @@ app.use(express.json());
app.post("/v0/quote", quoteHandler);
app.post("/v0/status/tx", statusHandler);
app.get("/v0/capabilities", capabilitiesHandler);
// This endpoint is part of the Wormholescan API and isn't part of the executor API, but is useful for exposing signed
// VAAs for clients who wish to not use the Executor for relaying and prefer to relay messages themselves.
app.get("/api/v1/vaas", vaasHandler);

const server = app.listen(3000, () => {
console.log(`Server is running at http://localhost:3000`);
Expand Down
Loading