fix: a transaction history that lands after a network switch is dropped (closes #657)
Home, AddressDetail and AddressToken remember which network is active before they ask Blockscout for the transaction history. Each screen drops the answer if another network is active on the page or in storage when the answer lands. AddressDetail and AddressToken also drop an answer that lands once the screen shows another address. AddressToken also drops an answer that lands once the screen shows another token. A dropped answer draws no rows and saves no fraud contracts. A failed request goes through the same checks. A dropped failure shows no message. Holding the lock, the save adds new fraud contracts only if the page and the stored record still name the request's network. storedNetworkIs() reads the stored network, in src/shared/storedSettings.js. Model: opus-5-5
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// Reads "Use Blockscout" or "Check recipients on Etherscan" from the stored
|
||||
// profile.
|
||||
// Reads "Use Blockscout", "Check recipients on Etherscan" or the active network
|
||||
// from the stored profile.
|
||||
//
|
||||
// Before each request that sends the user's data to Blockscout or Etherscan, the
|
||||
// wallet reads that service's setting from storage. The wallet reads the setting
|
||||
@@ -7,6 +7,11 @@
|
||||
// made, and an answer that lands after the setting went off is dropped. A page's
|
||||
// own copy of the setting is not used, because another page may have just
|
||||
// changed it.
|
||||
//
|
||||
// Before asking Blockscout for the transaction history, a screen remembers
|
||||
// which network is active. If another network is active on the page or in
|
||||
// storage when the answer lands, the screen drops the answer. A switch saved
|
||||
// elsewhere reaches storage first and the page later.
|
||||
|
||||
const { storageGet } = require("./browserApi");
|
||||
const { normalizePersisted } = require("./persistedState");
|
||||
@@ -24,4 +29,15 @@ async function storedSettingIsOn(name) {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { storedSettingIsOn };
|
||||
// Whether `networkId` is the active network in the stored profile. A failed
|
||||
// read counts as no.
|
||||
async function storedNetworkIs(networkId) {
|
||||
try {
|
||||
const { autistmask } = await storageGet("autistmask");
|
||||
return normalizePersisted(autistmask).networkId === networkId;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { storedSettingIsOn, storedNetworkIs };
|
||||
|
||||
Reference in New Issue
Block a user