fix: TransactionDetail drops a Blockscout answer for another transaction (closes #675)
TransactionDetail asks Blockscout for its transaction and does not wait for the answer. If the user pressed Back and opened another transaction first, the first answer filled the second screen with its block, network details, decoded details and raw data. The answer is now dropped unless TransactionDetail is still on screen for the same transaction, beside the check of "Use Blockscout". A request for another transaction that fails no longer logs its error. Model: opus-5-5
This commit is contained in:
@@ -311,10 +311,25 @@ function populateOnChainDetails(txData, chainId) {
|
||||
}
|
||||
}
|
||||
|
||||
// Whether TransactionDetail is on screen for the transaction with `txHash` on
|
||||
// `chainId`.
|
||||
function isOnScreen(txHash, chainId) {
|
||||
const tx = state.viewData.tx;
|
||||
return (
|
||||
state.currentView === "transaction" &&
|
||||
tx?.hash === txHash &&
|
||||
tx?.chainId === chainId
|
||||
);
|
||||
}
|
||||
|
||||
// Reads the block, network details and calldata from Blockscout, and decodes
|
||||
// the calldata. While the stored "Use Blockscout" is off, Blockscout is not
|
||||
// asked. An answer that lands after the setting went off is dropped
|
||||
// (src/shared/storedSettings.js). Either way none of them is shown.
|
||||
//
|
||||
// Blockscout can answer after the user has left this screen or opened another
|
||||
// transaction. That answer is dropped. If that request fails, its error is not
|
||||
// logged.
|
||||
async function loadFullTxDetails(txHash, chainId) {
|
||||
if (!(await storedSettingIsOn("useBlockscout"))) return;
|
||||
const section = $("tx-detail-calldata-section");
|
||||
@@ -333,6 +348,7 @@ async function loadFullTxDetails(txHash, chainId) {
|
||||
if (!resp.ok) return;
|
||||
const txData = await resp.json();
|
||||
if (!(await storedSettingIsOn("useBlockscout"))) return;
|
||||
if (!isOnScreen(txHash, chainId)) return;
|
||||
|
||||
// Populate on-chain detail fields (block, nonce, gas, fee)
|
||||
populateOnChainDetails(txData, chainId);
|
||||
@@ -399,7 +415,9 @@ async function loadFullTxDetails(txHash, chainId) {
|
||||
attachCopyHandlers(container);
|
||||
}
|
||||
} catch (e) {
|
||||
log.errorf("loadCalldata failed:", e.message);
|
||||
if (isOnScreen(txHash, chainId)) {
|
||||
log.errorf("loadCalldata failed:", e.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user