File tree Expand file tree Collapse file tree 3 files changed +43
-1
lines changed Expand file tree Collapse file tree 3 files changed +43
-1
lines changed Original file line number Diff line number Diff line change 1
1
export { quoteHandler } from "./quote" ;
2
2
export { statusHandler } from "./status" ;
3
3
export { capabilitiesHandler } from "./capabilities" ;
4
+ export { vaasHandler } from "./vaas.ts" ;
Original file line number Diff line number Diff line change
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
+
6
+ export const vaasHandler = async ( req : Request , res : Response ) => {
7
+ let txHash = req . query [ "txHash" ] ;
8
+
9
+ if ( ! txHash ) {
10
+ res . status ( 400 ) . send ( "txHash is required." ) ;
11
+ return ;
12
+ }
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
+ ) ;
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
+ }
33
+ }
34
+
35
+ res . status ( 200 ) . json ( {
36
+ data : [ ]
37
+ } ) ;
38
+ } ;
Original file line number Diff line number Diff line change 1
1
import express from "express" ;
2
2
import cors from "cors" ;
3
3
import { overrideGuardianSet } from "./overrideGuardianSet" ;
4
- import { quoteHandler , statusHandler , capabilitiesHandler } from "./api" ;
4
+ import { quoteHandler , statusHandler , capabilitiesHandler , vaasHandler } from "./api" ;
5
5
import { enabledChains } from "./chains" ;
6
6
import { isHex } from "viem" ;
7
7
@@ -25,6 +25,9 @@ app.use(express.json());
25
25
app . post ( "/v0/quote" , quoteHandler ) ;
26
26
app . post ( "/v0/status/tx" , statusHandler ) ;
27
27
app . get ( "/v0/capabilities" , capabilitiesHandler ) ;
28
+ // This endpoint is part of the Wormholescan API and isn't part of the executor API, but is useful for exposing signed
29
+ // VAAs for clients who wish to not use the Executor for relaying and prefer to relay messages themselves.
30
+ app . get ( "/api/v1/vaas" , vaasHandler ) ;
28
31
29
32
const server = app . listen ( 3000 , ( ) => {
30
33
console . log ( `Server is running at http://localhost:3000` ) ;
You can’t perform that action at this time.
0 commit comments