Out of the box the wallet sent the user's addresses to Blockscout. It sent each recipient to Etherscan for its label. Two settings, "Use Blockscout" and "Check recipients on Etherscan", now gate those requests. Both are off in a new install and offered unticked on Welcome and in Settings. While one is off, the screens that relied on it say so in a plain line. Each gated request reads its setting from storage before it asks and when the answer lands. An answer that lands after the setting went off is dropped. An open popup takes a change another page saved and draws its screens again. While "Use Blockscout" is off, no address keeps an untracked token. ENS lookups ask only the RPC endpoint. Model: opus-5-5
38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
// The first screen, shown while there is no wallet. It offers "Use Blockscout"
|
|
// and "Check recipients on Etherscan", which Settings offers too. Both are off
|
|
// until the user ticks them.
|
|
|
|
const { $, showView } = require("./helpers");
|
|
const { state, saveState } = require("../../shared/state");
|
|
|
|
function show() {
|
|
$("welcome-use-blockscout").checked = state.useBlockscout;
|
|
$("welcome-check-recipients-on-etherscan").checked =
|
|
state.checkRecipientsOnEtherscan;
|
|
showView("welcome");
|
|
}
|
|
|
|
// Each change is made inside the save, holding the lock, as Settings makes it.
|
|
function init(ctx) {
|
|
$("btn-welcome-add").addEventListener("click", ctx.showAddWalletView);
|
|
|
|
$("welcome-use-blockscout").addEventListener("change", async () => {
|
|
const on = $("welcome-use-blockscout").checked;
|
|
await saveState(() => {
|
|
state.useBlockscout = on;
|
|
});
|
|
});
|
|
|
|
$("welcome-check-recipients-on-etherscan").addEventListener(
|
|
"change",
|
|
async () => {
|
|
const on = $("welcome-check-recipients-on-etherscan").checked;
|
|
await saveState(() => {
|
|
state.checkRecipientsOnEtherscan = on;
|
|
});
|
|
},
|
|
);
|
|
}
|
|
|
|
module.exports = { init, show };
|