Initial commit: simple frontend helper for mortgageFi, basic debt repayment and debt viewing functionality works, tested for both cbbtc and wbtc and not weth
This commit is contained in:
61
providers/Web3Provider.tsx
Normal file
61
providers/Web3Provider.tsx
Normal file
@@ -0,0 +1,61 @@
|
||||
'use client';
|
||||
|
||||
import { createWeb3Modal } from '@web3modal/wagmi/react';
|
||||
import { WagmiProvider, createConfig, http } from 'wagmi';
|
||||
import { mainnet, sepolia, base, arbitrum } from 'wagmi/chains';
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||
import { PropsWithChildren, useEffect, useState } from 'react';
|
||||
|
||||
const projectId = process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID || '';
|
||||
if (!projectId) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn('[Web3] Missing NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID. WalletConnect will be limited.');
|
||||
}
|
||||
|
||||
const metadata = {
|
||||
name: 'MortgageFi',
|
||||
description: 'Decentralized Mortgage Lending Platform',
|
||||
url: 'https://mortgagefi.app',
|
||||
icons: ['https://mortgagefi.app/logo.png']
|
||||
};
|
||||
|
||||
const config = createConfig({
|
||||
chains: [base, arbitrum, mainnet, sepolia],
|
||||
transports: {
|
||||
[base.id]: http(),
|
||||
[arbitrum.id]: http(),
|
||||
[mainnet.id]: http(),
|
||||
[sepolia.id]: http(),
|
||||
},
|
||||
ssr: true,
|
||||
});
|
||||
|
||||
createWeb3Modal({
|
||||
wagmiConfig: config,
|
||||
projectId: projectId || 'missing_project_id',
|
||||
enableAnalytics: true,
|
||||
enableOnramp: true,
|
||||
themeMode: 'light',
|
||||
themeVariables: {
|
||||
'--w3m-accent': '#4F46E5',
|
||||
'--w3m-font-family': 'Inter, sans-serif',
|
||||
},
|
||||
});
|
||||
|
||||
const queryClient = new QueryClient();
|
||||
|
||||
export function Web3Provider({ children }: PropsWithChildren) {
|
||||
const [mounted, setMounted] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setMounted(true);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<WagmiProvider config={config}>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
{mounted && children}
|
||||
</QueryClientProvider>
|
||||
</WagmiProvider>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user