From b7dbae3598ad693a31b6c66d7792b036d09d6917 Mon Sep 17 00:00:00 2001 From: highlander Date: Tue, 28 Apr 2026 14:13:11 -0500 Subject: [PATCH] fix(eth): TxidPage explorer link missing for swaps + sends MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The transaction_complete message broadcast by sendTransaction reads explorerTxLink from currentProvider, but two SET_ASSET_CONTEXT code paths constructed the provider without that field: - The fallback path that builds providerData from EIP155_CHAINS when blockchainDataStorage has no entry (background/index.ts:996) was copying chainId / caip / name / providerUrl but dropping explorerTxLink (and networkId, which we also need for fallback resolution). When the user completed a Uniswap swap from this state, TxidPage received explorerUrl=undefined and rendered the txid as plain text with no link — confirmed in production today after a successful LINK swap landed at 0x6954a533…94b27968a9. Two fixes: 1. Carry explorerTxLink (and networkId) into providerData in the EIP155_CHAINS fallback so future sends have the link available. 2. Safety-net in sendTransaction: if currentProvider.explorerTxLink is missing, look it up from EIP155_CHAINS by networkId before firing transaction_complete. Catches any remaining stored state built by older code paths. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../src/background/chains/ethereumHandler.ts | 12 +++++++++++- chrome-extension/src/background/index.ts | 6 ++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/chrome-extension/src/background/chains/ethereumHandler.ts b/chrome-extension/src/background/chains/ethereumHandler.ts index e1518c3..0fcd5a0 100644 --- a/chrome-extension/src/background/chains/ethereumHandler.ts +++ b/chrome-extension/src/background/chains/ethereumHandler.ts @@ -1321,12 +1321,22 @@ const sendTransaction = async (params: any, KEEPKEY_WALLET: any, ADDRESS: string response.txid = txHash; await requestStorage.updateEventById(id, response); + // Defensive explorer-link resolution: if the stored provider was built + // through a code path that didn't carry explorerTxLink (e.g., older + // saved state), look it up from the static EIP155_CHAINS table by + // networkId. Otherwise the TxidPage gets no link and the user sees a + // bare hex hash with no way to navigate to etherscan. + let explorerTxLink = currentProvider.explorerTxLink; + if (!explorerTxLink && currentProvider.networkId) { + explorerTxLink = EIP155_CHAINS[currentProvider.networkId]?.explorerTxLink; + } + //push event chrome.runtime.sendMessage({ action: 'transaction_complete', eventId: id, txHash: txHash, - explorerTxLink: currentProvider.explorerTxLink, + explorerTxLink, networkId: currentProvider.networkId, }); diff --git a/chrome-extension/src/background/index.ts b/chrome-extension/src/background/index.ts index 65ec3b1..a570920 100644 --- a/chrome-extension/src/background/index.ts +++ b/chrome-extension/src/background/index.ts @@ -1001,6 +1001,12 @@ chrome.runtime.onMessage.addListener((message: any, sender: any, sendResponse: a name: chainInfo.name, providerUrl: chainInfo.rpc, fallbacks: [], + // Carry the static chain's explorer URL forward so + // transaction_complete events fired from sendTransaction + // have somewhere to deep-link the txid. Without this + // the TxidPage shows just the hex hash with no link. + explorerTxLink: chainInfo.explorerTxLink, + networkId: asset.networkId, }; } else { console.error(tag, 'Network not found in custom or static chains:', asset.networkId);