Add DEBUG mode with red banner and hardcoded mnemonic
All checks were successful
check / check (push) Successful in 12s
All checks were successful
check / check (push) Successful in 12s
When DEBUG=true: a sticky red "DEBUG / INSECURE" banner appears at the top of all views, and the die button returns a hardcoded test mnemonic instead of generating a random one.
This commit is contained in:
@@ -1,6 +1,10 @@
|
|||||||
// AutistMask popup UI — view management and event wiring
|
// AutistMask popup UI — view management and event wiring
|
||||||
const { Mnemonic } = require("ethers");
|
const { Mnemonic } = require("ethers");
|
||||||
|
|
||||||
|
const DEBUG = true;
|
||||||
|
const DEBUG_MNEMONIC =
|
||||||
|
"cube evolve unfold result inch risk jealous skill hotel bulb night wreck";
|
||||||
|
|
||||||
const VIEWS = [
|
const VIEWS = [
|
||||||
"lock",
|
"lock",
|
||||||
"welcome",
|
"welcome",
|
||||||
@@ -71,6 +75,7 @@ function makeStubAddress() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function generateMnemonic() {
|
function generateMnemonic() {
|
||||||
|
if (DEBUG) return DEBUG_MNEMONIC;
|
||||||
const wallet = Mnemonic.fromEntropy(
|
const wallet = Mnemonic.fromEntropy(
|
||||||
globalThis.crypto.getRandomValues(new Uint8Array(16)),
|
globalThis.crypto.getRandomValues(new Uint8Array(16)),
|
||||||
);
|
);
|
||||||
@@ -239,6 +244,14 @@ function backFromWalletAdd() {
|
|||||||
|
|
||||||
// -- init --
|
// -- init --
|
||||||
function init() {
|
function init() {
|
||||||
|
if (DEBUG) {
|
||||||
|
const banner = document.createElement("div");
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
if (!state.hasWallet) {
|
if (!state.hasWallet) {
|
||||||
showView("welcome");
|
showView("welcome");
|
||||||
} else if (state.locked) {
|
} else if (state.locked) {
|
||||||
|
|||||||
Reference in New Issue
Block a user