From 9f85758ef65af573729441bc9e0b9e2d11171c1c Mon Sep 17 00:00:00 2001 From: user Date: Sat, 28 Feb 2026 12:19:39 -0800 Subject: [PATCH] persist confirm-tx view across popup close/reopen (closes #77) Add confirm-tx to RESTORABLE_VIEWS and save pendingTx in state.viewData so the confirmation screen survives the popup lifecycle. On restore, re-render the full confirmation view including gas estimate. --- src/popup/index.js | 8 ++++++++ src/popup/views/confirmTx.js | 10 +++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/popup/index.js b/src/popup/index.js index 5a12180..e0e42aa 100644 --- a/src/popup/index.js +++ b/src/popup/index.js @@ -74,6 +74,7 @@ const RESTORABLE_VIEWS = new Set([ "receive", "settings", "settings-addtoken", + "confirm-tx", "transaction", "success-tx", "error-tx", @@ -127,6 +128,13 @@ function restoreView() { case "settings-addtoken": settingsAddToken.show(); break; + case "confirm-tx": + if (state.viewData && state.viewData.pendingTx) { + confirmTx.restore(); + } else { + fallbackView(); + } + break; case "transaction": if (state.viewData && state.viewData.tx) { transactionDetail.render(); diff --git a/src/popup/views/confirmTx.js b/src/popup/views/confirmTx.js index f11cf68..c0f0df7 100644 --- a/src/popup/views/confirmTx.js +++ b/src/popup/views/confirmTx.js @@ -38,6 +38,13 @@ const EXT_ICON = let pendingTx = null; +function restore() { + const d = state.viewData; + if (d && d.pendingTx) { + show(d.pendingTx); + } +} + function etherscanTokenLink(address) { return `https://etherscan.io/token/${address}`; } @@ -217,6 +224,7 @@ function show(txInfo) { // Gas estimate — show placeholder then fetch async $("confirm-fee").classList.remove("hidden"); $("confirm-fee-amount").textContent = "Estimating..."; + state.viewData = { pendingTx: txInfo }; showView("confirm-tx"); estimateGas(txInfo); @@ -347,4 +355,4 @@ function init(ctx) { }); } -module.exports = { init, show }; +module.exports = { init, show, restore };