@@ -1793,6 +1793,24 @@ describe('SOL:', function () {
17931793 } ,
17941794 } )
17951795 . resolves ( testData . SolResponses . getAccountBalanceResponse ) ;
1796+ callBack
1797+ . withArgs ( {
1798+ payload : {
1799+ id : '1' ,
1800+ jsonrpc : '2.0' ,
1801+ method : 'getTokenAccountsByOwner' ,
1802+ params : [
1803+ testData . keys . destinationPubKey ,
1804+ {
1805+ programId : 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb' ,
1806+ } ,
1807+ {
1808+ encoding : 'jsonParsed' ,
1809+ } ,
1810+ ] ,
1811+ } ,
1812+ } )
1813+ . resolves ( testData . SolResponses . getTokenAccountsByOwnerResponseNoAccounts ) ;
17961814 callBack
17971815 . withArgs ( {
17981816 payload : {
@@ -2031,6 +2049,68 @@ describe('SOL:', function () {
20312049 sandBox . assert . callCount ( solCoin . getDataFromNode , 7 ) ;
20322050 } ) ;
20332051
2052+ it ( 'should recover sol 2022 tokens to recovery destination with no existing token accounts' , async function ( ) {
2053+ const tokenTxn = await basecoin . recover ( {
2054+ userKey : testData . wrwUser . userKey ,
2055+ backupKey : testData . wrwUser . backupKey ,
2056+ bitgoKey : testData . wrwUser . bitgoKey ,
2057+ recoveryDestination : testData . keys . destinationPubKey ,
2058+ tokenContractAddress : t22mintAddress ,
2059+ walletPassphrase : testData . wrwUser . walletPassphrase ,
2060+ durableNonce : {
2061+ publicKey : testData . keys . durableNoncePubKey ,
2062+ secretKey : testData . keys . durableNoncePrivKey ,
2063+ } ,
2064+ programId : 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb' ,
2065+ } ) ;
2066+
2067+ tokenTxn . should . not . be . empty ( ) ;
2068+ tokenTxn . should . hasOwnProperty ( 'serializedTx' ) ;
2069+ tokenTxn . should . hasOwnProperty ( 'scanIndex' ) ;
2070+ should . equal ( ( tokenTxn as MPCTx ) . scanIndex , 0 ) ;
2071+
2072+ const tokenTxnDeserialize = new Transaction ( coin ) ;
2073+ tokenTxnDeserialize . fromRawTransaction ( ( tokenTxn as MPCTx ) . serializedTx ) ;
2074+ const tokenTxnJson = tokenTxnDeserialize . toJson ( ) ;
2075+
2076+ should . equal ( tokenTxnJson . nonce , testData . SolInputData . durableNonceBlockhash ) ;
2077+ should . equal ( tokenTxnJson . feePayer , testData . wrwUser . walletAddress0 ) ;
2078+ should . equal ( tokenTxnJson . numSignatures , testData . SolInputData . durableNonceSignatures ) ;
2079+
2080+ const instructionsData = tokenTxnJson . instructionsData as InstructionParams [ ] ;
2081+ should . equal ( instructionsData . length , 3 ) ;
2082+ should . equal ( instructionsData [ 0 ] . type , 'NonceAdvance' ) ;
2083+
2084+ const destinationTokenAccount = await getAssociatedTokenAccountAddress (
2085+ t22mintAddress ,
2086+ testData . keys . destinationPubKey
2087+ ) ;
2088+ should . equal ( instructionsData [ 1 ] . type , 'CreateAssociatedTokenAccount' ) ;
2089+ should . equal ( ( instructionsData [ 1 ] as AtaInit ) . params . mintAddress , t22mintAddress ) ;
2090+ should . equal ( ( instructionsData [ 1 ] as AtaInit ) . params . ataAddress , destinationTokenAccount ) ;
2091+ should . equal ( ( instructionsData [ 1 ] as AtaInit ) . params . ownerAddress , testData . keys . destinationPubKey ) ;
2092+ should . equal ( ( instructionsData [ 1 ] as AtaInit ) . params . tokenName , 'tsol:t22mint' ) ;
2093+ should . equal ( ( instructionsData [ 1 ] as AtaInit ) . params . payerAddress , testData . wrwUser . walletAddress0 ) ;
2094+
2095+ const sourceTokenAccount = await getAssociatedTokenAccountAddress (
2096+ t22mintAddress ,
2097+ testData . wrwUser . walletAddress0
2098+ ) ;
2099+ should . equal ( instructionsData [ 2 ] . type , 'TokenTransfer' ) ;
2100+ should . equal ( ( instructionsData [ 2 ] as TokenTransfer ) . params . fromAddress , testData . wrwUser . walletAddress0 ) ;
2101+ should . equal ( ( instructionsData [ 2 ] as TokenTransfer ) . params . toAddress , destinationTokenAccount ) ;
2102+ should . equal ( ( instructionsData [ 2 ] as TokenTransfer ) . params . amount , '2000000000' ) ;
2103+ should . equal ( ( instructionsData [ 2 ] as TokenTransfer ) . params . tokenName , 'tsol:t22mint' ) ;
2104+ should . equal ( ( instructionsData [ 2 ] as TokenTransfer ) . params . sourceAddress , sourceTokenAccount ) ;
2105+ should . equal (
2106+ ( instructionsData [ 2 ] as TokenTransfer ) . params . programId ,
2107+ 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb'
2108+ ) ;
2109+
2110+ const solCoin = basecoin as any ;
2111+ sandBox . assert . callCount ( solCoin . getDataFromNode , 7 ) ;
2112+ } ) ;
2113+
20342114 it ( 'should recover sol tokens to recovery destination with existing token accounts' , async function ( ) {
20352115 const tokenTxn = await basecoin . recover ( {
20362116 userKey : testData . wrwUser . userKey ,
0 commit comments