Skip to content

Commit

Permalink
fix bridge button sending users to swaps v1 (#5971)
Browse files Browse the repository at this point in the history
  • Loading branch information
walmat authored Aug 6, 2024
1 parent 39e1c73 commit 0fd389f
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/components/DappBrowser/control-panel/ControlPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -472,11 +472,26 @@ const HomePanel = ({
},
screen: Routes.MAIN_EXCHANGE_SCREEN,
});
}, [runWalletChecksBeforeSwapOrBridge, selectedWallet?.uniqueId]);
}, [navigate, runWalletChecksBeforeSwapOrBridge, selectedWallet?.uniqueId, swapsV2Enabled]);

const handleOnPressBridge = useCallback(async () => {
const valid = await runWalletChecksBeforeSwapOrBridge();
if (!valid) return;

const { swaps_v2 } = getRemoteConfig();

if (swaps_v2 || swapsV2Enabled) {
// TODO: We need to set something in swapsStore that deliniates between a swap and bridge
// for now let's just treat it like a normal swap
swapsStore.setState({
inputAsset: userAssetsStore.getState().getHighestValueAsset(),
});
InteractionManager.runAfterInteractions(() => {
navigate(Routes.SWAP);
});
return;
}

const mainnetEth = await ethereumUtils.getNativeAssetForNetwork(Network.mainnet, selectedWallet?.uniqueId);
Navigation.handleAction(Routes.EXCHANGE_MODAL, {
fromDiscover: true,
Expand All @@ -485,7 +500,7 @@ const HomePanel = ({
},
screen: Routes.MAIN_EXCHANGE_SCREEN,
});
}, [runWalletChecksBeforeSwapOrBridge, selectedWallet?.uniqueId]);
}, [navigate, runWalletChecksBeforeSwapOrBridge, selectedWallet?.uniqueId, swapsV2Enabled]);

const isOnHomepage = useBrowserStore(state => (state.getActiveTabUrl() || DEFAULT_TAB_URL) === RAINBOW_HOME);

Expand Down

0 comments on commit 0fd389f

Please sign in to comment.