Fix from address not showing when Send clicked from main view
Some checks failed
check / check (push) Has been cancelled
Some checks failed
check / check (push) Has been cancelled
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.
This commit is contained in:
@@ -12,7 +12,7 @@ const { state, currentAddress } = require("../../shared/state");
|
|||||||
const { formatUsd, getAddressValueUsd } = require("../../shared/prices");
|
const { formatUsd, getAddressValueUsd } = require("../../shared/prices");
|
||||||
const { fetchRecentTransactions } = require("../../shared/transactions");
|
const { fetchRecentTransactions } = require("../../shared/transactions");
|
||||||
const { resolveEnsNames } = require("../../shared/ens");
|
const { resolveEnsNames } = require("../../shared/ens");
|
||||||
const { updateSendBalance } = require("./send");
|
const { updateSendBalance, renderSendTokenSelect } = require("./send");
|
||||||
const { log } = require("../../shared/log");
|
const { log } = require("../../shared/log");
|
||||||
const QRCode = require("qrcode");
|
const QRCode = require("qrcode");
|
||||||
|
|
||||||
@@ -187,17 +187,6 @@ function showTxDetail(tx) {
|
|||||||
showView("transaction");
|
showView("transaction");
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderSendTokenSelect(addr) {
|
|
||||||
const sel = $("send-token");
|
|
||||||
sel.innerHTML = '<option value="ETH">ETH</option>';
|
|
||||||
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) {
|
function init(ctx) {
|
||||||
$("address-full").addEventListener("click", () => {
|
$("address-full").addEventListener("click", () => {
|
||||||
const addr = $("address-full").dataset.full;
|
const addr = $("address-full").dataset.full;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const {
|
|||||||
truncateMiddle,
|
truncateMiddle,
|
||||||
} = require("./helpers");
|
} = require("./helpers");
|
||||||
const { state, saveState, currentAddress } = require("../../shared/state");
|
const { state, saveState, currentAddress } = require("../../shared/state");
|
||||||
const { updateSendBalance } = require("./send");
|
const { updateSendBalance, renderSendTokenSelect } = require("./send");
|
||||||
const QRCode = require("qrcode");
|
const QRCode = require("qrcode");
|
||||||
const { deriveAddressFromXpub } = require("../../shared/wallet");
|
const { deriveAddressFromXpub } = require("../../shared/wallet");
|
||||||
const {
|
const {
|
||||||
@@ -139,6 +139,7 @@ function init(ctx) {
|
|||||||
}
|
}
|
||||||
$("send-to").value = "";
|
$("send-to").value = "";
|
||||||
$("send-amount").value = "";
|
$("send-amount").value = "";
|
||||||
|
renderSendTokenSelect(addr);
|
||||||
updateSendBalance();
|
updateSendBalance();
|
||||||
showView("send");
|
showView("send");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,6 +4,17 @@ const { $, showFlash, formatAddressHtml } = require("./helpers");
|
|||||||
const { state, currentAddress } = require("../../shared/state");
|
const { state, currentAddress } = require("../../shared/state");
|
||||||
const { getProvider } = require("../../shared/balances");
|
const { getProvider } = require("../../shared/balances");
|
||||||
|
|
||||||
|
function renderSendTokenSelect(addr) {
|
||||||
|
const sel = $("send-token");
|
||||||
|
sel.innerHTML = '<option value="ETH">ETH</option>';
|
||||||
|
for (const t of addr.tokenBalances || []) {
|
||||||
|
const opt = document.createElement("option");
|
||||||
|
opt.value = t.address;
|
||||||
|
opt.textContent = t.symbol;
|
||||||
|
sel.appendChild(opt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function updateSendBalance() {
|
function updateSendBalance() {
|
||||||
const addr = currentAddress();
|
const addr = currentAddress();
|
||||||
if (!addr) return;
|
if (!addr) return;
|
||||||
@@ -77,4 +88,4 @@ function init(ctx) {
|
|||||||
$("btn-send-back").addEventListener("click", ctx.showAddressDetail);
|
$("btn-send-back").addEventListener("click", ctx.showAddressDetail);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { init, updateSendBalance };
|
module.exports = { init, updateSendBalance, renderSendTokenSelect };
|
||||||
|
|||||||
Reference in New Issue
Block a user