From 6d32c91fb3f6f86a858e7c7cfe2f0ebc48fce038 Mon Sep 17 00:00:00 2001 From: TZGyn Date: Sun, 24 May 2026 04:57:55 +0800 Subject: [PATCH] Add token-to-native swap detection with NATIVE_SYMBOLS map --- apps/desktop/src/bun/index.ts | 14 ++++++++++++++ .../desktop/src/lib/components/EvmDashboard.svelte | 2 +- apps/desktop/src/routes/tx/[chainid]/[hash].svelte | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/apps/desktop/src/bun/index.ts b/apps/desktop/src/bun/index.ts index e3190e2..0b2ac72 100644 --- a/apps/desktop/src/bun/index.ts +++ b/apps/desktop/src/bun/index.ts @@ -104,6 +104,12 @@ const ALCHEMY_NETWORKS: Record = { '56': 'bnb-mainnet', } +const NATIVE_SYMBOLS: Record = { + '1': 'ETH', + '137': 'POL', + '56': 'BNB', +} + async function fetchAlchemyTransfers( @@ -272,6 +278,14 @@ async function pairTransfers( pairedContractAddress: tokIn[0].rawContract?.address ?? undefined, }) + } else if (tokOut.length > 0 && extIn.length > 0) { + combined.push({ + ...mapTransfer(tokOut[0]), + pairedValue: String(extIn[0].value), + pairedSymbol: chainid + ? NATIVE_SYMBOLS[chainid] + : undefined, + }) } else if (tokOut.length > 0) { combined.push(mapTransfer(tokOut[0])) } else if (tokIn.length > 0) { diff --git a/apps/desktop/src/lib/components/EvmDashboard.svelte b/apps/desktop/src/lib/components/EvmDashboard.svelte index b063e78..8bee275 100644 --- a/apps/desktop/src/lib/components/EvmDashboard.svelte +++ b/apps/desktop/src/lib/components/EvmDashboard.svelte @@ -459,7 +459,7 @@ ((e.target as HTMLElement).style.display = 'none')} /> {Number(tx.pairedValue).toFixed(4)} - {tx.pairedSymbol} + {tx.pairedSymbol ?? w.symbol} {:else if tx.tokenSymbol} → {Number(details.pairedValue).toFixed(4)} - {details.pairedSymbol} + {details.pairedSymbol ?? network?.symbol ?? 'ETH'}

{/if}