Skip to content

Commit a832524

Browse files
committed
refactor
1 parent 10a6dcc commit a832524

File tree

6 files changed

+27
-20
lines changed

6 files changed

+27
-20
lines changed

sdk/examples/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const recoverTxids: TransactionId[] = [
6262
console.log("Source txs", txids);
6363

6464
const vaa = await wh.getVaa(
65-
txids[txids.length - 1]!,
65+
txids[txids.length - 1]!.txid,
6666
"Ntt:WormholeTransfer",
6767
25 * 60 * 1000
6868
);

sdk/route/src/automatic.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,10 @@ export class NttAutomaticRoute<N extends Network>
251251
}
252252

253253
async resume(tx: TransactionId): Promise<R> {
254-
//@ts-ignore
255-
const vaa = await this.wh.getVaa(tx, "Ntt:WormholeTransferStandardRelayer");
254+
const vaa = await this.wh.getVaa(
255+
tx.txid,
256+
"Ntt:WormholeTransferStandardRelayer"
257+
);
256258
if (!vaa) throw new Error("No VAA found for transaction: " + tx.txid);
257259

258260
const msgId: WormholeMessageId = {
@@ -366,18 +368,17 @@ export class NttAutomaticRoute<N extends Network>
366368

367369
public override async *track(receipt: R, timeout?: number) {
368370
if (isSourceInitiated(receipt) || isSourceFinalized(receipt)) {
369-
const txid = receipt.originTxs[receipt.originTxs.length - 1]!;
371+
const { txid } = receipt.originTxs[receipt.originTxs.length - 1]!;
370372

371373
const isEvmPlatform = (chain: Chain) => chainToPlatform(chain) === "Evm";
372374
const vaaType =
373375
isEvmPlatform(receipt.from) && isEvmPlatform(receipt.to)
374376
? // Automatic NTT transfers between EVM chains use standard relayers
375377
"Ntt:WormholeTransferStandardRelayer"
376378
: "Ntt:WormholeTransfer";
377-
// @ts-ignore
378379
const vaa = await this.wh.getVaa(txid, vaaType, timeout);
379380
if (!vaa) {
380-
throw new Error(`No VAA found for transaction: ${txid.txid}`);
381+
throw new Error(`No VAA found for transaction: ${txid}`);
381382
}
382383

383384
const msgId: WormholeMessageId = {

sdk/route/src/executor/executor.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,7 @@ export class NttExecutorRoute<N extends Network>
564564
}
565565

566566
async resume(tx: TransactionId): Promise<R> {
567-
// @ts-ignore
568-
const vaa = await this.wh.getVaa(tx, "Ntt:WormholeTransfer");
567+
const vaa = await this.wh.getVaa(tx.txid, "Ntt:WormholeTransfer");
569568
if (!vaa) throw new Error("No VAA found for transaction: " + tx.txid);
570569

571570
const msgId: WormholeMessageId = {
@@ -675,10 +674,9 @@ export class NttExecutorRoute<N extends Network>
675674
public override async *track(receipt: R, timeout?: number) {
676675
// First we fetch the attestation (VAA) for the transfer
677676
if (isSourceInitiated(receipt) || isSourceFinalized(receipt)) {
678-
const txid = receipt.originTxs.at(-1)!;
679-
// @ts-ignore
677+
const { txid } = receipt.originTxs.at(-1)!;
680678
const vaa = await this.wh.getVaa(txid, "Ntt:WormholeTransfer", timeout);
681-
if (!vaa) throw new Error("No VAA found for transaction: " + txid.txid);
679+
if (!vaa) throw new Error("No VAA found for transaction: " + txid);
682680

683681
const msgId: WormholeMessageId = {
684682
chain: vaa.emitterChain,

sdk/route/src/executor/multiToken.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,9 +768,14 @@ export class MultiTokenNttExecutorRoute<N extends Network>
768768
public override async *track(receipt: R, timeout?: number) {
769769
if (isSourceInitiated(receipt) || isSourceFinalized(receipt)) {
770770
const txid = receipt.originTxs.at(-1)!;
771+
772+
// TODO: can pass txid when this is published: https://github.com/wormhole-foundation/wormhole-sdk-ts/pull/909
773+
const fromChain = this.wh.getChain(receipt.from);
774+
const [msg] = await fromChain.parseTransaction(txid.txid);
775+
if (!msg) throw new Error("No Wormhole messages found");
776+
771777
const vaa = await this.wh.getVaa(
772-
// @ts-ignore
773-
txid,
778+
msg,
774779
"MultiTokenNtt:WormholeTransfer",
775780
timeout
776781
);

sdk/route/src/manual.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,7 @@ export class NttManualRoute<N extends Network>
238238

239239
async resume(tx: TransactionId): Promise<R> {
240240
const vaa = await this.wh.getVaa(
241-
// @ts-ignore
242-
tx,
241+
tx.txid,
243242
"Ntt:WormholeTransfer",
244243
DEFAULT_TASK_TIMEOUT
245244
);
@@ -349,10 +348,9 @@ export class NttManualRoute<N extends Network>
349348

350349
public override async *track(receipt: R, timeout?: number) {
351350
if (isSourceInitiated(receipt) || isSourceFinalized(receipt)) {
352-
const txid = receipt.originTxs[receipt.originTxs.length - 1]!;
353-
// @ts-ignore
351+
const { txid } = receipt.originTxs[receipt.originTxs.length - 1]!;
354352
const vaa = await this.wh.getVaa(txid, "Ntt:WormholeTransfer", timeout);
355-
if (!vaa) throw new Error("No VAA found for transaction: " + txid.txid);
353+
if (!vaa) throw new Error("No VAA found for transaction: " + txid);
356354

357355
const msgId: WormholeMessageId = {
358356
chain: vaa.emitterChain,

sdk/route/src/multiTokenManual.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,14 @@ export class MultiTokenNttManualRoute<N extends Network>
425425
public override async *track(receipt: R, timeout?: number) {
426426
if (isSourceInitiated(receipt) || isSourceFinalized(receipt)) {
427427
const txid = receipt.originTxs.at(-1)!;
428+
429+
// TODO: can pass txid when this is published: https://github.com/wormhole-foundation/wormhole-sdk-ts/pull/909
430+
const fromChain = this.wh.getChain(receipt.from);
431+
const [msg] = await fromChain.parseTransaction(txid.txid);
432+
if (!msg) throw new Error("No Wormhole messages found");
433+
428434
const vaa = await this.wh.getVaa(
429-
// @ts-ignore
430-
txid,
435+
msg,
431436
"MultiTokenNtt:WormholeTransfer",
432437
timeout
433438
);

0 commit comments

Comments
 (0)