11import { useCallback , useEffect , useState } from 'react' ;
22import { useDispatch } from 'react-redux' ;
33
4- import config from 'config' ;
4+ import { useConfig } from 'contexts/ConfigContext' ;
5+ import type { ConfigContextType } from 'contexts/ConfigContext' ;
56import { setDestToken } from 'store/transferInput' ;
67
78import type { Token } from 'config/tokens' ;
@@ -28,6 +29,7 @@ type ReturnProps = {
2829 * 3. If both chains selected AND a source token: fetch supported destination tokens from routes
2930 */
3031const computeDestTokensForChains = async (
32+ config : ConfigContextType ,
3133 sourceChain : Chain | undefined ,
3234 destChain : Chain | undefined ,
3335 sourceToken : Token | undefined ,
@@ -57,6 +59,7 @@ const computeDestTokensForChains = async (
5759} ;
5860
5961const useComputeDestinationTokens = ( props : Props ) : ReturnProps => {
62+ const config = useConfig ( ) ;
6063 const { sourceChain, destChain, sourceToken } = props ;
6164
6265 const dispatch = useDispatch ( ) ;
@@ -71,6 +74,7 @@ const useComputeDestinationTokens = (props: Props): ReturnProps => {
7174
7275 try {
7376 const supported = await computeDestTokensForChains (
77+ config ,
7478 sourceChain ,
7579 destChain ,
7680 sourceToken ,
@@ -86,7 +90,7 @@ const useComputeDestinationTokens = (props: Props): ReturnProps => {
8690 } finally {
8791 setIsFetching ( false ) ;
8892 }
89- } , [ sourceToken , sourceChain , destChain , dispatch , getOrFetchToken ] ) ;
93+ } , [ config , sourceToken , sourceChain , destChain , dispatch , getOrFetchToken ] ) ;
9094
9195 useEffect ( ( ) => {
9296 computeDestTokens ( ) ;
0 commit comments