From 4f61154996baa621318cfb602c0c6e123d7f8d7a Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 14 Jul 2020 17:41:45 +0200 Subject: [PATCH] adapt network detection --- app.config.js | 4 ++- src/components/molecules/Wallet/Account.tsx | 10 +++++-- src/components/molecules/Wallet/Feedback.tsx | 30 +++++++++++--------- src/utils/wallet.ts | 6 ++++ 4 files changed, 33 insertions(+), 17 deletions(-) diff --git a/app.config.js b/app.config.js index d7a6bd3e2..29c348c86 100644 --- a/app.config.js +++ b/app.config.js @@ -10,5 +10,7 @@ module.exports = { process.env.FACTORY_ADDRESS || '0x00c6A0BC5cD0078d6Cd0b659E8061B404cfa5704', verbose: 3 - } + }, + // Main, Rinkeby, Kovan + networks: [1, 4, 42] } diff --git a/src/components/molecules/Wallet/Account.tsx b/src/components/molecules/Wallet/Account.tsx index 670d196ee..203953bd9 100644 --- a/src/components/molecules/Wallet/Account.tsx +++ b/src/components/molecules/Wallet/Account.tsx @@ -4,7 +4,11 @@ import { useOcean } from '@oceanprotocol/react' import { toDataUrl } from 'ethereum-blockies' import { ReactComponent as Caret } from '../../../images/caret.svg' import Status from '../../atoms/Status' -import { accountTruncate, connectWallet } from '../../../utils/wallet' +import { + accountTruncate, + connectWallet, + isCorrectNetwork +} from '../../../utils/wallet' const Blockies = ({ account }: { account: string | undefined }) => { if (!account) return null @@ -23,8 +27,8 @@ const Blockies = ({ account }: { account: string | undefined }) => { // Forward ref for Tippy.js // eslint-disable-next-line const Account = React.forwardRef((props, ref: any) => { - const { accountId, status, connect } = useOcean() - const hasSuccess = status === 1 + const { accountId, status, connect, chainId } = useOcean() + const hasSuccess = status === 1 && isCorrectNetwork(chainId) return accountId ? (