From 2f69ad0361930246585a158394551c0d01b5ecce Mon Sep 17 00:00:00 2001 From: clawbot Date: Sun, 1 Mar 2026 11:17:51 -0800 Subject: [PATCH] feat: show debug banner on testnet or debug mode, add TESTNET tag Display the red debug banner when on a testnet OR when DEBUG is enabled. When on a testnet, a 'TESTNET' label is shown on the far right side of the banner. The banner label shows the network name when not in debug mode, and 'DEBUG / INSECURE' when debug is on. closes #140 --- src/popup/index.js | 18 +++++++++++++++--- src/popup/views/helpers.js | 14 +++++++++++--- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/popup/index.js b/src/popup/index.js index 5c98a60..7f5d4b6 100644 --- a/src/popup/index.js +++ b/src/popup/index.js @@ -2,7 +2,12 @@ // Loads state, initializes views, triggers first render. const { DEBUG } = require("../shared/constants"); -const { state, saveState, loadState } = require("../shared/state"); +const { + state, + saveState, + loadState, + currentNetwork, +} = require("../shared/state"); const { refreshPrices } = require("../shared/prices"); const { refreshBalances } = require("../shared/balances"); const { $, showView } = require("./views/helpers"); @@ -167,10 +172,17 @@ function fallbackView() { } async function init() { - if (DEBUG) { + const net = currentNetwork(); + if (DEBUG || net.isTestnet) { const banner = document.createElement("div"); banner.id = "debug-banner"; - banner.textContent = "DEBUG / INSECURE"; + if (DEBUG && net.isTestnet) { + banner.textContent = "DEBUG / INSECURE [TESTNET]"; + } else if (net.isTestnet) { + banner.textContent = "[TESTNET]"; + } else { + banner.textContent = "DEBUG / INSECURE"; + } banner.style.cssText = "background:#c00;color:#fff;text-align:center;font-size:10px;padding:1px 0;font-family:monospace;position:sticky;top:0;z-index:9999;"; document.body.prepend(banner); diff --git a/src/popup/views/helpers.js b/src/popup/views/helpers.js index 450c98e..61acac1 100644 --- a/src/popup/views/helpers.js +++ b/src/popup/views/helpers.js @@ -6,7 +6,7 @@ const { getPrice, getAddressValueUsd, } = require("../../shared/prices"); -const { state, saveState } = require("../../shared/state"); +const { state, saveState, currentNetwork } = require("../../shared/state"); // When views are added, removed, or transitions between them change, // update the view-navigation documentation in README.md to match. @@ -59,10 +59,18 @@ function showView(name) { clearFlash(); state.currentView = name; saveState(); - if (DEBUG) { + const net = currentNetwork(); + if (DEBUG || net.isTestnet) { const banner = document.getElementById("debug-banner"); if (banner) { - banner.textContent = "DEBUG / INSECURE (" + name + ")"; + if (DEBUG && net.isTestnet) { + banner.textContent = + "DEBUG / INSECURE [TESTNET] (" + name + ")"; + } else if (net.isTestnet) { + banner.textContent = "[TESTNET]"; + } else { + banner.textContent = "DEBUG / INSECURE (" + name + ")"; + } } } }