@@ -9,17 +9,20 @@ import {
9
9
RedeemedTransferReceipt ,
10
10
Signer ,
11
11
TokenId ,
12
+ TransactionId ,
12
13
TransferState ,
13
14
Wormhole ,
14
15
WormholeMessageId ,
15
16
amount ,
17
+ canonicalAddress ,
16
18
isAttested ,
17
19
isDestinationQueued ,
18
20
isRedeemed ,
19
21
isSourceFinalized ,
20
22
isSourceInitiated ,
21
23
routes ,
22
24
signSendWait ,
25
+ finality ,
23
26
} from "@wormhole-foundation/sdk-connect" ;
24
27
import "@wormhole-foundation/sdk-definitions-ntt" ;
25
28
import { NttRoute } from "./types.js" ;
@@ -145,6 +148,7 @@ export class NttManualRoute<N extends Network>
145
148
token : request . destination . id ,
146
149
amount : amount . parse ( params . amount , request . destination . decimals ) ,
147
150
} ,
151
+ eta : finality . estimateFinalityTime ( request . fromChain . chain ) ,
148
152
} ;
149
153
const { fromChain, toChain } = request ;
150
154
const dstNtt = await toChain . getProtocol ( "Ntt" , {
@@ -224,6 +228,83 @@ export class NttManualRoute<N extends Network>
224
228
} ;
225
229
}
226
230
231
+ async resume ( tx : TransactionId ) : Promise < R > {
232
+ const vaa = await this . wh . getVaa ( tx . txid , "Ntt:WormholeTransfer" ) ;
233
+ if ( ! vaa ) throw new Error ( "No VAA found for transaction: " + tx . txid ) ;
234
+
235
+ const msgId : WormholeMessageId = {
236
+ chain : vaa . emitterChain ,
237
+ emitter : vaa . emitterAddress ,
238
+ sequence : vaa . sequence ,
239
+ } ;
240
+
241
+ const { recipientChain, trimmedAmount } =
242
+ vaa . payload [ "nttManagerPayload" ] . payload ;
243
+
244
+ const token = canonicalAddress ( {
245
+ chain : vaa . emitterChain ,
246
+ address : vaa . payload [ "nttManagerPayload" ] . payload . sourceToken ,
247
+ } ) ;
248
+ const manager = canonicalAddress ( {
249
+ chain : vaa . emitterChain ,
250
+ address : vaa . payload [ "sourceNttManager" ] ,
251
+ } ) ;
252
+ const whTransceiver =
253
+ vaa . emitterChain === "Solana"
254
+ ? manager
255
+ : canonicalAddress ( {
256
+ chain : vaa . emitterChain ,
257
+ address : vaa . emitterAddress ,
258
+ } ) ;
259
+
260
+ const dstInfo = NttRoute . resolveDestinationNttContracts (
261
+ this . staticConfig ,
262
+ {
263
+ chain : vaa . emitterChain ,
264
+ address : vaa . payload [ "sourceNttManager" ] ,
265
+ } ,
266
+ recipientChain
267
+ ) ;
268
+
269
+ const amt = amount . fromBaseUnits (
270
+ trimmedAmount . amount ,
271
+ trimmedAmount . decimals
272
+ ) ;
273
+
274
+ return {
275
+ from : vaa . emitterChain ,
276
+ to : recipientChain ,
277
+ state : TransferState . Attested ,
278
+ originTxs : [ tx ] ,
279
+ attestation : {
280
+ id : msgId ,
281
+ attestation : vaa ,
282
+ } ,
283
+ params : {
284
+ amount : amount . display ( amt ) ,
285
+ options : { automatic : false } ,
286
+ normalizedParams : {
287
+ amount : amt ,
288
+ options : { queue : false } ,
289
+ sourceContracts : {
290
+ token,
291
+ manager,
292
+ transceiver : {
293
+ wormhole : whTransceiver ,
294
+ } ,
295
+ } ,
296
+ destinationContracts : {
297
+ token : dstInfo . token ,
298
+ manager : dstInfo . manager ,
299
+ transceiver : {
300
+ wormhole : dstInfo . transceiver . wormhole ,
301
+ } ,
302
+ } ,
303
+ } ,
304
+ } ,
305
+ } ;
306
+ }
307
+
227
308
async finalize ( signer : Signer , receipt : R ) : Promise < R > {
228
309
if ( ! isDestinationQueued ( receipt ) ) {
229
310
throw new Error (
0 commit comments