fix(wallet): support no-signature wallet connect

This commit is contained in:
TerryM
2026-06-02 21:52:15 +08:00
parent 803d3d57c1
commit 4d38c4513d
3 changed files with 119 additions and 72 deletions

View File

@@ -51,9 +51,14 @@ export function WalletLoginModal() {
wc.reset();
};
const startWalletLogin = (kind: WalletKind) => {
const selectWallet = (kind: WalletKind) => {
setSelected(kind);
void wc.start(kind);
wc.reset();
};
const startWalletLogin = (kind: WalletKind, mode: "deeplink" | "qr") => {
setSelected(kind);
void wc.start(kind, mode);
};
return (
@@ -92,34 +97,63 @@ export function WalletLoginModal() {
const connecting = active && wc.state === "connecting";
const signing = active && wc.state === "signing";
return (
<button
<div
key={kind}
type="button"
onClick={() => startWalletLogin(kind)}
disabled={!wc.available || busy}
className={`flex items-center gap-3 rounded-2xl border px-4 py-4 text-left transition ${
className={`rounded-2xl border p-3 transition ${
active
? "border-ark-gold/60 bg-ark-gold/10"
: "border-white/10 bg-[#20202a] hover:border-ark-gold/50 hover:bg-ark-gold/10"
} disabled:cursor-wait disabled:opacity-70`}
: "border-white/10 bg-[#20202a]"
}`}
>
<WalletBrandIcon kind={kind} size={32} />
<span className="min-w-0 flex-1">
<span className="block text-base font-semibold text-neutral-100">
{walletName(kind)}
<button
type="button"
onClick={() =>
mobileDevice
? selectWallet(kind)
: startWalletLogin(kind, "qr")
}
disabled={!wc.available || busy}
className="flex w-full items-center gap-3 text-left disabled:cursor-wait disabled:opacity-70"
>
<WalletBrandIcon kind={kind} size={32} />
<span className="min-w-0 flex-1">
<span className="block text-base font-semibold text-neutral-100">
{walletName(kind)}
</span>
<span className="mt-1 block text-xs leading-5 text-neutral-400">
{connecting
? t("walletConnecting")
: signing
? t("walletSigning")
: walletHint(kind)}
</span>
</span>
<span className="mt-1 block text-xs leading-5 text-neutral-400">
{connecting
? t("walletConnecting")
: signing
? t("walletSigning")
: walletHint(kind)}
</span>
</span>
{connecting || signing ? (
<LoaderCircle className="h-4 w-4 animate-spin text-ark-gold" />
{connecting || signing ? (
<LoaderCircle className="h-4 w-4 animate-spin text-ark-gold" />
) : null}
</button>
{mobileDevice && active ? (
<div className="mt-3 grid grid-cols-2 gap-2">
<button
type="button"
onClick={() => startWalletLogin(kind, "deeplink")}
disabled={!wc.available || busy}
className="rounded-full bg-ark-gold px-3 py-2 text-sm font-bold text-black transition hover:bg-ark-gold2 disabled:cursor-wait disabled:opacity-70"
>
{t("walletOpenWalletApp")}
</button>
<button
type="button"
onClick={() => startWalletLogin(kind, "qr")}
disabled={!wc.available || busy}
className="rounded-full border border-ark-gold/50 px-3 py-2 text-sm font-semibold text-ark-gold transition hover:bg-ark-gold/10 disabled:cursor-wait disabled:opacity-70"
>
{t("walletQrLogin")}
</button>
</div>
) : null}
</button>
</div>
);
})}
</div>