diff --git a/src/config/Theme/index.ts b/src/config/Theme/index.ts index 74e6654..7eeb926 100644 --- a/src/config/Theme/index.ts +++ b/src/config/Theme/index.ts @@ -8,7 +8,7 @@ export const getCustomThemes = () => { light: lightTheme, dark: darkTheme, }, - mui: getMuiThemeConfig, + getMui: getMuiThemeConfig, rainbow: rainbowTheme, }; }; diff --git a/src/config/env.ts b/src/config/env.ts index 4d3ba54..923e670 100644 --- a/src/config/env.ts +++ b/src/config/env.ts @@ -1,13 +1,11 @@ import { Env } from '~/types'; -export const getEnv = (): Env => { - const NEXT_PUBLIC_RPC_URL = process.env.NEXT_PUBLIC_RPC_URL; - const NEXT_PUBLIC_PROJECT_ID = process.env.NEXT_PUBLIC_PROJECT_ID; - const NEXT_PUBLIC_ALCHEMY_KEY = process.env.NEXT_PUBLIC_ALCHEMY_KEY; +const env: Env = { + RPC_URL: process.env.NEXT_PUBLIC_RPC_URL as string, + PROJECT_ID: process.env.NEXT_PUBLIC_PROJECT_ID as string, + ALCHEMY_KEY: process.env.NEXT_PUBLIC_ALCHEMY_KEY as string, +}; - return { - RPC_URL: NEXT_PUBLIC_RPC_URL as string, - PROJECT_ID: NEXT_PUBLIC_PROJECT_ID as string, - ALCHEMY_KEY: NEXT_PUBLIC_ALCHEMY_KEY as string, - }; +export const getEnv = (): Env => { + return env; }; diff --git a/src/config/index.ts b/src/config/index.ts index 3428c71..00898c2 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -12,7 +12,7 @@ export const publicClient = createPublicClient({ }); export const getConfig = (): Config => ({ - ...getEnv(), - ...getConstants(), - ...getCustomThemes(), + env: getEnv(), + constants: getConstants(), + customThemes: getCustomThemes(), }); diff --git a/src/providers/ThemeProvider.tsx b/src/providers/ThemeProvider.tsx index 565f26a..242ea6b 100644 --- a/src/providers/ThemeProvider.tsx +++ b/src/providers/ThemeProvider.tsx @@ -17,7 +17,7 @@ interface StateProps { export const ThemeContext = createContext({} as ContextType); export const ThemeProvider = ({ children }: StateProps) => { - const getMuiThemeConfig = getConfig().mui; + const { getMui: getMuiThemeConfig } = getConfig().customThemes; const defaultTheme = 'dark'; diff --git a/src/types/Config.ts b/src/types/Config.ts index 81d84a0..e438b60 100644 --- a/src/types/Config.ts +++ b/src/types/Config.ts @@ -10,4 +10,8 @@ export interface Constants { //... } -export interface Config extends Env, Constants, CustomThemes {} +export interface Config { + env: Env; + constants: Constants; + customThemes: CustomThemes; +} diff --git a/src/types/Theme.ts b/src/types/Theme.ts index 2f401ca..e51d03a 100644 --- a/src/types/Theme.ts +++ b/src/types/Theme.ts @@ -26,6 +26,6 @@ export interface CustomThemes { light: Theme; dark: Theme; }; - mui: (currentTheme: Theme, themeName: ThemeName) => MuiTheme; + getMui: (currentTheme: Theme, themeName: ThemeName) => MuiTheme; rainbow: RainbowTheme; } diff --git a/src/utils/config.ts b/src/utils/config.ts index f305006..4106654 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -4,7 +4,7 @@ import { createConfig, http, cookieStorage, createStorage } from 'wagmi'; import { localhost, sepolia } from 'wagmi/chains'; import { getConfig } from '~/config'; -const { PROJECT_ID } = getConfig(); +const { PROJECT_ID } = getConfig().env; const getWallets = () => { if (PROJECT_ID) { diff --git a/src/utils/getTheme.ts b/src/utils/getTheme.ts index 54d2b06..85118b1 100644 --- a/src/utils/getTheme.ts +++ b/src/utils/getTheme.ts @@ -2,7 +2,7 @@ import { getConfig } from '~/config'; import { Theme, ThemeName } from '~/types'; export const getTheme = (theme?: ThemeName): Theme => { - const { dark, light } = getConfig().main; + const { dark, light } = getConfig().customThemes.main; switch (theme) { case 'light':