From 25b8ebe7dc409bff77f33226238c02cf514e4c76 Mon Sep 17 00:00:00 2001 From: Jeesun Kim Date: Tue, 10 Mar 2026 15:11:42 -0700 Subject: [PATCH] fix trustline bug --- src/app/(sidebar)/account/fund/page.tsx | 204 +++++++++++--------- src/components/SignTransactionXdr/index.tsx | 25 ++- 2 files changed, 135 insertions(+), 94 deletions(-) diff --git a/src/app/(sidebar)/account/fund/page.tsx b/src/app/(sidebar)/account/fund/page.tsx index 01b91566c..3c79c2dcf 100644 --- a/src/app/(sidebar)/account/fund/page.tsx +++ b/src/app/(sidebar)/account/fund/page.tsx @@ -389,102 +389,124 @@ export default function FundAccount() { Choose asset to fund - - } - size="sm" - > - What is a trustline? -
- {fundTokens.map((t) => { - const asset = `${t.assetCode}:${t.assetIssuer}`; - const hasTrustline = Boolean(accountBalances?.[asset]); - - return ( -
-
- {`${t.label} -
- -
- - {t.label} - - {`${formatNumber(parseFloat(t.amount))} ${t.currency}`} + {fundTokens + .filter((t) => { + // Hide XLM if the account is already funded + if (t.id === "xlm" && accountInfo?.isFunded) { + return false; + } + return true; + }) + .map((t) => { + const asset = `${t.assetCode}:${t.assetIssuer}`; + const hasTrustline = Boolean(accountBalances?.[asset]); + + return ( +
+
+ {`${t.label} +
+ +
+ + {t.label} + + {`${formatNumber(parseFloat(t.amount))} ${t.currency}`} +
+ + {t.id === "xlm" || hasTrustline ? ( + // Fund button + + ) : ( + // Add trustline button + + )}
- - {t.id === "xlm" || hasTrustline ? ( - // Fund button - - ) : ( - // Add trustline button - - )} -
- ); - })} + ); + })}
+ + + + A trustline lets your account hold and receive this asset. Your + address must have XLM to submit the transaction.{" "} + } + size="xs" + > + What is a trustline? + + + {isFriendBotFetchedAfterMount && friendBotError ? ( diff --git a/src/components/SignTransactionXdr/index.tsx b/src/components/SignTransactionXdr/index.tsx index 097cfd86f..0f6ab1595 100644 --- a/src/components/SignTransactionXdr/index.tsx +++ b/src/components/SignTransactionXdr/index.tsx @@ -230,7 +230,6 @@ export const SignTransactionXdr = ({ signatureSigs = sigSignature; } - const tx = TransactionBuilder.fromXDR(xdrToSign, network.passphrase); const allSigs = [ ...secretKeySigs, ...hardwareSigs, @@ -248,9 +247,29 @@ export const SignTransactionXdr = ({ setAllSigsCount(allSigsCount); if (allSigs.length > 0) { - tx.signatures.push(...allSigs); + // When only the extension wallet signed, use its signed XDR directly. + // This avoids issues where wallets may modify the transaction + // (e.g., fee adjustments), making the extracted signature invalid + // for the original unsigned transaction. + const isExtensionWalletOnly = + extensionSigs.length > 0 && + secretKeySigs.length === 0 && + hardwareSigs.length === 0 && + signatureSigs.length === 0; + + let signedTx: string; + + if (isExtensionWalletOnly && exSignedTxXdr) { + signedTx = exSignedTxXdr; + } else { + const tx = TransactionBuilder.fromXDR( + xdrToSign, + network.passphrase, + ); + tx.signatures.push(...allSigs); + signedTx = tx.toEnvelope().toXDR("base64"); + } - const signedTx = tx.toEnvelope().toXDR("base64"); onDoneAction({ signedXdr: signedTx, successMessage: getAllSigsMessage(allSigsCount),