Skip to content

Commit

Permalink
Fix the issue with connecting evm chains using WalletConnect
Browse files Browse the repository at this point in the history
  • Loading branch information
Lbqds committed Sep 7, 2024
1 parent 2b31863 commit f8546c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 5 additions & 1 deletion bridge_ui/src/components/EvmConnectWalletDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ const EvmConnectWalletDialog = ({
.map((connection) => (
<WalletOptions
connection={connection}
connect={(evmChainId === undefined || getEvmChainId(chainId) === evmChainId) ? connect : forceNetworkSwitch}
connect={
(evmChainId === undefined || getEvmChainId(chainId) === evmChainId)
? (connectionType) => connect(connectionType, chainId)
: forceNetworkSwitch
}
onClose={onClose}
key={connection.name}
/>
Expand Down
10 changes: 5 additions & 5 deletions bridge_ui/src/contexts/EthereumProviderContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import walletconnectIcon from "../icons/walletconnect.svg";
import { EVM_RPC_MAP } from "../utils/metaMaskChainParameters";
import QRCodeModal from '@alephium/walletconnect-qrcode-modal'
import { getEvmChainId } from "../utils/consts";
import { CHAIN_ID_ETH } from "@alephium/wormhole-sdk";
import { ChainId } from "@alephium/wormhole-sdk";
import { useTranslation } from "react-i18next";

const WALLET_CONNECT_PROJECT_ID = '6e2562e43678dd68a9070a62b6d52207'
Expand All @@ -33,7 +33,7 @@ export interface Connection {
}

interface IEthereumProviderContext {
connect(connectType: ConnectType): void;
connect(connectType: ConnectType, chainId: ChainId): void;
disconnect(): void;
provider: Provider;
chainId: number | undefined;
Expand All @@ -45,7 +45,7 @@ interface IEthereumProviderContext {
}

const EthereumProviderContext = React.createContext<IEthereumProviderContext>({
connect: (connectType: ConnectType) => {},
connect: (connectType: ConnectType, chainId: ChainId) => {},
disconnect: () => {},
provider: undefined,
chainId: undefined,
Expand Down Expand Up @@ -136,7 +136,7 @@ export const EthereumProviderProvider = ({
}, [ethereumProvider, walletConnectProvider]);

const connect = useCallback(
(connectType: ConnectType) => {
(connectType: ConnectType, wormholeChainId: ChainId) => {
setConnectType(connectType);
if (connectType === ConnectType.METAMASK) {
detectEthereumProvider()
Expand Down Expand Up @@ -219,7 +219,7 @@ export const EthereumProviderProvider = ({
EthereumProvider.init({
projectId: WALLET_CONNECT_PROJECT_ID,
showQrModal: false,
chains: [getEvmChainId(CHAIN_ID_ETH) as number],
chains: [getEvmChainId(wormholeChainId) as number],
rpcMap: EVM_RPC_MAP
}).then((walletConnectProvider) => {
setWalletConnectProvider(walletConnectProvider);
Expand Down

0 comments on commit f8546c0

Please sign in to comment.