From 1ba74f8fc922c8a3140038e95ad5d5ca179919bb Mon Sep 17 00:00:00 2001 From: vladwulf Date: Wed, 25 Jan 2023 21:45:54 +0000 Subject: [PATCH] debug: add logs --- components/swap/parts/ChainSwapper.tsx | 1 + components/swap/parts/SourceChainSelector.tsx | 11 +++++++++-- .../src-chain-selector/hooks/useSwitchSrcChain.ts | 6 +++++- hooks/init/useInitialChainList.ts | 2 ++ hooks/usePreventDuplicateChains.ts | 1 + 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/components/swap/parts/ChainSwapper.tsx b/components/swap/parts/ChainSwapper.tsx index d7ad806dd..297457cd8 100644 --- a/components/swap/parts/ChainSwapper.tsx +++ b/components/swap/parts/ChainSwapper.tsx @@ -27,6 +27,7 @@ export const ChainSwapper = () => { const updateQueryParamsAndSwitch = async () => { setDestChain(srcChain); + console.log(1); setSrcChain(destChain); // if switching from a native token should choose the wrapped version diff --git a/components/swap/parts/SourceChainSelector.tsx b/components/swap/parts/SourceChainSelector.tsx index e5941f1ac..8c6d4662f 100644 --- a/components/swap/parts/SourceChainSelector.tsx +++ b/components/swap/parts/SourceChainSelector.tsx @@ -57,7 +57,10 @@ export const SourceChainSelector = () => { const chain = filteredChains.find( (candidate) => candidate.chainName === srcChainName ); - if (chain) setSrcChain(chain); + if (chain) { + console.log(2); + setSrcChain(chain); + } }, [router.query]); useEffect(() => { @@ -91,7 +94,10 @@ export const SourceChainSelector = () => { const selectedChainHasAsset = selectedChain?.assets?.find( (_asset) => _asset.common_key === asset?.id ); - if (selectedChainHasAsset) return setSrcChain(chain); + if (selectedChainHasAsset) { + console.log(3); + return setSrcChain(chain); + } // if asset incompatible find fist compatible asset const compatibleAsset = allAssets.find( @@ -101,6 +107,7 @@ export const SourceChainSelector = () => { ); if (!compatibleAsset) return; setAsset(compatibleAsset); + console.log(4); setSrcChain(chain); } diff --git a/features/src-chain-selector/hooks/useSwitchSrcChain.ts b/features/src-chain-selector/hooks/useSwitchSrcChain.ts index 33fab9f7c..3d5fd2347 100644 --- a/features/src-chain-selector/hooks/useSwitchSrcChain.ts +++ b/features/src-chain-selector/hooks/useSwitchSrcChain.ts @@ -21,7 +21,10 @@ export const useSwitchSrcChain = () => { const selectedChainHasAsset = selectedChain?.assets?.find( (_asset) => _asset.common_key === asset?.id ); - if (selectedChainHasAsset) return setSrcChain(chain); + if (selectedChainHasAsset) { + console.log(5); + return setSrcChain(chain); + } // if asset incompatible find fist compatible asset const compatibleAsset = allAssets.find( @@ -31,6 +34,7 @@ export const useSwitchSrcChain = () => { ); if (!compatibleAsset) return; setAsset(compatibleAsset); + console.log(6); setSrcChain(chain); }; }; diff --git a/hooks/init/useInitialChainList.ts b/hooks/init/useInitialChainList.ts index f480c5db8..7b92594b4 100644 --- a/hooks/init/useInitialChainList.ts +++ b/hooks/init/useInitialChainList.ts @@ -120,8 +120,10 @@ export const useInitialChainList = () => { ) as ChainInfo; } if (srcChainFound) { + console.log(8); setSrcChain(srcChainFound); } else { + console.log(9); setSrcChain( uniqueChains.find( (chain) => chain.chainName?.toLowerCase() === DEFAULT_SRC_CHAIN diff --git a/hooks/usePreventDuplicateChains.ts b/hooks/usePreventDuplicateChains.ts index e4bf77ad6..23b7661d6 100644 --- a/hooks/usePreventDuplicateChains.ts +++ b/hooks/usePreventDuplicateChains.ts @@ -37,6 +37,7 @@ export const usePreventDuplicateChains = () => { const newChain = allChains.find( (chain) => chain?.chainName !== srcChain?.chainName ) as ChainInfo; + console.log(7); setSrcChain(newChain); } else if (sourceChain === "destChain") { const newChain = allChains.find(