Skip to content

Commit

Permalink
Merge pull request #933 from webdev403/hotfix/okxwallet-connection
Browse files Browse the repository at this point in the history
Fix okxwallet connection
  • Loading branch information
sameepsi authored Jul 25, 2023
2 parents 87c2d3d + 55de61b commit 18cd2d3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@
"installBraveDesc": "You need to install brave browser to use brave wallet. If you are on brave browser, you need to disable metamask or set Default Ethereum Wallet to Brave Wallet in settings. (brave://settings/wallet)",
"installBitKeep": "Install BitKeep Wallet",
"installTrustWallet": "Install TrustWallet",
"installOkxWallet": "Install OkxWallet",
"wrongNetwork": "Wrong Network",
"connectPolygonNetwork": "Please connect to the appropriate Polygon network.",
"errorConnectRefresh": "Error connecting. Try refreshing the page.",
Expand Down
21 changes: 18 additions & 3 deletions src/components/WalletModal/WalletModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import React, { useEffect, useState } from 'react';
import { isMobile } from 'react-device-detect';
import ReactGA from 'react-ga';
import { Box } from '@material-ui/core';
import MetamaskIcon from 'assets/images/metamask.png';
import BraveWalletIcon from 'assets/images/braveWalletIcon.png';
import { ReactComponent as Close } from 'assets/images/CloseIcon.svg';
import { GlobalConst } from 'constants/index';
import { ApplicationModal } from 'state/application/actions';
Expand Down Expand Up @@ -157,6 +155,7 @@ const WalletModal: React.FC<WalletModalProps> = ({
const isPhantomWallet =
(ethereum && ethereum.isPhantom) || (phantom && phantom.ethereum);
const isCoinbaseWallet = ethereum && ethereum.isCoinbaseWallet;
const isOkxwallet = (window as any).okxwallet;

return connections.map((option) => {
if (
Expand Down Expand Up @@ -232,7 +231,23 @@ const WalletModal: React.FC<WalletModalProps> = ({
header={t('installMetamask')}
subheader={null}
link={'https://metamask.io/'}
icon={MetamaskIcon}
icon={option.iconName}
iconify={iconify}
/>
);
} else if (
option.name === GlobalConst.walletName.OKXWALLET &&
!isOkxwallet
) {
return (
<WalletOption
id={`connect-${option.name}`}
key={option.name}
color={'#E8831D'}
header={t('installOkxWallet')}
subheader={null}
link={'https://www.okx.com/web3'}
icon={option.iconName}
iconify={iconify}
/>
);
Expand Down
2 changes: 1 addition & 1 deletion src/connectors/OkxWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Connector } from '@web3-react/types';

export class NoOkxWalletError extends Error {
public constructor() {
super('BitKeep not installed');
super('OkxWallet not installed');
this.name = NoOkxWalletError.name;
Object.setPrototypeOf(this, NoOkxWalletError.prototype);
}
Expand Down
1 change: 1 addition & 0 deletions src/connectors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ export const okxWalletConnection: Connection = {
iconName: OkxWalletIcon,
color: '#E8831D',
description: 'OkxWallet browser extension.',
mobile: true,
};

const [web3CypherD, web3CypherDHooks] = initializeConnector<CypherD>(
Expand Down
1 change: 1 addition & 0 deletions src/connectors/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const getIsMetaMaskWallet = () => {
return Boolean(
ethereum &&
ethereum.isMetaMask &&
ethereum._metamask &&
(ethereum.detected && ethereum.detected.length > 0
? ethereum.detected.find(
(provider: any) =>
Expand Down

0 comments on commit 18cd2d3

Please sign in to comment.