@@ -42,10 +42,11 @@ import {
4242 fetchCapabilities ,
4343 fetchSignedQuote ,
4444 fetchStatus ,
45- isRelayStatusFailed ,
4645 getNativeRecipientAddress ,
46+ isRelayStatusFailed ,
4747} from "./utils.js" ;
4848import { Ntt , NttWithExecutor } from "@wormhole-foundation/sdk-definitions-ntt" ;
49+ import { StacksNttWithExecutor } from "@wormhole-foundation/sdk-stacks-ntt" ;
4950import {
5051 isNative ,
5152 relayInstructionsLayout ,
@@ -404,7 +405,6 @@ export class NttExecutorRoute<N extends Network>
404405 request : {
405406 type : "StacksNttReceiveInstruction" as const ,
406407 nttManager : Buffer . from (
407- // TODO: is using Buffer correct?
408408 params . normalizedParams . destinationContracts . manager
409409 ) ,
410410 recipient : recipient
@@ -617,50 +617,26 @@ export class NttExecutorRoute<N extends Network>
617617 const { recipientChain, trimmedAmount } =
618618 vaa . payload [ "nttManagerPayload" ] . payload ;
619619
620- let token : string , manager : string , whTransceiver : string ;
621- let dstInfo : Ntt . Contracts ;
622-
623- if ( chainToPlatform ( vaa . emitterChain ) === "Stacks" ) {
624- const { stacksConfig, dstInfo : stacksDstInfo } =
625- NttRoute . resolveDestinationNttContractsStacksEmitter (
626- this . staticConfig . ntt ,
627- vaa . emitterAddress ,
628- recipientChain
629- ) ;
630-
631- token = stacksConfig . token ;
632- manager = stacksConfig . manager ;
633- whTransceiver = stacksConfig . transceiver . find (
634- ( t ) => t . type === "wormhole"
635- ) ! . address ;
636-
637- dstInfo = stacksDstInfo ;
638- } else {
639- token = canonicalAddress ( {
640- chain : vaa . emitterChain ,
641- address : vaa . payload [ "nttManagerPayload" ] . payload . sourceToken ,
642- } ) ;
643- manager = canonicalAddress ( {
620+ const srcManagerAddress = await ( async ( ) => {
621+ if ( chainToPlatform ( tx . chain ) === "Stacks" ) {
622+ // We can't use the manager address from the VAA payload for Stacks
623+ // since it's the hashed address. Instead, we need to fetch it from the transaction.
624+ const stacks = this . wh . getChain ( "Stacks" ) ;
625+ const rpc = await stacks . getRpc ( ) ;
626+ return StacksNttWithExecutor . getManagerAddressFromTx ( rpc , tx . txid ) ;
627+ }
628+ return {
644629 chain : vaa . emitterChain ,
645630 address : vaa . payload [ "sourceNttManager" ] ,
646- } ) ;
647- whTransceiver =
648- chainToPlatform ( vaa . emitterChain ) === "Solana"
649- ? manager
650- : canonicalAddress ( {
651- chain : vaa . emitterChain ,
652- address : vaa . emitterAddress ,
653- } ) ;
654-
655- dstInfo = NttRoute . resolveDestinationNttContracts (
631+ } ;
632+ } ) ( ) ;
633+
634+ const { srcContracts, dstContracts } =
635+ NttRoute . resolveDestinationNttContracts (
656636 this . staticConfig . ntt ,
657- {
658- chain : vaa . emitterChain ,
659- address : vaa . payload [ "sourceNttManager" ] ,
660- } ,
637+ srcManagerAddress ,
661638 recipientChain
662639 ) ;
663- }
664640
665641 const amt = amount . fromBaseUnits (
666642 trimmedAmount . amount ,
@@ -681,20 +657,8 @@ export class NttExecutorRoute<N extends Network>
681657 options : { } ,
682658 normalizedParams : {
683659 amount : amt ,
684- sourceContracts : {
685- token,
686- manager,
687- transceiver : {
688- wormhole : whTransceiver ,
689- } ,
690- } ,
691- destinationContracts : {
692- token : dstInfo . token ,
693- manager : dstInfo . manager ,
694- transceiver : {
695- wormhole : dstInfo . transceiver [ "wormhole" ] ! ,
696- } ,
697- } ,
660+ sourceContracts : srcContracts ,
661+ destinationContracts : dstContracts ,
698662 referrerFeeDbps : 0n ,
699663 } ,
700664 } ,
0 commit comments