diff --git a/packages/widget/src/AppDrawer.tsx b/packages/widget/src/AppDrawer.tsx index 432ae62db..a9570a09c 100644 --- a/packages/widget/src/AppDrawer.tsx +++ b/packages/widget/src/AppDrawer.tsx @@ -19,7 +19,7 @@ import { WidgetConfig } from './types'; export type AppDrawerProps = DrawerProps & { elementRef?: RefObject; - config: WidgetConfig; + config?: WidgetConfig; }; export interface AppDrawerBase { diff --git a/packages/widget/src/AppProvider.tsx b/packages/widget/src/AppProvider.tsx index fea11cb13..2453ce0ad 100644 --- a/packages/widget/src/AppProvider.tsx +++ b/packages/widget/src/AppProvider.tsx @@ -9,7 +9,7 @@ import { WalletProvider } from './providers/WalletProvider'; import { WidgetProvider } from './providers/WidgetProvider'; export interface AppProps { - config: WidgetConfig; + config?: WidgetConfig; } const QueryProvider = QueryClientProvider as FC< diff --git a/packages/widget/src/providers/WidgetProvider/WidgetProvider.tsx b/packages/widget/src/providers/WidgetProvider/WidgetProvider.tsx index 352e962fc..ebe10aa72 100644 --- a/packages/widget/src/providers/WidgetProvider/WidgetProvider.tsx +++ b/packages/widget/src/providers/WidgetProvider/WidgetProvider.tsx @@ -17,11 +17,11 @@ export const useWidgetConfig = (): WidgetContextProps => export const WidgetProvider: React.FC< React.PropsWithChildren -> = ({ children, config: { fromChain, toChain, ...other } }) => { +> = ({ + children, + config: { fromChain, fromToken, toChain, toToken, ...config } = {}, +}) => { const value = useMemo((): WidgetContextProps => { - const config = { - ...other, - }; try { return { ...config, @@ -37,14 +37,14 @@ export const WidgetProvider: React.FC< : typeof toChain === 'string' ? getChainByKey(toChain.toLowerCase() as ChainKey).id : ChainId.ETH, - fromToken: config.fromToken?.toLowerCase(), - toToken: config.toToken?.toLowerCase(), + fromToken: fromToken?.toLowerCase(), + toToken: toToken?.toLowerCase(), }; } catch (e) { console.warn(e); return config; } - }, [fromChain, other, toChain]); + }, [config, fromChain, fromToken, toChain, toToken]); return ( {children} ); diff --git a/packages/widget/src/providers/WidgetProvider/types.ts b/packages/widget/src/providers/WidgetProvider/types.ts index 91965fb3a..9615129ae 100644 --- a/packages/widget/src/providers/WidgetProvider/types.ts +++ b/packages/widget/src/providers/WidgetProvider/types.ts @@ -6,5 +6,5 @@ export interface WidgetContextProps extends WidgetConfig { } export interface WidgetProviderProps { - config: WidgetConfig; + config?: WidgetConfig; }