@@ -661,19 +661,38 @@ const ataCloseInstructionKeysIndexes = {
661661 * @param {TransactionInstruction[] } instructions - an array of supported Solana instructions
662662 * @returns {InstructionParams[] } An array containing instruction params for Send tx
663663 */
664- function parseAtaCloseInstructions ( instructions : TransactionInstruction [ ] ) : Array < AtaClose > {
665- const instructionData : Array < AtaClose > = [ ] ;
666-
664+ function parseAtaCloseInstructions ( instructions : TransactionInstruction [ ] ) : Array < AtaClose | Nonce > {
665+ const instructionData : Array < AtaClose | Nonce > = [ ] ;
667666 for ( const instruction of instructions ) {
668- const ataClose : AtaClose = {
669- type : InstructionBuilderTypes . CloseAssociatedTokenAccount ,
670- params : {
671- accountAddress : instruction . keys [ ataCloseInstructionKeysIndexes . AccountAddress ] . pubkey . toString ( ) ,
672- destinationAddress : instruction . keys [ ataCloseInstructionKeysIndexes . DestinationAddress ] . pubkey . toString ( ) ,
673- authorityAddress : instruction . keys [ ataCloseInstructionKeysIndexes . AuthorityAddress ] . pubkey . toString ( ) ,
674- } ,
675- } ;
676- instructionData . push ( ataClose ) ;
667+ const type = getInstructionType ( instruction ) ;
668+ switch ( type ) {
669+ case ValidInstructionTypesEnum . AdvanceNonceAccount :
670+ const advanceNonceInstruction = SystemInstruction . decodeNonceAdvance ( instruction ) ;
671+ const nonce : Nonce = {
672+ type : InstructionBuilderTypes . NonceAdvance ,
673+ params : {
674+ walletNonceAddress : advanceNonceInstruction . noncePubkey . toString ( ) ,
675+ authWalletAddress : advanceNonceInstruction . authorizedPubkey . toString ( ) ,
676+ } ,
677+ } ;
678+ instructionData . push ( nonce ) ;
679+ break ;
680+ case ValidInstructionTypesEnum . CloseAssociatedTokenAccount :
681+ const ataClose : AtaClose = {
682+ type : InstructionBuilderTypes . CloseAssociatedTokenAccount ,
683+ params : {
684+ accountAddress : instruction . keys [ ataCloseInstructionKeysIndexes . AccountAddress ] . pubkey . toString ( ) ,
685+ destinationAddress : instruction . keys [ ataCloseInstructionKeysIndexes . DestinationAddress ] . pubkey . toString ( ) ,
686+ authorityAddress : instruction . keys [ ataCloseInstructionKeysIndexes . AuthorityAddress ] . pubkey . toString ( ) ,
687+ } ,
688+ } ;
689+ instructionData . push ( ataClose ) ;
690+ break ;
691+ default :
692+ throw new NotSupported (
693+ 'Invalid transaction, instruction type not supported: ' + getInstructionType ( instruction )
694+ ) ;
695+ }
677696 }
678697 return instructionData ;
679698}
0 commit comments