@@ -836,6 +836,7 @@ export class Sol extends BaseCoin {
836836
837837 // check for possible token recovery, recover the token provide by user
838838 if ( params . tokenContractAddress ) {
839+ let isUnsupportedToken = false ;
839840 const tokenAccounts = await this . getTokenAccountsByOwner ( bs58EncodedPublicKey , params . programId , params . apiKey ) ;
840841 if ( tokenAccounts . length !== 0 ) {
841842 // there exists token accounts on the given address, but need to check certain conditions:
@@ -848,8 +849,11 @@ export class Sol extends BaseCoin {
848849 const network = this . getNetwork ( ) ;
849850 const token = getSolTokenFromAddress ( tokenAccount . info . mint , network ) ; // todo(WIN-5894) fix for ams
850851
851- if ( ! _ . isUndefined ( token ) && tokenAmount . gt ( new BigNumber ( 0 ) ) ) {
852- tokenAccount . tokenName = token . name ;
852+ if ( ! token ) {
853+ isUnsupportedToken = true ;
854+ }
855+ if ( tokenAmount . gt ( new BigNumber ( 0 ) ) ) {
856+ tokenAccount . tokenName = token ?. name || 'Unsupported Token' ;
853857 recovereableTokenAccounts . push ( tokenAccount ) ;
854858 }
855859 break ;
@@ -889,17 +893,26 @@ export class Sol extends BaseCoin {
889893 params . programId ?. toString ( )
890894 ) ;
891895 const tokenName = tokenAccount . tokenName as string ;
892- txBuilder . send ( {
896+ const sendParams = {
893897 address : recipientTokenAccount ,
894898 amount : tokenAccount . info . tokenAmount . amount ,
895- tokenName : tokenName ,
896- } ) ;
899+ tokenName,
900+ ...( isUnsupportedToken
901+ ? {
902+ tokenAddress : tokenAccount . info . mint ,
903+ programId : params . programId ?. toString ( ) ,
904+ decimalPlaces : tokenAccount . info . tokenAmount . decimals ,
905+ }
906+ : { } ) ,
907+ } ;
908+ txBuilder . send ( sendParams ) ;
897909
898910 if ( ! recipientTokenAccountExists ) {
899911 // recipient token account does not exist for token and must be created
900912 txBuilder . createAssociatedTokenAccount ( {
901913 ownerAddress : params . recoveryDestination ,
902914 tokenName : tokenName ,
915+ ...( isUnsupportedToken ? { tokenAddress : tokenAccount . info . mint } : { } ) ,
903916 programId :
904917 params . programId ?. toString ( ) . toLowerCase ( ) === TOKEN_2022_PROGRAM_ID . toString ( ) . toLowerCase ( )
905918 ? TOKEN_2022_PROGRAM_ID . toString ( )
0 commit comments