@@ -2,9 +2,9 @@ import type {
22 Network ,
33 WormholeConfigOverrides ,
44} from "@wormhole-foundation/sdk-connect" ;
5- import { RequestPrefix } from "@wormhole-foundation/sdk-connect" ;
5+ import { RequestPrefix , UniversalAddress } from "@wormhole-foundation/sdk-connect" ;
66import { fetchQuote , fetchStatus } from "@wormhole-foundation/sdk-connect" ;
7- import { toChain , toUniversal , type Chain } from "@wormhole-foundation/sdk" ;
7+ import { toChain , toUniversal , type Chain , executor , CONFIG } from "@wormhole-foundation/sdk" ;
88import { ethers } from "ethers" ;
99import { decodeAccountID } from "xrpl" ;
1010import { colors } from "../../colors.js" ;
@@ -17,12 +17,6 @@ import {
1717 walletFromSeed ,
1818 withXrplClient ,
1919} from "../../xrpl/helpers" ;
20- import { getDefaultExecutorApiForNetwork } from "../../xrpl/executor" ;
21- import {
22- CHAIN_ID_XRPL ,
23- getDefaultGuardianApiForNetwork ,
24- pollSignedVaa ,
25- } from "../../xrpl/guardian" ;
2620import {
2721 buildGasInstructionHex ,
2822 serializeRequest ,
@@ -39,6 +33,9 @@ import {
3933 type TokenId ,
4034} from "../../xrpl/tokenId" ;
4135import { withCommon } from "./common" ;
36+ import { getVaaBytesWithRetry } from "@wormhole-foundation/sdk-connect/whscan-api" ;
37+
38+ const CHAIN_ID_XRPL = 66 ;
4239
4340/**
4441 * Resolve a destination address to a 32-byte universal hex. Accepts the
@@ -309,15 +306,15 @@ export async function runRelay(
309306
310307 // ── 2. Poll the guardian API for the signed VAA ──
311308 console . log ( colors . blue ( "\n⏳ Waiting for guardian VAA..." ) ) ;
312- await pollSignedVaa ( {
309+ await getVaaBytesWithRetry (
313310 guardianApi ,
314- chain : CHAIN_ID_XRPL ,
315- emitterHex ,
316- sequence ,
317- pollIntervalMs : pollInterval ,
318- pollTimeoutMs : pollTimeout ,
319- onAttempt : ( n , url ) => console . log ( colors . dim ( ` attempt ${ n } : ${ url } ` ) ) ,
320- } ) ;
311+ {
312+ chain : toChain ( CHAIN_ID_XRPL ) ,
313+ emitter : new UniversalAddress ( emitterHex ) ,
314+ sequence : sequence
315+ } ,
316+ pollTimeout
317+ ) ;
321318 console . log ( colors . green ( " VAA available." ) ) ;
322319
323320 // ── 3. Fetch a quote ──
@@ -433,3 +430,33 @@ export async function runRelay(
433430 )
434431 ) ;
435432}
433+
434+ /**
435+ * Default Executor API base URL for a network. Throws if there is no default
436+ * for that network (e.g. not deployed yet) — pass `--executor-api` explicitly
437+ * in that case.
438+ */
439+ export function getDefaultExecutorApiForNetwork ( network : Network ) : string {
440+ const api = executor . executorAPI . get ( network ) ;
441+ if ( ! api ) {
442+ throw new Error (
443+ `No default Executor API for ${ network } ; pass --executor-api`
444+ ) ;
445+ }
446+ return api ;
447+ }
448+
449+ /**
450+ * Default Guardian / Wormholescan API base URL for a network. Throws if there
451+ * is no default for that network (e.g. not deployed yet) — pass `--guardian-api`
452+ * explicitly in that case.
453+ */
454+ export function getDefaultGuardianApiForNetwork ( network : Network ) : string {
455+ const api = CONFIG [ network ] . api ;
456+ if ( ! api ) {
457+ throw new Error (
458+ `No default Guardian API for ${ network } ; pass --guardian-api`
459+ ) ;
460+ }
461+ return api ;
462+ }
0 commit comments