Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: don't load social login if no env var is set #3267

Merged
merged 2 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/hooks/wallets/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import walletConnect from '@web3-onboard/walletconnect'
import e2eWalletModule from '@/tests/e2e-wallet'
import { CGW_NAMES, WALLET_KEYS } from './consts'
import MpcModule from '@/services/mpc/SocialLoginModule'
import { SOCIAL_WALLET_OPTIONS } from '@/services/mpc/config'

const prefersDarkMode = (): boolean => {
return window?.matchMedia('(prefers-color-scheme: dark)')?.matches
Expand Down Expand Up @@ -70,6 +71,8 @@ export const getSupportedWallets = (chain: ChainInfo): WalletInit[] => {
}

export const isSocialWalletEnabled = (chain: ChainInfo | undefined): boolean => {
if (Object.keys(SOCIAL_WALLET_OPTIONS).length === 0) return false

if (!chain) return false

return chain.disabledWallets.every((label) => label !== CGW_NAMES.SOCIAL_LOGIN)
Expand Down
4 changes: 2 additions & 2 deletions src/services/mpc/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export const isSocialWalletOptions = (options: unknown): options is SocialWallet

/** env variables */
export const SOCIAL_WALLET_OPTIONS: any = (() => {
const SOCIAL_WALLET_OPTIONS_PRODUCTION = process.env.NEXT_PUBLIC_SOCIAL_WALLET_OPTIONS_PRODUCTION || ''
const SOCIAL_WALLET_OPTIONS_STAGING = process.env.NEXT_PUBLIC_SOCIAL_WALLET_OPTIONS_STAGING || ''
const SOCIAL_WALLET_OPTIONS_PRODUCTION = process.env.NEXT_PUBLIC_SOCIAL_WALLET_OPTIONS_PRODUCTION || '{}'
const SOCIAL_WALLET_OPTIONS_STAGING = process.env.NEXT_PUBLIC_SOCIAL_WALLET_OPTIONS_STAGING || '{}'

try {
return JSON.parse(IS_PRODUCTION ? SOCIAL_WALLET_OPTIONS_PRODUCTION : SOCIAL_WALLET_OPTIONS_STAGING)
Expand Down
Loading