diff --git a/apps/dcellar-web-ui/.env.example b/apps/dcellar-web-ui/.env.example index 0ab4ee5c..9ef8e52d 100644 --- a/apps/dcellar-web-ui/.env.example +++ b/apps/dcellar-web-ui/.env.example @@ -1,4 +1,7 @@ # For local development, copy this file to .env.local and update the values as needed. +# WalletConnect Cloud project ID for this environment. Set it before running the Next.js build. +NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID= + NEXT_PUBLIC_ENV=development NEXT_PUBLIC_GOOGLE_ANALYTICS_ID='' diff --git a/apps/dcellar-web-ui/src/context/WalletConnectContext/components/WalletConnectProvider.tsx b/apps/dcellar-web-ui/src/context/WalletConnectContext/components/WalletConnectProvider.tsx index 86c51a2a..f5c0dc97 100644 --- a/apps/dcellar-web-ui/src/context/WalletConnectContext/components/WalletConnectProvider.tsx +++ b/apps/dcellar-web-ui/src/context/WalletConnectContext/components/WalletConnectProvider.tsx @@ -7,19 +7,26 @@ import { GREENFIELD_CHAIN_ID } from '@/base/env'; import { metaMask, trustWallet, walletConnect } from '@totejs/walletkit/wallets'; import * as Sentry from '@sentry/nextjs'; import { reportEvent } from '@/utils/gtag'; -import * as process from 'process'; import { ReactNode } from 'react'; import { customTheme } from '@/base/theme/wallet'; import { DCLink } from '@/components/common/DCLink'; +const walletConnectProjectId = process.env.NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID?.trim() ?? ''; + +if (typeof window !== 'undefined' && !walletConnectProjectId) { + // eslint-disable-next-line no-console + console.warn( + 'WalletConnect is disabled. Set NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID before building dcellar-web-ui.', + ); +} + const config = createConfig( getDefaultConfig({ chains: [bscChain, greenFieldChain], appName: 'Connect a Wallet', autoConnect: true, - /* WC 2.0 requires a project ID (get one here: https://cloud.walletconnect.com/sign-in) */ - walletConnectProjectId: '89848e3205cafe0bf76c91aa1aaa71d0', - connectors: [trustWallet(), metaMask(), walletConnect()], + walletConnectProjectId, + connectors: [trustWallet(), metaMask(), ...(walletConnectProjectId ? [walletConnect()] : [])], }), );