diff --git a/src/services/mpc/config.ts b/src/services/mpc/config.ts index 5f782792c6..134909bd78 100644 --- a/src/services/mpc/config.ts +++ b/src/services/mpc/config.ts @@ -1,3 +1,5 @@ +import { IS_PRODUCTION } from '@/config/constants' + enum SocialWalletOptionsKeys { web3AuthClientId = 'web3AuthClientId', web3AuthAggregateVerifierId = 'web3AuthAggregateVerifierId', @@ -16,28 +18,24 @@ export const isSocialWalletOptions = (options: unknown): options is SocialWallet if (typeof options !== 'object' || options === null) { return false } - const keys = Object.keys(options) const hasRequiredKeys = - keys.length === 4 && - keys.includes(SocialWalletOptionsKeys.web3AuthClientId) && - keys.includes(SocialWalletOptionsKeys.web3AuthAggregateVerifierId) && - keys.includes(SocialWalletOptionsKeys.web3AuthSubverifierId) && - keys.includes(SocialWalletOptionsKeys.googleClientId) + SocialWalletOptionsKeys.web3AuthClientId in options && + SocialWalletOptionsKeys.web3AuthAggregateVerifierId in options && + SocialWalletOptionsKeys.web3AuthSubverifierId in options && + SocialWalletOptionsKeys.googleClientId in options const hasValues = Object.values(options).every(Boolean) return hasRequiredKeys && hasValues } /** env variables */ -const SOCIAL_WALLET_IS_PRODUCTION = process.env.NEXT_PUBLIC_IS_PRODUCTION === 'true' - 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 || '' try { - return JSON.parse(SOCIAL_WALLET_IS_PRODUCTION ? SOCIAL_WALLET_OPTIONS_PRODUCTION : SOCIAL_WALLET_OPTIONS_STAGING) + return JSON.parse(IS_PRODUCTION ? SOCIAL_WALLET_OPTIONS_PRODUCTION : SOCIAL_WALLET_OPTIONS_STAGING) } catch (error) { console.error(error) return {}