Skip to content

Commit b9ff759

Browse files
Shawclaude
andcommitted
fix(bsc): repair wallet connection on /bsc payment page
Three bugs prevented wallet connection from working end-to-end: 1. /bsc was missing from ConditionalWalletProviders route list, so the global wallet provider tree never mounted for that page. 2. The page worked around this by creating its own inline LazyStewardWalletProviders, but that introduced a nested QueryClientProvider isolated from the root app QueryClient. useAttachWallet's invalidateQueries({ queryKey: ['user-profile'] }) fired against the wrong client, so the user profile never refreshed after wallet verification and the UI stayed stuck on the attach step. 3. The nested QueryClientProvider in StewardWalletProviders was also the source of the prior wagmi circular-chunk bug (documented in vite.config.ts) that caused TypeError: n is not a function on /bsc in older production builds. Fix: add /bsc and /bsc/* to WALLET_ROUTE_PATTERNS, remove the inline provider wrapper from bsc/page.tsx (ConditionalWalletProviders covers it at layout level), and remove the isolated QueryClientProvider from StewardWalletProviders so all hooks share the root QueryClient. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 053e31f commit b9ff759

3 files changed

Lines changed: 29 additions & 38 deletions

File tree

packages/cloud-frontend/src/pages/bsc/page.tsx

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ import { Link } from "react-router-dom";
1818
import type { CryptoStatusResponse } from "@/lib/types/crypto-status";
1919
import { useUserProfile } from "../../lib/data/user";
2020

21-
const LazyStewardWalletProviders = lazy(async () => {
22-
const mod = await import("../login/steward-wallet-providers");
23-
return { default: mod.StewardWalletProviders };
24-
});
25-
2621
const LazyDirectCryptoCreditCard = lazy(async () => {
2722
const mod = await import(
2823
"../../dashboard/billing/_components/direct-crypto-credit-card"
@@ -227,28 +222,26 @@ export default function BscPromoPage() {
227222
</Card>
228223
}
229224
>
230-
<LazyStewardWalletProviders>
231-
{user.wallet_address ? (
232-
<LazyDirectCryptoCreditCard
233-
amount={amountValue}
234-
promoCode="bsc"
235-
status={status}
236-
accountWalletAddress={user.wallet_address}
237-
surface="cloud"
238-
lockedNetwork="bsc"
239-
onSuccess={() => undefined}
240-
/>
241-
) : (
242-
// OAuth signups (Google / Discord / GitHub / Magic
243-
// Link / Passkey) land here. The direct-crypto-payments
244-
// endpoint requires `user.wallet_address`, so until
245-
// they verify a wallet against their account the pay
246-
// button is a dead-end. AttachWalletCard drives the
247-
// SIWE flow that fixes that, then `useUserProfile`
248-
// refetches and this branch swaps to the purchase UI.
249-
<LazyAttachWalletCard chainId={56} />
250-
)}
251-
</LazyStewardWalletProviders>
225+
{user.wallet_address ? (
226+
<LazyDirectCryptoCreditCard
227+
amount={amountValue}
228+
promoCode="bsc"
229+
status={status}
230+
accountWalletAddress={user.wallet_address}
231+
surface="cloud"
232+
lockedNetwork="bsc"
233+
onSuccess={() => undefined}
234+
/>
235+
) : (
236+
// OAuth signups (Google / Discord / GitHub / Magic
237+
// Link / Passkey) land here. The direct-crypto-payments
238+
// endpoint requires `user.wallet_address`, so until
239+
// they verify a wallet against their account the pay
240+
// button is a dead-end. AttachWalletCard drives the
241+
// SIWE flow that fixes that, then `useUserProfile`
242+
// refetches and this branch swaps to the purchase UI.
243+
<LazyAttachWalletCard chainId={56} />
244+
)}
252245
</Suspense>
253246
)}
254247
</div>

packages/cloud-frontend/src/pages/login/steward-wallet-providers.tsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
PhantomWalletAdapter,
1414
SolflareWalletAdapter,
1515
} from "@solana/wallet-adapter-wallets";
16-
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
1716
import { useMemo } from "react";
1817
import { http, WagmiProvider } from "wagmi";
1918
import { base, bsc, mainnet } from "wagmi/chains";
@@ -65,7 +64,6 @@ export function StewardWalletProviders({
6564
[alchemyKey, appUrl, walletConnectProjectId],
6665
);
6766

68-
const queryClient = useMemo(() => new QueryClient(), []);
6967
const rainbowTheme = useMemo(
7068
() =>
7169
darkTheme({
@@ -83,15 +81,13 @@ export function StewardWalletProviders({
8381

8482
return (
8583
<WagmiProvider config={evmConfig}>
86-
<QueryClientProvider client={queryClient}>
87-
<RainbowKitProvider theme={rainbowTheme} modalSize="compact">
88-
<ConnectionProvider endpoint={solanaEndpoint}>
89-
<WalletProvider wallets={solanaWallets} autoConnect>
90-
<WalletModalProvider>{children}</WalletModalProvider>
91-
</WalletProvider>
92-
</ConnectionProvider>
93-
</RainbowKitProvider>
94-
</QueryClientProvider>
84+
<RainbowKitProvider theme={rainbowTheme} modalSize="compact">
85+
<ConnectionProvider endpoint={solanaEndpoint}>
86+
<WalletProvider wallets={solanaWallets} autoConnect>
87+
<WalletModalProvider>{children}</WalletModalProvider>
88+
</WalletProvider>
89+
</ConnectionProvider>
90+
</RainbowKitProvider>
9591
</WagmiProvider>
9692
);
9793
}

packages/cloud-frontend/src/providers/ConditionalWalletProviders.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import { matchPath, useLocation } from "react-router-dom";
1616
const WALLET_ROUTE_PATTERNS = [
1717
"/login",
1818
"/login/*",
19+
"/bsc",
20+
"/bsc/*",
1921
"/dashboard/billing",
2022
"/dashboard/billing/*",
2123
"/dashboard/settings",

0 commit comments

Comments
 (0)