WalletProvider.connect() picked wallet_addEthereumChain params via `chainId === 1990 ? MAINNET : TESTNET` -- a ternary that only distinguishes QIE Mainnet from everything else. The live production site runs on the "demo" network (chainId 31337, the self-hosted anvil devnet backing https://qie-forge.vercel.app -- the only network actually deployed today). Any real visitor whose wallet didn't already have chain 31337 added would hit the wallet_addEthereumChain fallback and get offered QIE Testnet (1983, https://testnet.qie.digital/api/eth-rpc) instead -- the wrong chain, where none of this app's deployed contracts exist. The UI would report "connected" while every subsequent swap/deposit/borrow transaction silently targeted the wrong network. Fixed by building the add-chain params from whichever network is actually configured (getNetworkConfig()) instead of a hardcoded two-network guess, and dropped the now-redundant chainId parameter every one of the 5 call sites (SwapCard/VaultCard/LendCard/ LiquidityCard/WalletConnectButton) was separately re-deriving just to pass through to connect(). Verified: `tsc --noEmit` and `eslint` clean on every changed file; `next build` clean (no type errors); full workspace `npm test` (core 23/23 + cli 28/28, unchanged); a Node script against the built core package reproduces the pre-fix bug (chainId 31337 -> old logic picks TESTNET/1983) and confirms the fix (same input -> real demo chain 0x7a69 with the real self-hosted RPC URL); redeployed to https://qie-forge.vercel.app (vercel --prod + alias) and re-verified live: /, /swap, /pool, /vault all 200, /api/quote still returns 139579 for 1 WQIE, /vault's server-rendered stats bar still shows the documented 500000/480000/20000/4.00%/0/20000-100000 TUSD figures unchanged -- zero regressions from the refactor.
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
"use client";
|
|
|
|
import { useWallet } from "./WalletProvider";
|
|
import { WalletIcon } from "./icons";
|
|
|
|
function short(address: string): string {
|
|
return `${address.slice(0, 6)}…${address.slice(-4)}`;
|
|
}
|
|
|
|
export function WalletConnectButton() {
|
|
const { address, connecting, error, connect } = useWallet();
|
|
|
|
if (address) {
|
|
return (
|
|
<span className="inline-flex items-center gap-2 rounded-xl border border-border px-3 py-1.5 text-sm text-foreground">
|
|
<WalletIcon className="w-4 h-4 text-muted" />
|
|
{short(address)}
|
|
</span>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div className="flex flex-col items-end gap-1">
|
|
<button
|
|
onClick={() => connect()}
|
|
disabled={connecting}
|
|
className="btn-primary inline-flex items-center gap-2 px-4 py-2 text-sm"
|
|
>
|
|
<WalletIcon className="w-4 h-4" />
|
|
{connecting ? "Connecting…" : "Connect Wallet"}
|
|
</button>
|
|
{error && <span className="text-xs text-danger max-w-[220px] text-right">{error}</span>}
|
|
</div>
|
|
);
|
|
}
|