small fixes

This commit is contained in:
thesn10
2026-05-23 15:38:35 +02:00
parent 9b7391677c
commit 81bbbd7e57
3 changed files with 13 additions and 10 deletions

View File

@@ -4,6 +4,8 @@ const nextConfig: NextConfig = {
transpilePackages: [ transpilePackages: [
'@tamagui/lucide-icons-2', '@tamagui/lucide-icons-2',
'@descro/sdk', '@descro/sdk',
'@solana/connector',
'@wallet-ui/core',
], ],
turbopack: { turbopack: {
resolveAlias: { resolveAlias: {

View File

@@ -2,8 +2,7 @@
import type { ReactNode } from 'react' import type { ReactNode } from 'react'
import { useMemo } from 'react' import { useMemo } from 'react'
import { AppProvider } from '@solana/connector/react' import { AppProvider, getDefaultConfig, getDefaultMobileConfig } from '@solana/connector/react'
import { getDefaultConfig } from '@solana/connector/headless'
function getOrigin() { function getOrigin() {
if (typeof window !== 'undefined') return window.location.origin if (typeof window !== 'undefined') return window.location.origin
@@ -33,5 +32,10 @@ export function WalletProviders({ children }: { children: ReactNode }) {
[], [],
) )
return <AppProvider connectorConfig={connectorConfig}>{children}</AppProvider> const mobile = useMemo(
() => getDefaultMobileConfig({ appName: 'Descro', appUrl: getOrigin() }),
[],
)
return <AppProvider connectorConfig={connectorConfig} mobile={mobile}>{children}</AppProvider>
} }

View File

@@ -1,13 +1,10 @@
'use client' 'use client'
import { useState } from 'react' import { useState } from 'react'
import { useConnector, useConnectWallet, useDisconnectWallet, useWalletConnectors } from '@solana/connector/react' import { useConnector } from '@solana/connector/react'
export function WalletButton() { export function WalletButton() {
const { isConnected, isConnecting, account, connector } = useConnector() const { isConnected, isConnecting, account, connector, connectWallet, disconnectWallet, connectors } = useConnector()
const { connect } = useConnectWallet()
const { disconnect } = useDisconnectWallet()
const connectors = useWalletConnectors()
const [showList, setShowList] = useState(false) const [showList, setShowList] = useState(false)
const baseStyle: React.CSSProperties = { const baseStyle: React.CSSProperties = {
@@ -24,7 +21,7 @@ export function WalletButton() {
if (isConnected && account) { if (isConnected && account) {
const short = `${account.slice(0, 4)}${account.slice(-4)}` const short = `${account.slice(0, 4)}${account.slice(-4)}`
return ( return (
<button style={{ ...baseStyle, backgroundColor: '#2e7d32' }} onClick={() => disconnect()}> <button style={{ ...baseStyle, backgroundColor: '#2e7d32' }} onClick={() => disconnectWallet()}>
{connector?.icon && ( {connector?.icon && (
<img src={connector.icon} width={16} height={16} alt="" style={{ marginRight: 6, verticalAlign: 'middle', borderRadius: 4 }} /> <img src={connector.icon} width={16} height={16} alt="" style={{ marginRight: 6, verticalAlign: 'middle', borderRadius: 4 }} />
)} )}
@@ -47,7 +44,7 @@ export function WalletButton() {
{connectors.map((w) => ( {connectors.map((w) => (
<button <button
key={w.id} key={w.id}
onClick={() => { connect(w.id); setShowList(false) }} onClick={() => { connectWallet(w.id); setShowList(false) }}
style={{ style={{
display: 'flex', alignItems: 'center', gap: 8, width: '100%', display: 'flex', alignItems: 'center', gap: 8, width: '100%',
padding: '8px 12px', border: 'none', background: 'none', padding: '8px 12px', border: 'none', background: 'none',