Skip to content

Commit

Permalink
fix: route to bridge page when a HW is connected
Browse files Browse the repository at this point in the history
  • Loading branch information
micaelae committed Nov 20, 2024
1 parent 2dc61c6 commit 345b024
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions ui/hooks/bridge/useBridging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ import { isHardwareKeyring } from '../../helpers/utils/hardware';
import { getPortfolioUrl } from '../../helpers/utils/portfolio';
import { SwapsTokenObject } from '../../../shared/constants/swaps';
import { getProviderConfig } from '../../ducks/metamask/metamask';
// eslint-disable-next-line import/no-restricted-paths
import { getEnvironmentType } from '../../../app/scripts/lib/util';
import { ENVIRONMENT_TYPE_FULLSCREEN } from '../../../shared/constants/app';
import { useCrossChainSwapsEvents } from './useCrossChainSwapsEvents';
///: END:ONLY_INCLUDE_IF

Expand Down Expand Up @@ -90,18 +93,18 @@ const useBridging = () => {
chain_id: providerConfig.chainId,
},
});
if (usingHardwareWallet && global.platform.openExtensionInBrowser) {
global.platform.openExtensionInBrowser(
PREPARE_SWAP_ROUTE,
null,
false,
);
const environmentType = getEnvironmentType();
const environmentTypeIsFullScreen =
environmentType === ENVIRONMENT_TYPE_FULLSCREEN;
const bridgeRoute = `${CROSS_CHAIN_SWAP_ROUTE}${PREPARE_SWAP_ROUTE}?token=${token.address.toLowerCase()}`;
if (
usingHardwareWallet &&
global.platform.openExtensionInBrowser &&
!environmentTypeIsFullScreen
) {
global.platform.openExtensionInBrowser(bridgeRoute);
} else {
history.push(
`${
CROSS_CHAIN_SWAP_ROUTE + PREPARE_SWAP_ROUTE
}?token=${token.address.toLowerCase()}`,
);
history.push(bridgeRoute);
}
} else {
const portfolioUrl = getPortfolioUrl(
Expand Down

0 comments on commit 345b024

Please sign in to comment.