File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,14 +36,14 @@ export function Layout() {
3636 initializeNetworkDetection ( )
3737 } , [ ] )
3838
39- // Initialize AppKit once mini app context is ready
39+ // Initialize AppKit once mini app context is ready AND network is detected
4040 useEffect ( ( ) => {
4141 const initialize = async ( ) => {
42- if ( ! isInitialized ) return
42+ if ( ! isInitialized || ! detectedNetwork ) return
4343
4444 try {
45- // Initialize AppKit with conditional Farcaster support
46- await initializeAppKit ( )
45+ // Initialize AppKit with the detected network
46+ await initializeAppKit ( detectedNetwork )
4747 setAppKitInitialized ( true )
4848 } catch ( error ) {
4949 console . error ( 'Failed to initialize AppKit:' , error )
@@ -52,7 +52,7 @@ export function Layout() {
5252 }
5353
5454 initialize ( )
55- } , [ isInitialized ] )
55+ } , [ isInitialized , detectedNetwork ] )
5656
5757 // Switch to detected network only if auto-detection is enabled
5858 useEffect ( ( ) => {
Original file line number Diff line number Diff line change 11import { EthersAdapter } from '@reown/appkit-adapter-ethers'
22import { AppKit , createAppKit } from '@reown/appkit/react'
3- import { getConfiguredNetwork } from './network-config '
3+ import type { AppKitNetwork } from '@reown/appkit/networks '
44
55// 1. Get projectId from environment
66const projectId = import . meta. env . WALLETCONNECT_PROJECT_ID
@@ -13,23 +13,21 @@ const metadata = {
1313 icons : [ '/images/davinci-icon-small.png' ] ,
1414}
1515
16- // 3. Get configured network
17- const network = getConfiguredNetwork ( )
18-
19- // 4. Create Ethers Adapter with conditional provider
16+ // 3. Create Ethers Adapter with conditional provider
2017const ethersAdapter = new EthersAdapter ( )
2118
2219let appKit : AppKit | null = null
2320
2421/**
25- * Initialize AppKit - simplified version since mini app logic is now in context
22+ * Initialize AppKit with the detected network
23+ * @param network The network to initialize AppKit with
2624 */
27- export async function initializeAppKit ( ) {
25+ export async function initializeAppKit ( network : AppKitNetwork ) {
2826 if ( appKit ) {
2927 return appKit
3028 }
3129
32- console . log ( 'Initializing AppKit...' )
30+ console . log ( 'Initializing AppKit with network:' , network . name )
3331
3432 // Create standard AppKit (works for both mini app and regular web)
3533 appKit = createAppKit ( {
Original file line number Diff line number Diff line change @@ -7,8 +7,6 @@ import { OfflineIndicator } from '~components/offline-indicator'
77import { VocdoniApiProvider } from '~components/vocdoni-api-context'
88import { MiniAppProvider } from '~contexts/MiniAppContext'
99import { RouterProvider } from '~router'
10- // Initialize AppKit
11- import '~lib/appkit'
1210
1311import '@fontsource/averia-libre/400.css'
1412import '@fontsource/averia-libre/700.css'
You can’t perform that action at this time.
0 commit comments