feat: add WalletProviders with connector + react-query
This commit is contained in:
44
app/src/providers/WalletProviders.tsx
Normal file
44
app/src/providers/WalletProviders.tsx
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import type { ReactNode } from 'react'
|
||||||
|
import { useMemo } from 'react'
|
||||||
|
import { AppProvider, getDefaultConfig, getDefaultMobileConfig } from '@solana/connector/react'
|
||||||
|
import { QueryClientProvider } from '@tanstack/react-query'
|
||||||
|
import { queryClient } from '@/lib/queryClient'
|
||||||
|
|
||||||
|
function getOrigin() {
|
||||||
|
if (typeof window !== 'undefined') return window.location.origin
|
||||||
|
return 'http://localhost:3000'
|
||||||
|
}
|
||||||
|
|
||||||
|
export function WalletProviders({ children }: { children: ReactNode }) {
|
||||||
|
const connectorConfig = useMemo(
|
||||||
|
() =>
|
||||||
|
getDefaultConfig({
|
||||||
|
appName: 'Solisting Explorer',
|
||||||
|
appUrl: getOrigin(),
|
||||||
|
autoConnect: true,
|
||||||
|
clusters: [
|
||||||
|
{ id: 'solana:localnet' as const, label: 'Localnet', url: 'http://localhost:8899' },
|
||||||
|
{ id: 'solana:devnet' as const, label: 'Devnet', url: 'https://api.devnet.solana.com' },
|
||||||
|
{
|
||||||
|
id: 'solana:mainnet' as const,
|
||||||
|
label: 'Mainnet',
|
||||||
|
url: 'https://api.mainnet-beta.solana.com',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
[],
|
||||||
|
)
|
||||||
|
|
||||||
|
const mobile = useMemo(
|
||||||
|
() => getDefaultMobileConfig({ appName: 'Solisting Explorer', appUrl: getOrigin() }),
|
||||||
|
[],
|
||||||
|
)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<AppProvider connectorConfig={connectorConfig} mobile={mobile}>
|
||||||
|
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
||||||
|
</AppProvider>
|
||||||
|
)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user