@@ -27,11 +27,11 @@ import {
27
27
toGatewayMsg ,
28
28
toNative ,
29
29
} from "@wormhole-foundation/sdk-definitions" ;
30
- import { signSendWait } from "../common.js" ;
31
- import { fetchIbcXfer , isTokenBridgeVaaRedeemed , retry } from "../tasks.js" ;
32
- import { TransferState } from "../types.js" ;
33
- import { Wormhole } from "../wormhole.js" ;
34
- import type { WormholeTransfer } from "./wormholeTransfer.js" ;
30
+ import { signSendWait } from "../../ common.js" ;
31
+ import { fetchIbcXfer , isTokenBridgeVaaRedeemed , retry } from "../../ tasks.js" ;
32
+ import { TransferState } from "../../ types.js" ;
33
+ import { Wormhole } from "../../ wormhole.js" ;
34
+ import type { WormholeTransfer } from ".. /wormholeTransfer.js" ;
35
35
36
36
type GatewayContext < N extends Network > = ChainContext < N , typeof GatewayTransfer . chain > ;
37
37
@@ -285,12 +285,6 @@ export class GatewayTransfer<N extends Network = Network> implements WormholeTra
285
285
// start the WormholeTransfer by submitting transactions to the source chain
286
286
// returns a transaction hash
287
287
async initiateTransfer ( signer : Signer ) : Promise < TxHash [ ] > {
288
- /*
289
- 0) Check current `state` is valid to call this (eg: state == Created)
290
- 1) Figure out where to call and issue transactions
291
- 2) Update state
292
- 3) return transaction ids
293
- */
294
288
if ( this . _state !== TransferState . Created )
295
289
throw new Error ( "Invalid state transition in `start`" ) ;
296
290
@@ -496,12 +490,6 @@ export class GatewayTransfer<N extends Network = Network> implements WormholeTra
496
490
// finish the WormholeTransfer by submitting transactions to the destination chain
497
491
// returns a transaction hash
498
492
async completeTransfer ( signer : Signer ) : Promise < TxHash [ ] > {
499
- /*
500
- 0) check that the current `state` is valid to call this (eg: state == Ready)
501
- 1) prepare the transactions and sign them given the signer
502
- 2) submit the VAA and transactions on chain
503
- 3) return txid of submission
504
- */
505
493
if ( this . _state < TransferState . Attested )
506
494
throw new Error ( "Invalid state transition in `finish`. Be sure to call `fetchAttestation`." ) ;
507
495
@@ -527,7 +515,19 @@ export class GatewayTransfer<N extends Network = Network> implements WormholeTra
527
515
return redeemTxs . map ( ( { txid } ) => txid ) ;
528
516
}
529
517
530
- static async getTransferVaa < N extends Network > (
518
+ // Implicitly determine if the chain is Gateway enabled by
519
+ // checking to see if the Gateway IBC bridge has a transfer channel setup
520
+ // If this is a new chain, add the channels to the constants file
521
+ private fromGateway ( ) : boolean {
522
+ return this . gatewayIbcBridge . getTransferChannel ( this . transfer . from . chain ) !== null ;
523
+ }
524
+ private toGateway ( ) : boolean {
525
+ return this . gatewayIbcBridge . getTransferChannel ( this . transfer . to . chain ) !== null ;
526
+ }
527
+ }
528
+
529
+ export namespace GatewayTransfer {
530
+ export async function getTransferVaa < N extends Network > (
531
531
wh : Wormhole < N > ,
532
532
whm : WormholeMessageId ,
533
533
timeout ?: number ,
@@ -537,7 +537,7 @@ export class GatewayTransfer<N extends Network = Network> implements WormholeTra
537
537
return vaa ;
538
538
}
539
539
540
- static async destinationOverrides < N extends Network > (
540
+ export async function destinationOverrides < N extends Network > (
541
541
srcChain : ChainContext < N > ,
542
542
dstChain : ChainContext < N > ,
543
543
gatewayChain : ChainContext < N , "Wormchain" > ,
@@ -563,7 +563,11 @@ export class GatewayTransfer<N extends Network = Network> implements WormholeTra
563
563
564
564
// Lookup the token id for the destination chain given the source chain
565
565
// and token id
566
- static async lookupDestinationToken < N extends Network , SC extends Chain , DC extends Chain > (
566
+ export async function lookupDestinationToken <
567
+ N extends Network ,
568
+ SC extends Chain ,
569
+ DC extends Chain ,
570
+ > (
567
571
srcChain : ChainContext < N , SC > ,
568
572
dstChain : ChainContext < N , DC > ,
569
573
gatewayChain : ChainContext < N , "Wormchain" > ,
@@ -601,14 +605,4 @@ export class GatewayTransfer<N extends Network = Network> implements WormholeTra
601
605
const dstAddress = await dstTb . getWrappedAsset ( lookup ) ;
602
606
return { chain : dstChain . chain , address : dstAddress } ;
603
607
}
604
-
605
- // Implicitly determine if the chain is Gateway enabled by
606
- // checking to see if the Gateway IBC bridge has a transfer channel setup
607
- // If this is a new chain, add the channels to the constants file
608
- private fromGateway ( ) : boolean {
609
- return this . gatewayIbcBridge . getTransferChannel ( this . transfer . from . chain ) !== null ;
610
- }
611
- private toGateway ( ) : boolean {
612
- return this . gatewayIbcBridge . getTransferChannel ( this . transfer . to . chain ) !== null ;
613
- }
614
608
}
0 commit comments