@@ -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 ,
@@ -405,6 +406,7 @@ export class NttExecutorRoute<N extends Network>
405406 type : "StacksNttReceiveInstruction" as const ,
406407 nttManager : Buffer . from (
407408 // TODO: is using Buffer correct?
409+ // what if 0x prefix?
408410 params . normalizedParams . destinationContracts . manager
409411 ) ,
410412 recipient : recipient
@@ -617,50 +619,26 @@ export class NttExecutorRoute<N extends Network>
617619 const { recipientChain, trimmedAmount } =
618620 vaa . payload [ "nttManagerPayload" ] . payload ;
619621
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 ( {
622+ const srcManagerAddress = await ( async ( ) => {
623+ if ( chainToPlatform ( tx . chain ) === "Stacks" ) {
624+ // We can't use the manager address from the VAA payload for Stacks
625+ // since it's the hashed address. Instead, we need to fetch it from the transaction.
626+ const stacks = this . wh . getChain ( "Stacks" ) ;
627+ const rpc = await stacks . getRpc ( ) ;
628+ return StacksNttWithExecutor . getManagerAddressFromTx ( rpc , tx . txid ) ;
629+ }
630+ return {
644631 chain : vaa . emitterChain ,
645632 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 (
633+ } ;
634+ } ) ( ) ;
635+
636+ const { srcContracts, dstContracts } =
637+ NttRoute . resolveDestinationNttContracts (
656638 this . staticConfig . ntt ,
657- {
658- chain : vaa . emitterChain ,
659- address : vaa . payload [ "sourceNttManager" ] ,
660- } ,
639+ srcManagerAddress ,
661640 recipientChain
662641 ) ;
663- }
664642
665643 const amt = amount . fromBaseUnits (
666644 trimmedAmount . amount ,
@@ -681,20 +659,8 @@ export class NttExecutorRoute<N extends Network>
681659 options : { } ,
682660 normalizedParams : {
683661 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- } ,
662+ sourceContracts : srcContracts ,
663+ destinationContracts : dstContracts ,
698664 referrerFeeDbps : 0n ,
699665 } ,
700666 } ,
0 commit comments