Skip to content

Commit 933b8d5

Browse files
authored
Merge pull request #837 from Junman140/fix/issues-810-792-801-806
fix: wallet adapter compatibility, config import, and fee checks (closes #810, #792, #801, #806)
2 parents b84774d + 8b7307e commit 933b8d5

5 files changed

Lines changed: 31 additions & 10 deletions

File tree

.github/workflows/e2e.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
- uses: actions/checkout@v4
2424
with:
2525
ref: ${{ github.event.pull_request.head.sha || github.sha }}
26+
allow-unsafe-pr-checkout: true
2627
- uses: actions/setup-node@v4
2728
with:
2829
node-version: 20.x

.github/workflows/frontend.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
- uses: actions/checkout@v4
2828
with:
2929
ref: ${{ github.event.pull_request.head.sha || github.sha }}
30+
allow-unsafe-pr-checkout: true
3031
- uses: actions/setup-node@v4
3132
with:
3233
node-version: 20.x
@@ -51,6 +52,7 @@ jobs:
5152
- uses: actions/checkout@v4
5253
with:
5354
ref: ${{ github.event.pull_request.head.sha }}
55+
allow-unsafe-pr-checkout: true
5456
- uses: actions/setup-node@v4
5557
with:
5658
node-version: 20.x

frontend/src/app/profile/[username]/edit/page.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import { useEffect, useState } from "react";
44
import { useParams, useRouter } from "next/navigation";
55
import Link from "next/link";
6-
import { getAddress } from "@stellar/freighter-api";
76
import { AppShell } from "@/components/app-shell";
7+
import { getWalletAdapter, type WalletId } from "@/lib/wallet-adapters";
88
import { API_BASE_URL } from "@/lib/config";
99
import { apiFetch } from "@/lib/api-client";
1010
import { useToast } from "@/lib/use-toast";
@@ -93,8 +93,9 @@ export default function EditProfilePage() {
9393
}
9494
const profile: ProfileData = await res.json();
9595

96-
const result = await getAddress().catch(() => ({ address: "", error: "Freighter not available" }));
97-
const connectedAddress = "address" in result ? result.address : "";
96+
const walletId = localStorage.getItem("walletId") as WalletId | null;
97+
const adapter = walletId ? getWalletAdapter(walletId) : null;
98+
const connectedAddress = adapter ? await adapter.connect().catch(() => "") : "";
9899

99100
if (!connectedAddress) {
100101
// Wallet not connected or Freighter is locked — show a prompt instead of silently redirecting
@@ -224,9 +225,9 @@ export default function EditProfilePage() {
224225
<div className="flex h-[60vh] flex-col items-center justify-center gap-4 text-center px-4">
225226
<div className="rounded-full bg-yellow-500/10 p-4 text-3xl">🔒</div>
226227
<h2 className="text-xl font-bold text-white">Connect your wallet to edit this profile</h2>
227-
<p className="text-sm text-steel max-w-sm">
228-
Freighter is not connected or is locked. Unlock your Freighter wallet and try again.
229-
</p>
228+
<p className="text-sm text-steel max-w-sm">
229+
Your wallet is not connected or is locked. Unlock your wallet and try again.
230+
</p>
230231
<button
231232
type="button"
232233
onClick={() => {

frontend/src/components/profile-tabs.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import { motion, AnimatePresence } from "framer-motion";
1010
import { EmptyState } from "./empty-state";
1111
import { stellarExpertUrl } from "@/lib/stellar";
1212
import { useRouter } from "next/navigation";
13-
14-
const API_BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL ?? "http://localhost:4000";
13+
import { API_BASE_URL } from "@/lib/config";
1514

1615
type Transaction = {
1716
id: string;

frontend/src/components/support-panel.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ export function SupportPanel({
112112
const parsedAmt = parseFloat(amount);
113113
const validAmount = !isNaN(parsedAmt) && parsedAmt > 0;
114114
const parsedBal = balance ? parseFloat(balance) : 0;
115-
const overBalance = validAmount && parsedAmt + FEE_IN_XLM > parsedBal;
115+
const overBalance = isXlmPayment
116+
? validAmount && parsedAmt + FEE_IN_XLM > parsedBal
117+
: validAmount && parsedAmt > parsedBal;
116118
if (!visitorAddress || !validAmount || overBalance || sending) return;
117119

118120
const walletId = (
@@ -273,6 +275,13 @@ export function SupportPanel({
273275
const isValidAmount = hasValidAmount;
274276
const recipientAsset = { code: "XLM" };
275277

278+
const isXlmPayment = paymentAsset.code === "XLM";
279+
const xlmBalance = parseFloat(
280+
visitorBalances.find((b) => b.asset_type === "native")?.balance ?? "0"
281+
);
282+
const insufficientXlmForFee =
283+
!isXlmPayment && hasValidAmount && xlmBalance < FEE_IN_XLM;
284+
276285
if (!visitorAddress) {
277286
return (
278287
<section className="rounded-[2rem] border border-gold/25 bg-gold/10 p-7 text-center">
@@ -659,10 +668,19 @@ export function SupportPanel({
659668
</div>
660669
)}
661670

671+
{insufficientXlmForFee && (
672+
<div className="mt-4 rounded-2xl border border-red-500/20 bg-red-500/5 p-3">
673+
<p className="text-xs text-red-400">
674+
Insufficient XLM balance. You need at least {FEE_IN_XLM.toFixed(7)}{" "}
675+
XLM in your wallet to pay the Stellar network fee.
676+
</p>
677+
</div>
678+
)}
679+
662680
<button
663681
type="button"
664682
onClick={handleSend}
665-
disabled={!hasValidAmount || insufficientBalance || sending}
683+
disabled={!hasValidAmount || insufficientBalance || insufficientXlmForFee || sending}
666684
className="mt-6 w-full rounded-lg bg-mint px-4 py-3 text-sm font-semibold text-black hover:bg-mint/90 transition-colors disabled:opacity-30 disabled:cursor-not-allowed"
667685
>
668686
{sending ? "Sending…" : "Send Support"}

0 commit comments

Comments
 (0)