Skip to content

Commit

Permalink
Merge branch 'dev' into release/0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
totop716 committed Mar 18, 2022
2 parents 58a3b2f + c8c4fbd commit 15d2432
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 27 deletions.
3 changes: 3 additions & 0 deletions src/assets/images/blockwalletIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 9 additions & 3 deletions src/components/AccountDetails/AccountDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,21 @@ const AccountDetails: React.FC<AccountDetailsProps> = ({

function formatConnectorName() {
const { ethereum } = window as any;
const isMetaMask = !!(ethereum && ethereum.isMetaMask);
const isMetaMask = !!(
ethereum &&
!ethereum.isBitKeep &&
ethereum.isMetaMask
);
const isBitkeep = !!(ethereum && ethereum.isBitKeep);
const isBlockWallet = !!(ethereum && ethereum.isBlockWallet);
const name = Object.keys(SUPPORTED_WALLETS)
.filter(
(k) =>
SUPPORTED_WALLETS[k].connector === connector &&
(connector !== injected ||
isBitkeep === (k === 'BITKEEP') ||
(!isBitkeep && isMetaMask) === (k === 'METAMASK')),
(isBlockWallet && k === 'BLOCKWALLET') ||
(isBitkeep && k === 'BITKEEP') ||
(isMetaMask && k === 'METAMASK')),
)
.map((k) => SUPPORTED_WALLETS[k].name)[0];
return <Typography variant='body2'>Connected with {name}</Typography>;
Expand Down
8 changes: 5 additions & 3 deletions src/components/AccountDetails/StatusIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ import { useActiveWeb3React } from 'hooks';
const StatusIcon: React.FC = () => {
const { connector } = useActiveWeb3React();
const { ethereum } = window as any;
const isMetaMask = !!(ethereum && ethereum.isMetaMask);
const isMetaMask = !!(ethereum && !ethereum.isBitKeep && ethereum.isMetaMask);
const isBlockWallet = !!(ethereum && ethereum.isBlockWallet);
const isBitkeep = !!(ethereum && ethereum.isBitKeep);
const icon = Object.keys(SUPPORTED_WALLETS)
.filter(
(k) =>
SUPPORTED_WALLETS[k].connector === connector &&
(connector !== injected ||
isBitkeep === (k === 'BITKEEP') ||
(!isBitkeep && isMetaMask) === (k === 'METAMASK')),
(isBlockWallet && k === 'BLOCKWALLET') ||
(isBitkeep && k === 'BITKEEP') ||
(isMetaMask && k === 'METAMASK')),
)
.map((k) => SUPPORTED_WALLETS[k].iconName)[0];
return (
Expand Down
29 changes: 26 additions & 3 deletions src/components/WalletModal/PendingView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AbstractConnector } from '@web3-react/abstract-connector';
import React from 'react';
import { Box, CircularProgress, Typography } from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';
import { SUPPORTED_WALLETS } from 'constants/index';
import { GlobalConst, SUPPORTED_WALLETS } from 'constants/index';
import { injected } from 'connectors';
import Option from './Option';

Expand Down Expand Up @@ -50,6 +50,8 @@ const PendingView: React.FC<PendingViewProps> = ({
tryActivation,
}) => {
const isMetamask = (window as any).ethereum?.isMetaMask;
const isBlockWallet = (window as any).ethereum?.isBlockWallet;
const isBitKeep = (window as any).ethereum?.isBitKeep;
const classes = useStyles();

return (
Expand Down Expand Up @@ -81,10 +83,31 @@ const PendingView: React.FC<PendingViewProps> = ({
const option = SUPPORTED_WALLETS[key];
if (option.connector === connector) {
if (option.connector === injected) {
if (isMetamask && option.name !== 'MetaMask') {
if (isMetamask && option.name !== GlobalConst.walletName.METAMASK) {
return null;
}
if (!isMetamask && option.name === 'MetaMask') {
if (
!isMetamask &&
option.name === GlobalConst.walletName.METAMASK
) {
return null;
}
if (isBitKeep && option.name !== GlobalConst.walletName.BITKEEP) {
return null;
}
if (!isBitKeep && option.name === GlobalConst.walletName.BITKEEP) {
return null;
}
if (
isBlockWallet &&
option.name !== GlobalConst.walletName.BLOCKWALLET
) {
return null;
}
if (
!isBlockWallet &&
option.name === GlobalConst.walletName.BLOCKWALLET
) {
return null;
}
}
Expand Down
45 changes: 35 additions & 10 deletions src/components/WalletModal/WalletModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import MetamaskIcon from 'assets/images/metamask.png';
import { ReactComponent as Close } from 'assets/images/CloseIcon.svg';
import { fortmatic, injected, portis, safeApp } from 'connectors';
import { OVERLAY_READY } from 'connectors/Fortmatic';
import { SUPPORTED_WALLETS } from 'constants/index';
import { GlobalConst, SUPPORTED_WALLETS } from 'constants/index';
import usePrevious from 'hooks/usePrevious';
import { ApplicationModal } from 'state/application/actions';
import { useModalOpen, useWalletModalToggle } from 'state/application/hooks';
Expand Down Expand Up @@ -161,8 +161,9 @@ const WalletModal: React.FC<WalletModalProps> = ({
// get wallets user can switch too, depending on device/browser
function getOptions() {
const { ethereum, web3 } = window as any;
const isMetamask = ethereum && ethereum.isMetaMask;
const isBitKeep = window.ethereum && (window.ethereum as any).isBitKeep;
const isMetamask = ethereum && !ethereum.isBitKeep && ethereum.isMetaMask;
const isBlockWallet = ethereum && ethereum.isBlockWallet;
const isBitKeep = ethereum && ethereum.isBitKeep;
return Object.keys(SUPPORTED_WALLETS).map((key) => {
const option = SUPPORTED_WALLETS[key];
//disable safe app by in the list
Expand All @@ -189,8 +190,12 @@ const WalletModal: React.FC<WalletModalProps> = ({
active={
option.connector === connector &&
(connector !== injected ||
isBitKeep === (option.name === 'BitKeep') ||
(!isBitKeep && isMetamask) === (option.name === 'MetaMask'))
isBlockWallet ===
(option.name === GlobalConst.walletName.BLOCKWALLET) ||
isBitKeep ===
(option.name === GlobalConst.walletName.BITKEEP) ||
isMetamask ===
(option.name === GlobalConst.walletName.METAMASK))
}
color={option.color}
link={option.href}
Expand All @@ -207,7 +212,7 @@ const WalletModal: React.FC<WalletModalProps> = ({
if (option.connector === injected) {
// don't show injected if there's no injected provider
if (!(web3 || ethereum)) {
if (option.name === 'MetaMask') {
if (option.name === GlobalConst.walletName.METAMASK) {
return (
<Option
id={`connect-${key}`}
Expand All @@ -224,11 +229,27 @@ const WalletModal: React.FC<WalletModalProps> = ({
}
}
// don't return metamask if injected provider isn't metamask
else if (option.name === 'MetaMask' && !isMetamask) {
else if (
option.name === GlobalConst.walletName.METAMASK &&
!isMetamask
) {
return null;
} else if (
option.name === GlobalConst.walletName.BITKEEP &&
!isBitKeep
) {
return null;
} else if (
option.name === GlobalConst.walletName.BLOCKWALLET &&
!isBlockWallet
) {
return null;
}
// likewise for generic
else if (option.name === 'Injected' && isMetamask) {
else if (
option.name === GlobalConst.walletName.INJECTED &&
(isMetamask || isBitKeep || isBlockWallet)
) {
return null;
}
}
Expand All @@ -248,8 +269,12 @@ const WalletModal: React.FC<WalletModalProps> = ({
active={
option.connector === connector &&
(connector !== injected ||
isBitKeep === (option.name === 'BitKeep') ||
(!isBitKeep && isMetamask) === (option.name === 'MetaMask'))
isBlockWallet ===
(option.name === GlobalConst.walletName.BLOCKWALLET) ||
isBitKeep ===
(option.name === GlobalConst.walletName.BITKEEP) ||
isMetamask ===
(option.name === GlobalConst.walletName.METAMASK))
}
color={option.color}
link={option.href}
Expand Down
36 changes: 28 additions & 8 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
safeApp,
} from '../connectors';
import MetamaskIcon from 'assets/images/metamask.png';
import BlockWalletIcon from 'assets/images/blockwalletIcon.svg';
import BitKeepIcon from 'assets/images/bitkeep.png';
import CoinbaseWalletIcon from 'assets/images/coinbaseWalletIcon.svg';
import WalletConnectIcon from 'assets/images/walletConnectIcon.svg';
Expand Down Expand Up @@ -93,28 +94,47 @@ export const GlobalConst = {
LPFARM_INDEX: 0,
DUALFARM_INDEX: 1,
},
walletName: {
METAMASK: 'Metamask',
BLOCKWALLET: 'BlockWallet',
BITKEEP: 'BitKeep',
INJECTED: 'Injected',
SAFE_APP: 'Gnosis Safe App',
ARKANE_CONNECT: 'Venly',
Portis: 'Portis',
WALLET_LINK: 'Coinbase Wallet',
WALLET_CONNECT: 'WalletConnect',
},
};

export const SUPPORTED_WALLETS: { [key: string]: WalletInfo } = {
METAMASK: {
connector: injected,
name: 'MetaMask',
name: GlobalConst.walletName.METAMASK,
iconName: MetamaskIcon,
description: 'Easy-to-use browser extension.',
href: null,
color: '#E8831D',
},
BLOCKWALLET: {
connector: injected,
name: GlobalConst.walletName.BLOCKWALLET,
iconName: BlockWalletIcon,
description: 'BlockWallet browser extension.',
href: null,
color: '#1673ff',
},
BITKEEP: {
connector: injected,
name: 'BitKeep',
name: GlobalConst.walletName.BITKEEP,
iconName: BitKeepIcon,
description: 'BitKeep browser extension.',
href: null,
color: '#E8831D',
},
INJECTED: {
connector: injected,
name: 'Injected',
name: GlobalConst.walletName.INJECTED,
iconName: 'arrow-right.svg',
description: 'Injected web3 provider.',
href: null,
Expand All @@ -123,7 +143,7 @@ export const SUPPORTED_WALLETS: { [key: string]: WalletInfo } = {
},
SAFE_APP: {
connector: safeApp,
name: 'Gnosis Safe App',
name: GlobalConst.walletName.SAFE_APP,
iconName: GnosisIcon,
description: 'Login using gnosis safe app',
href: null,
Expand All @@ -132,15 +152,15 @@ export const SUPPORTED_WALLETS: { [key: string]: WalletInfo } = {
},
ARKANE_CONNECT: {
connector: arkaneconnect,
name: 'Venly',
name: GlobalConst.walletName.ARKANE_CONNECT,
iconName: VenlyIcon,
description: 'Login using Venly hosted wallet.',
href: null,
color: '#4196FC',
},
Portis: {
connector: portis,
name: 'Portis',
name: GlobalConst.walletName.Portis,
iconName: PortisIcon,
description: 'Login using Portis hosted wallet',
href: null,
Expand All @@ -149,15 +169,15 @@ export const SUPPORTED_WALLETS: { [key: string]: WalletInfo } = {
},
WALLET_LINK: {
connector: walletlink,
name: 'Coinbase Wallet',
name: GlobalConst.walletName.WALLET_LINK,
iconName: CoinbaseWalletIcon,
description: 'Use Coinbase Wallet app on mobile device',
href: null,
color: '#315CF5',
},
WALLET_CONNECT: {
connector: walletconnect,
name: 'WalletConnect',
name: GlobalConst.walletName.WALLET_CONNECT,
iconName: WalletConnectIcon,
description: 'Connect to Trust Wallet, Rainbow Wallet and more...',
href: null,
Expand Down

0 comments on commit 15d2432

Please sign in to comment.