File tree Expand file tree Collapse file tree 3 files changed +56
-1
lines changed Expand file tree Collapse file tree 3 files changed +56
-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 , isHex } 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
+ if ( ! isHex ( txHash ) ) {
15
+ res . status ( 400 ) . send ( "txHash must be a valid hex string." ) ;
16
+ return ;
17
+ }
18
+
19
+ // Loop through enabledChains and try mockWormhole for each one, returning the first signed VAA
20
+ // that mockWormhole returns.
21
+ for ( const chainConfig of Object . values ( enabledChains ) ) {
22
+ try {
23
+ if ( ! isHex ( chainConfig . coreContractAddress ) ) {
24
+ continue ;
25
+ }
26
+ const result = await mockWormhole (
27
+ chainConfig . rpc ,
28
+ txHash ,
29
+ chainConfig . coreContractAddress ,
30
+ "" ,
31
+ ) ;
32
+
33
+ if ( result !== undefined ) {
34
+ res . status ( 200 ) . json ( { data : [ { vaa : result } ] } ) ;
35
+ return ;
36
+ }
37
+ } catch ( error ) {
38
+ // Continue to next chain if this one fails
39
+ console . log ( `Failed to get VAA from chain ${ chainConfig . name } :` , error ) ;
40
+ }
41
+ }
42
+
43
+ res . status ( 200 ) . json ( {
44
+ data : [ ] ,
45
+ } ) ;
46
+ } ;
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 {
5
+ quoteHandler ,
6
+ statusHandler ,
7
+ capabilitiesHandler ,
8
+ vaasHandler ,
9
+ } from "./api" ;
5
10
import { enabledChains } from "./chains" ;
6
11
import { isHex } from "viem" ;
7
12
@@ -25,6 +30,9 @@ app.use(express.json());
25
30
app . post ( "/v0/quote" , quoteHandler ) ;
26
31
app . post ( "/v0/status/tx" , statusHandler ) ;
27
32
app . get ( "/v0/capabilities" , capabilitiesHandler ) ;
33
+ // This endpoint is part of the Wormholescan API and isn't part of the executor API, but is useful for exposing signed
34
+ // VAAs for clients who wish to not use the Executor for relaying and prefer to relay messages themselves.
35
+ app . get ( "/api/v1/vaas" , vaasHandler ) ;
28
36
29
37
const server = app . listen ( 3000 , ( ) => {
30
38
console . log ( `Server is running at http://localhost:3000` ) ;
You can’t perform that action at this time.
0 commit comments