From 2d328c73890f0d64bb57c77b407f923a8ccd0630 Mon Sep 17 00:00:00 2001 From: sneak Date: Thu, 26 Feb 2026 03:49:20 +0700 Subject: [PATCH] Fix from address not showing when Send clicked from main view Move renderSendTokenSelect to send.js so both the main view and address detail view call it before navigating to send. Without it, the token dropdown was stale and updateSendBalance had no context. --- src/popup/views/addressDetail.js | 13 +------------ src/popup/views/home.js | 3 ++- src/popup/views/send.js | 13 ++++++++++++- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/popup/views/addressDetail.js b/src/popup/views/addressDetail.js index eb046f9..31b1b6d 100644 --- a/src/popup/views/addressDetail.js +++ b/src/popup/views/addressDetail.js @@ -12,7 +12,7 @@ const { state, currentAddress } = require("../../shared/state"); const { formatUsd, getAddressValueUsd } = require("../../shared/prices"); const { fetchRecentTransactions } = require("../../shared/transactions"); const { resolveEnsNames } = require("../../shared/ens"); -const { updateSendBalance } = require("./send"); +const { updateSendBalance, renderSendTokenSelect } = require("./send"); const { log } = require("../../shared/log"); const QRCode = require("qrcode"); @@ -187,17 +187,6 @@ function showTxDetail(tx) { showView("transaction"); } -function renderSendTokenSelect(addr) { - const sel = $("send-token"); - sel.innerHTML = ''; - for (const t of addr.tokenBalances || []) { - const opt = document.createElement("option"); - opt.value = t.address; - opt.textContent = t.symbol; - sel.appendChild(opt); - } -} - function init(ctx) { $("address-full").addEventListener("click", () => { const addr = $("address-full").dataset.full; diff --git a/src/popup/views/home.js b/src/popup/views/home.js index 3ff16d0..cccc48d 100644 --- a/src/popup/views/home.js +++ b/src/popup/views/home.js @@ -7,7 +7,7 @@ const { truncateMiddle, } = require("./helpers"); const { state, saveState, currentAddress } = require("../../shared/state"); -const { updateSendBalance } = require("./send"); +const { updateSendBalance, renderSendTokenSelect } = require("./send"); const QRCode = require("qrcode"); const { deriveAddressFromXpub } = require("../../shared/wallet"); const { @@ -139,6 +139,7 @@ function init(ctx) { } $("send-to").value = ""; $("send-amount").value = ""; + renderSendTokenSelect(addr); updateSendBalance(); showView("send"); }); diff --git a/src/popup/views/send.js b/src/popup/views/send.js index 99ac988..98c256c 100644 --- a/src/popup/views/send.js +++ b/src/popup/views/send.js @@ -4,6 +4,17 @@ const { $, showFlash, formatAddressHtml } = require("./helpers"); const { state, currentAddress } = require("../../shared/state"); const { getProvider } = require("../../shared/balances"); +function renderSendTokenSelect(addr) { + const sel = $("send-token"); + sel.innerHTML = ''; + for (const t of addr.tokenBalances || []) { + const opt = document.createElement("option"); + opt.value = t.address; + opt.textContent = t.symbol; + sel.appendChild(opt); + } +} + function updateSendBalance() { const addr = currentAddress(); if (!addr) return; @@ -77,4 +88,4 @@ function init(ctx) { $("btn-send-back").addEventListener("click", ctx.showAddressDetail); } -module.exports = { init, updateSendBalance }; +module.exports = { init, updateSendBalance, renderSendTokenSelect };