fix: Blockscout and Etherscan lookups are off until the user turns them on (closes #668)
Out of the box the wallet sent the user's addresses to Blockscout and each recipient to Etherscan. 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, and drops a late answer. An open popup takes another page's change and draws its screens again. While "Use Blockscout" is off, no address keeps an untracked token, and no screen names a token from Blockscout's report. ENS lookups ask only the RPC endpoint. Model: opus-5-5 (implementation); fable-5-1 (prose)
This commit is contained in:
+23
-2
@@ -653,6 +653,12 @@ function traceEnabled(raw) {
|
||||
* confirmed receipt instead of null, so a wait screen resolves.
|
||||
* @param {boolean} [opts.failReceiptLookup] answer eth_getTransactionReceipt
|
||||
* with an error, so every receipt lookup fails; read at request time.
|
||||
* @param {string} [opts.etherscanLabel] the label Etherscan's page gives the
|
||||
* address asked about, such as "Fake_Phishing1"; none when unset. Read at
|
||||
* request time.
|
||||
* @param {object[]} [opts.requests] a list for the requests this handler
|
||||
* sees. Each is appended in order as { method, url, fromWorker }, whether it
|
||||
* came from a popup page or the background worker.
|
||||
* @returns {Promise<{waitForServiceWorkerTraffic: (ms: number) =>
|
||||
* Promise<string|null>}>}
|
||||
*/
|
||||
@@ -691,6 +697,13 @@ async function installNetworkStubs(ctx, opts) {
|
||||
const origin = fromWorker ? "[sw] " : "[page] ";
|
||||
console.log("# routed " + origin + req.method() + " " + req.url());
|
||||
}
|
||||
if (Array.isArray(opts.requests)) {
|
||||
opts.requests.push({
|
||||
method: req.method(),
|
||||
url: req.url(),
|
||||
fromWorker,
|
||||
});
|
||||
}
|
||||
|
||||
// JSON-RPC endpoint (any host): a POST with a JSON-RPC body.
|
||||
if (req.method() === "POST") {
|
||||
@@ -762,12 +775,20 @@ async function installNetworkStubs(ctx, opts) {
|
||||
return route.fulfill({ status: 204, body: "" });
|
||||
}
|
||||
|
||||
// Best-effort Etherscan address labels: served as an empty page.
|
||||
// Best-effort Etherscan address labels: served as an empty page, or
|
||||
// as a page labelling the address with opts.etherscanLabel.
|
||||
if (url.hostname.endsWith("etherscan.io")) {
|
||||
const title = opts.etherscanLabel
|
||||
? "<title>" +
|
||||
opts.etherscanLabel +
|
||||
" | Address: " +
|
||||
p.split("/").pop() +
|
||||
" | Etherscan</title>"
|
||||
: "";
|
||||
return route.fulfill({
|
||||
status: 200,
|
||||
contentType: "text/html",
|
||||
body: "<html><body></body></html>",
|
||||
body: "<html><head>" + title + "</head><body></body></html>",
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user