File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -229,15 +229,22 @@ const CreateStream = (props: CreateStreamProps) => {
229229  } ; 
230230
231231  // Get your current chainID 
232-   let  targetChainId : number  |  undefined ; 
233-   if  ( chain )  { 
234-     targetChainId  =  chain . id ; 
235-   } 
232+   const  targetChainId  =  chain  ? chain . id  : undefined ; 
236233
237-   // reset selectedToken if chainId changes 
238234  useEffect ( ( )  =>  { 
235+     // Reset the selectedToken when the targetChainId changes 
239236    setSelectedToken ( null ) ; 
240-   } ,  [ targetChainId ] ) ; 
237+ 
238+     // Filter the tokens based on the chainId 
239+     const  filteredTokens  =  props . tokenList . filter ( 
240+       ( token )  =>  token . chainId  ===  targetChainId , 
241+     ) ; 
242+ 
243+     // If there's only one token, set it as the selected token 
244+     if  ( filteredTokens . length  ===  1 )  { 
245+       setSelectedToken ( filteredTokens [ 0 ] ) ; 
246+     } 
247+   } ,  [ props . tokenList ,  targetChainId ] ) ; 
241248
242249  // Select the payment token among tokens with the same chainID 
243250  const  Step1  =  ( )  =>  { 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments