diff --git a/src/popup/index.js b/src/popup/index.js index 5c98a60..429ea5e 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,12 +172,24 @@ 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"; 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;"; + "background:#c00;color:#fff;text-align:center;font-size:10px;padding:1px 0;font-family:monospace;position:sticky;top:0;z-index:9999;display:flex;justify-content:center;align-items:center;"; + const label = document.createElement("span"); + label.id = "debug-banner-label"; + label.style.cssText = "flex:1;text-align:center;"; + label.textContent = DEBUG ? "DEBUG / INSECURE" : net.name; + banner.appendChild(label); + if (net.isTestnet) { + const tag = document.createElement("span"); + tag.id = "debug-banner-testnet"; + tag.style.cssText = "position:absolute;right:6px;font-weight:bold;"; + tag.textContent = "TESTNET"; + banner.appendChild(tag); + } document.body.prepend(banner); } diff --git a/src/popup/views/helpers.js b/src/popup/views/helpers.js index 450c98e..e0472bf 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,13 @@ function showView(name) { clearFlash(); state.currentView = name; saveState(); - if (DEBUG) { - const banner = document.getElementById("debug-banner"); - if (banner) { - banner.textContent = "DEBUG / INSECURE (" + name + ")"; + const net = currentNetwork(); + if (DEBUG || net.isTestnet) { + const label = document.getElementById("debug-banner-label"); + if (label) { + label.textContent = DEBUG + ? "DEBUG / INSECURE (" + name + ")" + : net.name + " (" + name + ")"; } } }