1
- import {
2
- Chain ,
3
- canonicalAddress ,
4
- routes ,
5
- wormhole ,
6
- } from "@wormhole-foundation/sdk" ;
1
+ import { canonicalAddress , routes , wormhole } from "@wormhole-foundation/sdk" ;
7
2
import evm from "@wormhole-foundation/sdk/evm" ;
8
3
import solana from "@wormhole-foundation/sdk/solana" ;
9
4
10
5
// register protocol implementations
11
- import { Ntt } from "@wormhole-foundation/sdk-definitions-ntt" ;
12
6
import "@wormhole-foundation/sdk-evm-ntt" ;
13
7
import "@wormhole-foundation/sdk-solana-ntt" ;
14
8
15
- import {
16
- NttRoute ,
17
- nttAutomaticRoute ,
18
- } from "@wormhole-foundation/sdk-route-ntt" ;
9
+ import { nttAutomaticRoute } from "@wormhole-foundation/sdk-route-ntt" ;
19
10
import { getSigner } from "./helpers.js" ;
20
-
21
- const NTT_CONTRACTS : Record < string , Ntt . Contracts > = {
22
- Solana : {
23
- token : "E3W7KwMH8ptaitYyWtxmfBUpqcuf2XieaFtQSn1LVXsA" ,
24
- manager : "WZLm4bJU4BNVmzWEwEzGVMQ5XFUc4iBmMSLutFbr41f" ,
25
- transceiver : {
26
- wormhole : "WZLm4bJU4BNVmzWEwEzGVMQ5XFUc4iBmMSLutFbr41f" ,
27
- } ,
28
- quoter : "Nqd6XqA8LbsCuG8MLWWuP865NV6jR1MbXeKxD4HLKDJ" ,
29
- } ,
30
- ArbitrumSepolia : {
31
- token : "0x87579Dc40781e99b870DDce46e93bd58A0e58Ae5" ,
32
- manager : "0xdA5a8e05e276AAaF4d79AB5b937a002E5221a4D8" ,
33
- transceiver : {
34
- wormhole : "0xd2940c256a3D887833D449eF357b6D639Cb98e12" ,
35
- } ,
36
- } ,
37
- } ;
38
-
39
- // Reformat NTT contracts to fit token list list
40
- const tokens = {
41
- Jito : Object . entries ( NTT_CONTRACTS ) . map ( ( [ c , contracts ] ) => {
42
- const chain = c as Chain ;
43
- const { token, manager, transceiver : transceivers , quoter } = contracts ;
44
- const transceiver = Object . entries ( transceivers ) . map ( ( [ k , v ] ) => {
45
- return { type : k as NttRoute . TransceiverType , address : v } ;
46
- } ) ;
47
-
48
- return { chain, token, manager, quoter, transceiver } ;
49
- } ) ,
50
- } ;
11
+ import { NttTokens } from "./consts.js" ;
51
12
52
13
( async function ( ) {
53
14
const wh = await wormhole ( "Testnet" , [ solana , evm ] ) ;
@@ -58,7 +19,7 @@ const tokens = {
58
19
const srcSigner = await getSigner ( src ) ;
59
20
const dstSigner = await getSigner ( dst ) ;
60
21
61
- const resolver = wh . resolver ( [ nttAutomaticRoute ( { tokens } ) ] ) ;
22
+ const resolver = wh . resolver ( [ nttAutomaticRoute ( { tokens : NttTokens } ) ] ) ;
62
23
63
24
const srcTokens = await resolver . supportedSourceTokens ( src ) ;
64
25
console . log (
@@ -112,9 +73,7 @@ const tokens = {
112
73
// this new var must be passed to the next step, quote
113
74
const validated = await bestRoute . validate ( {
114
75
amount : "0.00001" ,
115
- options : {
116
- gasDropoff : "0.0000001" ,
117
- } ,
76
+ options : { gasDropoff : "0.0" } ,
118
77
} ) ;
119
78
if ( ! validated . valid ) throw validated . error ;
120
79
console . log ( "Validated parameters: " , validated . params ) ;
@@ -125,13 +84,12 @@ const tokens = {
125
84
if ( ! quote . success ) throw quote . error ;
126
85
console . log ( "Best route quote: " , quote ) ;
127
86
128
- return ;
129
87
// Now the transfer may be initiated
130
88
// A receipt will be returned, guess what you gotta do with that?
131
- // const receipt = await bestRoute.initiate(srcSigner.signer, quote);
132
- // console.log("Initiated transfer with receipt: ", receipt);
89
+ const receipt = await bestRoute . initiate ( srcSigner . signer , quote ) ;
90
+ console . log ( "Initiated transfer with receipt: " , receipt ) ;
133
91
134
- //// Kick off a wait log, if there is an opportunity to complete, this function will do it
135
- //// see the implementation for how this works
136
- // await routes.checkAndCompleteTransfer(bestRoute, receipt, dstSigner.signer);
92
+ // Kick off a wait log, if there is an opportunity to complete, this function will do it
93
+ // see the implementation for how this works
94
+ await routes . checkAndCompleteTransfer ( bestRoute , receipt , dstSigner . signer ) ;
137
95
} ) ( ) ;
0 commit comments