@@ -615,9 +615,19 @@ export class SolanaNtt<N extends Network, C extends SolanaChains>
615
615
yield * this . core . postVaa ( payer , wormholeNTT ) ;
616
616
617
617
const senderAddress = new SolanaAddress ( payer ) . unwrap ( ) ;
618
- const nttMessage = wormholeNTT . payload [ "nttManagerPayload" ] ;
619
- const emitterChain = wormholeNTT . emitterChain ;
620
618
619
+ const receiveMessageIx = NTT . createReceiveWormholeMessageInstruction (
620
+ this . program ,
621
+ {
622
+ wormholeId : new PublicKey ( this . core . address ) ,
623
+ payer : senderAddress ,
624
+ vaa : wormholeNTT ,
625
+ } ,
626
+ this . pdas
627
+ ) ;
628
+
629
+ const nttMessage = wormholeNTT . payload . nttManagerPayload ;
630
+ const emitterChain = wormholeNTT . emitterChain ;
621
631
const releaseArgs = {
622
632
payer : senderAddress ,
623
633
config,
@@ -629,17 +639,27 @@ export class SolanaNtt<N extends Network, C extends SolanaChains>
629
639
revertOnDelay : false ,
630
640
} ;
631
641
632
- const [ receiveMessageIx , redeemIx , releaseIx ] = await Promise . all ( [
633
- this . createReceiveWormholeMessageInstruction ( senderAddress , wormholeNTT ) ,
634
- this . createRedeemInstruction ( senderAddress , wormholeNTT ) ,
642
+ const redeemIx = NTT . createRedeemInstruction ( this . program , config , {
643
+ payer : senderAddress ,
644
+ vaa : wormholeNTT ,
645
+ } ) ;
646
+
647
+ const releaseIx =
635
648
config . mode . locking != null
636
- ? this . createReleaseInboundUnlockInstruction ( releaseArgs )
637
- : this . createReleaseInboundMintInstruction ( releaseArgs ) ,
638
- ] ) ;
649
+ ? NTT . createReleaseInboundUnlockInstruction (
650
+ this . program ,
651
+ config ,
652
+ releaseArgs
653
+ )
654
+ : NTT . createReleaseInboundMintInstruction (
655
+ this . program ,
656
+ config ,
657
+ releaseArgs
658
+ ) ;
639
659
640
660
const tx = new Transaction ( ) ;
641
661
tx . feePayer = senderAddress ;
642
- tx . add ( receiveMessageIx , redeemIx , releaseIx ) ;
662
+ tx . add ( ... ( await Promise . all ( [ receiveMessageIx , redeemIx , releaseIx ] ) ) ) ;
643
663
644
664
const luts : AddressLookupTableAccount [ ] = [ ] ;
645
665
@@ -757,34 +777,6 @@ export class SolanaNtt<N extends Network, C extends SolanaChains>
757
777
return xfer ;
758
778
}
759
779
760
- async createReceiveWormholeMessageInstruction (
761
- payer : PublicKey ,
762
- wormholeNTT : WormholeNttTransceiver . VAA
763
- ) : Promise < TransactionInstruction > {
764
- const config = await this . getConfig ( ) ;
765
- if ( config . paused ) throw new Error ( "Contract is paused" ) ;
766
-
767
- const nttMessage = wormholeNTT . payload [ "nttManagerPayload" ] ;
768
- const emitterChain = wormholeNTT . emitterChain ;
769
- return await this . program . methods
770
- . receiveWormholeMessage ( )
771
- . accountsStrict ( {
772
- payer : payer ,
773
- config : { config : this . pdas . configAccount ( ) } ,
774
- peer : this . pdas . transceiverPeerAccount ( emitterChain ) ,
775
- vaa : utils . derivePostedVaaKey (
776
- this . core . address ,
777
- Buffer . from ( wormholeNTT . hash )
778
- ) ,
779
- transceiverMessage : this . pdas . transceiverMessageAccount (
780
- emitterChain ,
781
- nttMessage . id
782
- ) ,
783
- systemProgram : SystemProgram . programId ,
784
- } )
785
- . instruction ( ) ;
786
- }
787
-
788
780
async createRedeemInstruction (
789
781
payer : PublicKey ,
790
782
wormholeNTT : WormholeNttTransceiver . VAA
0 commit comments