1
1
import type { Network , Signer , TransactionId , Wormhole } from "@wormhole-foundation/sdk" ;
2
- import { CircleTransfer , amount , wormhole } from "@wormhole-foundation/sdk" ;
2
+ import { CircleTransfer , TransferState , amount , wormhole } from "@wormhole-foundation/sdk" ;
3
3
import evm from "@wormhole-foundation/sdk/evm" ;
4
4
import solana from "@wormhole-foundation/sdk/solana" ;
5
+ import sui from "@wormhole-foundation/sdk/sui" ;
5
6
import type { SignerStuff } from "./helpers/index.js" ;
6
7
import { getSigner } from "./helpers/index.js" ;
7
8
@@ -16,19 +17,19 @@ AutoRelayer takes a 0.1usdc fee when xfering to any chain beside goerli, which i
16
17
( async function ( ) {
17
18
// init Wormhole object, passing config for which network
18
19
// to use (e.g. Mainnet/Testnet) and what Platforms to support
19
- const wh = await wormhole ( "Testnet" , [ evm , solana ] ) ;
20
+ const wh = await wormhole ( "Testnet" , [ evm , solana , sui ] ) ;
20
21
21
22
// Grab chain Contexts
22
23
const sendChain = wh . getChain ( "Avalanche" ) ;
23
- const rcvChain = wh . getChain ( "Solana " ) ;
24
+ const rcvChain = wh . getChain ( "Sui " ) ;
24
25
25
26
// Get signer from local key but anything that implements
26
27
// Signer interface (e.g. wrapper around web wallet) should work
27
28
const source = await getSigner ( sendChain ) ;
28
29
const destination = await getSigner ( rcvChain ) ;
29
30
30
31
// 6 decimals for USDC (except for bsc, so check decimals before using this)
31
- const amt = amount . units ( amount . parse ( "0.2 " , 6 ) ) ;
32
+ const amt = amount . units ( amount . parse ( "0.01 " , 6 ) ) ;
32
33
33
34
// Choose whether or not to have the attestation delivered for you
34
35
const automatic = false ;
@@ -105,6 +106,18 @@ async function cctpTransfer<N extends Network>(
105
106
console . log ( "Completing Transfer" ) ;
106
107
const dstTxids = await xfer . completeTransfer ( dst . signer ) ;
107
108
console . log ( `Completed Transfer: ` , dstTxids ) ;
109
+
110
+ console . log ( "Tracking Transfer Progress" ) ;
111
+ let receipt = CircleTransfer . getReceipt ( xfer ) ;
112
+
113
+ for await ( receipt of CircleTransfer . track ( wh , receipt ) ) {
114
+ console . log ( "Receipt State:" , receipt . state ) ;
115
+ if ( receipt . state === TransferState . DestinationFinalized ) {
116
+ console . log ( "Transfer Confirmed Complete" ) ;
117
+ break ;
118
+ }
119
+ }
120
+
108
121
// EXAMPLE_CCTP_TRANSFER
109
122
}
110
123
0 commit comments