From 58b8ed9d8209fa42310dfd5c2e1b0c2e42a5c364 Mon Sep 17 00:00:00 2001 From: ibrahimijai Date: Sat, 17 Oct 2026 11:07:00 +0100 Subject: [PATCH 1/2] Remove temporary swap files from the repository --- .a.swp | Bin 1024 -> 0 bytes .capability.swp | Bin 1024 -> 0 bytes .colored.swp | Bin 1024 -> 0 bytes .for.swp | Bin 1024 -> 0 bytes .has.swp | Bin 1024 -> 0 bytes .if.swp | Bin 1024 -> 0 bytes .prompt,.swp | Bin 1024 -> 0 bytes .terminal.swp | Bin 1024 -> 0 bytes .the.swp | Bin 1024 -> 0 bytes .uncomment.swp | Bin 1024 -> 0 bytes 10 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .a.swp delete mode 100644 .capability.swp delete mode 100644 .colored.swp delete mode 100644 .for.swp delete mode 100644 .has.swp delete mode 100644 .if.swp delete mode 100644 .prompt,.swp delete mode 100644 .terminal.swp delete mode 100644 .the.swp delete mode 100644 .uncomment.swp diff --git a/.a.swp b/.a.swp deleted file mode 100644 index 5e258018da0fa7b5343956e03b321a9637acfa7d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1024 zcmYc?$V<%2S1{KzVn6{Z3JeTMIf=>H#ffE^`K3iDl4u+k*I@4u{{US_OBYA?U~e>8 T1UC`E9A%A$z-R~zf)D@z7LE+e diff --git a/.capability.swp b/.capability.swp deleted file mode 100644 index 0286241fb5f5a98877778090b7b8a600375edf28..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1024 zcmYc?$V<%2S1{KzVn6{Z3JeTMIf=>H#ffE^`K3iDl4u+k*I@4u{{US_OBYA?U~e>8 c1UEUcATcR3C$ppyAvVey4S~@R7`PAs0CJ=djQ{`u diff --git a/.colored.swp b/.colored.swp deleted file mode 100644 index 1a2a468164bed54baf6bac66d2b63171f6a8732d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1024 zcmYc?$V<%2S1{KzVn6{Z3JeTMIf=>H#ffE^`K3iDl4u+k*I@4u{{US_OBYA?U~e>8 Z1UET9C%-5)1tBoX8V!Nb5E#%9000?u4^sdD diff --git a/.for.swp b/.for.swp deleted file mode 100644 index 1187de8f73aef780f8e88df07a1f95515540d7b4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1024 zcmYc?$V<%2S1{KzVn6{Z3JeTMIf=>H#ffE^`K3iDl4u+k*I@4u{{US_OBYA?U~e>8 W1UD@ouQ3RPqpZ;o7!3isga80cU=6YW diff --git a/.has.swp b/.has.swp deleted file mode 100644 index 608322b169b0c5a7c532d459b6843c4f52604e2e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1024 zcmYc?$V<%2S1{KzVn6{Z3JeTMIf=>H#ffE^`K3iDl4u+k*I@4u{{US_OBYA?U~e>8 V1UDnG7{M83jfTKz2n=`#001Qr4W|GA diff --git a/.if.swp b/.if.swp deleted file mode 100644 index bbaac6f8487c5aff5226e5b6c1f12a1ce79413b9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1024 zcmYc?$V<%2S1{KzVn6{Z3JeTMIf=>H#ffE^`K3iDl4u+k*I@4u{{US_OBYA?U~e>8 U1UEAc!5(FehQMeD415Rx0H4ndIsgCw diff --git a/.prompt,.swp b/.prompt,.swp deleted file mode 100644 index add1c79c72f687ec9454f93b1602364b7e205721..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1024 zcmYc?$V<%2S1{KzVn6{Z3JeTMIf=>H#ffE^`K3iDl4u+k*I@4u{{US_OBYA?U~e>8 Z1h=3lKewPn2O%)Z8V!Nb5E#%9006yb4>H#ffE^`K3iDl4u+k*I@4u{{US_OBYA?U~e>8 a1h*u$C^s`NF$WH#ffE^`K3iDl4u+k*I@4u{{US_OBYA?U~e>8 V1h*t36~P&0jfTKz2n=`#001`$4XgkF diff --git a/.uncomment.swp b/.uncomment.swp deleted file mode 100644 index da4f6af36d455de2907e86139e977b962dacd6c3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1024 zcmYc?$V<%2S1{KzVn6{Z3JeTMIf=>H#ffE^`K3iDl4u+k*I@4u{{US_OBYA?U~e>8 e1h+IVIX^cyHLnCAG|Czcfzc44UkHSvTLl1YH4v5n From bef67a2334bf4bb0dea683df33244a5c21084b71 Mon Sep 17 00:00:00 2001 From: ibrahimijai Date: Sat, 17 Oct 2026 11:17:49 +0100 Subject: [PATCH 2/2] Fix amount truncation precision, SEP-7 fallback domain typo, ignore swap files - parseAmount truncated via Math.floor(x * 10^d) / 10^d, which drops a unit on binary-rounding inputs ("0.57" became 0.5699999). Truncate the decimal string instead; add regression test. - ConnectButton SSR fallback origin pointed at so4.markets (typo of so4.market), which would route wallet callbacks to a foreign domain. - Add *.swp to .gitignore after removing committed nano swap files. --- .gitignore | 4 +++- .../src/features/wallet/components/ConnectButton.tsx | 2 +- apps/web/src/lib/amount.test.ts | 7 +++++++ apps/web/src/lib/amount.ts | 12 ++++++------ 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index e57f4c17..6a0b2600 100644 --- a/.gitignore +++ b/.gitignore @@ -50,4 +50,6 @@ fix.md test-results/ # Generated OG images apps/docs/public/og/ -.nitro-static/og/ \ No newline at end of file +.nitro-static/og/ +# Editor swap files +*.swp diff --git a/apps/web/src/features/wallet/components/ConnectButton.tsx b/apps/web/src/features/wallet/components/ConnectButton.tsx index 9e69607e..7a5073b0 100644 --- a/apps/web/src/features/wallet/components/ConnectButton.tsx +++ b/apps/web/src/features/wallet/components/ConnectButton.tsx @@ -278,7 +278,7 @@ function WalletModal({ ) const sep7Uri = useMemo(() => { const origin = - typeof window === "undefined" ? "https://so4.markets" : window.location.origin + typeof window === "undefined" ? "https://so4.market" : window.location.origin const callbackUrl = new URL("/", origin).toString() if (pendingTransactionXdr) { diff --git a/apps/web/src/lib/amount.test.ts b/apps/web/src/lib/amount.test.ts index 38fede9f..bdb717ca 100644 --- a/apps/web/src/lib/amount.test.ts +++ b/apps/web/src/lib/amount.test.ts @@ -136,6 +136,13 @@ describe("parseAmount", () => { const result = parseAmount("1.1234567", { decimals: 6 }) expect(result.value).toBe(1.123456) }) + + it("does not lose a unit to floating-point truncation", () => { + // Math.floor(0.57 * 1e7) / 1e7 === 0.5699999 + expect(parseAmount("0.57").value).toBe(0.57) + expect(parseAmount("0.57", { decimals: 2 }).value).toBe(0.57) + expect(parseAmount("0.5799999999").value).toBe(0.5799999) + }) }) }) diff --git a/apps/web/src/lib/amount.ts b/apps/web/src/lib/amount.ts index 41ca0548..1d920958 100644 --- a/apps/web/src/lib/amount.ts +++ b/apps/web/src/lib/amount.ts @@ -99,17 +99,17 @@ export function parseAmount(raw: string, options: ParseAmountOptions = {}): Pars return { value: null, isPartial: false, wasClamped: false } } - const parsed = Number(normalized) + // Enforce decimal precision by truncating the string, not the float: + // Math.floor(0.57 * 1e7) / 1e7 yields 0.5699999 due to binary rounding. + const [intPart, fracPart = ""] = normalized.split(".") + const truncatedFrac = fracPart.slice(0, decimals) + const truncated = Number(truncatedFrac ? `${intPart}.${truncatedFrac}` : intPart) // Guard: NaN or Infinity shouldn't happen with the regex above, but be safe - if (!Number.isFinite(parsed)) { + if (!Number.isFinite(truncated)) { return { value: null, isPartial: false, wasClamped: false } } - // Enforce decimal precision — truncate excess digits - const factor = 10 ** decimals - const truncated = Math.floor(parsed * factor) / factor - // Clamp to maxAmount if provided let finalValue = truncated let wasClamped = false