Compare commits
8 Commits
78f961f416
...
fix/issue-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dbaf84325c | ||
| dc8ec7d28f | |||
|
|
2fbed343db | ||
| 699e080e3e | |||
|
|
8f2bf9618e | ||
| 069981baa0 | |||
|
|
886cd38a9b | ||
| 438d915f73 |
@@ -581,11 +581,23 @@
|
|||||||
id="confirm-errors"
|
id="confirm-errors"
|
||||||
class="mb-2 border border-border border-dashed p-2 hidden"
|
class="mb-2 border border-border border-dashed p-2 hidden"
|
||||||
></div>
|
></div>
|
||||||
|
<div class="mb-2">
|
||||||
|
<label class="block mb-1 text-xs">Password</label>
|
||||||
|
<input
|
||||||
|
type="password"
|
||||||
|
id="confirm-tx-password"
|
||||||
|
class="border border-border p-1 w-full font-mono text-sm bg-bg text-fg"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
id="confirm-tx-password-error"
|
||||||
|
class="text-xs mb-2 min-h-[1.25rem]"
|
||||||
|
></div>
|
||||||
<button
|
<button
|
||||||
id="btn-confirm-send"
|
id="btn-confirm-send"
|
||||||
class="border border-border px-2 py-1 hover:bg-fg hover:text-bg cursor-pointer"
|
class="border border-border px-2 py-1 hover:bg-fg hover:text-bg cursor-pointer"
|
||||||
>
|
>
|
||||||
Send
|
Sign & Send
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -664,42 +676,6 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- ============ PASSWORD MODAL ============ -->
|
|
||||||
<div
|
|
||||||
id="password-modal"
|
|
||||||
class="hidden fixed inset-0 bg-bg flex items-center justify-center z-50"
|
|
||||||
>
|
|
||||||
<div class="border border-border p-4 bg-bg w-80">
|
|
||||||
<h2 class="font-bold mb-2">Enter Password</h2>
|
|
||||||
<p class="text-xs text-muted mb-2">
|
|
||||||
Your password is needed to authorize this transaction.
|
|
||||||
</p>
|
|
||||||
<input
|
|
||||||
type="password"
|
|
||||||
id="modal-password"
|
|
||||||
class="border border-border p-1 w-full font-mono text-sm bg-bg text-fg mb-2"
|
|
||||||
/>
|
|
||||||
<div
|
|
||||||
id="modal-password-error"
|
|
||||||
class="text-xs mb-2 border border-border border-dashed p-1 hidden"
|
|
||||||
></div>
|
|
||||||
<div class="flex gap-2">
|
|
||||||
<button
|
|
||||||
id="btn-modal-confirm"
|
|
||||||
class="border border-border px-2 py-1 hover:bg-fg hover:text-bg cursor-pointer"
|
|
||||||
>
|
|
||||||
Confirm
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
id="btn-modal-cancel"
|
|
||||||
class="border border-border px-2 py-1 hover:bg-fg hover:text-bg cursor-pointer"
|
|
||||||
>
|
|
||||||
Cancel
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- ============ RECEIVE ============ -->
|
<!-- ============ RECEIVE ============ -->
|
||||||
<div id="view-receive" class="view hidden">
|
<div id="view-receive" class="view hidden">
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -325,6 +325,9 @@ function init(_ctx) {
|
|||||||
$("export-privkey-flash").classList.remove("hidden");
|
$("export-privkey-flash").classList.remove("hidden");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const btn = $("btn-export-privkey-confirm");
|
||||||
|
btn.disabled = true;
|
||||||
|
btn.classList.add("text-muted");
|
||||||
const wallet = state.wallets[state.selectedWallet];
|
const wallet = state.wallets[state.selectedWallet];
|
||||||
try {
|
try {
|
||||||
const secret = await decryptWithPassword(
|
const secret = await decryptWithPassword(
|
||||||
@@ -344,6 +347,9 @@ function init(_ctx) {
|
|||||||
} catch {
|
} catch {
|
||||||
$("export-privkey-flash").textContent = "Wrong password.";
|
$("export-privkey-flash").textContent = "Wrong password.";
|
||||||
$("export-privkey-flash").classList.remove("hidden");
|
$("export-privkey-flash").classList.remove("hidden");
|
||||||
|
} finally {
|
||||||
|
btn.disabled = false;
|
||||||
|
btn.classList.remove("text-muted");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -172,6 +172,8 @@ function showTxApproval(details) {
|
|||||||
// If this is an ERC-20 call, try to extract the real recipient and amount
|
// If this is an ERC-20 call, try to extract the real recipient and amount
|
||||||
const decoded = decodeCalldata(details.txParams.data, toAddr || "");
|
const decoded = decodeCalldata(details.txParams.data, toAddr || "");
|
||||||
if (decoded && decoded.details) {
|
if (decoded && decoded.details) {
|
||||||
|
let decodedTokenAddr = null;
|
||||||
|
let decodedTokenSymbol = null;
|
||||||
for (const d of decoded.details) {
|
for (const d of decoded.details) {
|
||||||
if (d.label === "Recipient" && d.address) {
|
if (d.label === "Recipient" && d.address) {
|
||||||
pendingTxDetails.to = d.address;
|
pendingTxDetails.to = d.address;
|
||||||
@@ -179,10 +181,20 @@ function showTxApproval(details) {
|
|||||||
if (d.label === "Amount") {
|
if (d.label === "Amount") {
|
||||||
pendingTxDetails.amount = d.rawValue || d.value;
|
pendingTxDetails.amount = d.rawValue || d.value;
|
||||||
}
|
}
|
||||||
|
if (d.label === "Token In" && d.isToken && d.address) {
|
||||||
|
const t = TOKEN_BY_ADDRESS.get(d.address.toLowerCase());
|
||||||
|
if (t) {
|
||||||
|
decodedTokenAddr = d.address;
|
||||||
|
decodedTokenSymbol = t.symbol;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (token) {
|
if (token) {
|
||||||
pendingTxDetails.token = toAddr;
|
pendingTxDetails.token = toAddr;
|
||||||
pendingTxDetails.tokenSymbol = token.symbol;
|
pendingTxDetails.tokenSymbol = token.symbol;
|
||||||
|
} else if (decodedTokenAddr) {
|
||||||
|
pendingTxDetails.token = decodedTokenAddr;
|
||||||
|
pendingTxDetails.tokenSymbol = decodedTokenSymbol;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Transaction confirmation view + password modal.
|
// Transaction confirmation view with inline password.
|
||||||
// Shows transaction details, warnings, errors. On proceed, opens
|
// Shows transaction details, warnings, errors. On Sign & Send,
|
||||||
// password modal, decrypts secret, signs and broadcasts.
|
// reads inline password, decrypts secret, signs and broadcasts.
|
||||||
|
|
||||||
const {
|
const {
|
||||||
parseEther,
|
parseEther,
|
||||||
@@ -233,6 +233,10 @@ function show(txInfo) {
|
|||||||
sendBtn.classList.remove("text-muted");
|
sendBtn.classList.remove("text-muted");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset password field and error
|
||||||
|
$("confirm-tx-password").value = "";
|
||||||
|
hideError("confirm-tx-password-error");
|
||||||
|
|
||||||
// Gas estimate — show placeholder then fetch async
|
// Gas estimate — show placeholder then fetch async
|
||||||
$("confirm-fee").classList.remove("hidden");
|
$("confirm-fee").classList.remove("hidden");
|
||||||
$("confirm-fee-amount").textContent = "Estimating...";
|
$("confirm-fee-amount").textContent = "Estimating...";
|
||||||
@@ -282,39 +286,20 @@ async function estimateGas(txInfo) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showPasswordModal() {
|
|
||||||
$("modal-password").value = "";
|
|
||||||
hideError("modal-password-error");
|
|
||||||
$("password-modal").classList.remove("hidden");
|
|
||||||
}
|
|
||||||
|
|
||||||
function hidePasswordModal() {
|
|
||||||
$("password-modal").classList.add("hidden");
|
|
||||||
}
|
|
||||||
|
|
||||||
function init(ctx) {
|
function init(ctx) {
|
||||||
$("btn-confirm-send").addEventListener("click", () => {
|
$("btn-confirm-send").addEventListener("click", async () => {
|
||||||
showPasswordModal();
|
const password = $("confirm-tx-password").value;
|
||||||
});
|
|
||||||
|
|
||||||
$("btn-confirm-back").addEventListener("click", () => {
|
|
||||||
showView("send");
|
|
||||||
});
|
|
||||||
|
|
||||||
$("btn-modal-cancel").addEventListener("click", () => {
|
|
||||||
hidePasswordModal();
|
|
||||||
});
|
|
||||||
|
|
||||||
$("btn-modal-confirm").addEventListener("click", async () => {
|
|
||||||
const password = $("modal-password").value;
|
|
||||||
if (!password) {
|
if (!password) {
|
||||||
showError("modal-password-error", "Please enter your password.");
|
showError(
|
||||||
|
"confirm-tx-password-error",
|
||||||
|
"Please enter your password.",
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const wallet = state.wallets[state.selectedWallet];
|
const wallet = state.wallets[state.selectedWallet];
|
||||||
let decryptedSecret;
|
let decryptedSecret;
|
||||||
hideError("modal-password-error");
|
hideError("confirm-tx-password-error");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
decryptedSecret = await decryptWithPassword(
|
decryptedSecret = await decryptWithPassword(
|
||||||
@@ -322,11 +307,12 @@ function init(ctx) {
|
|||||||
password,
|
password,
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showError("modal-password-error", "Wrong password.");
|
showError("confirm-tx-password-error", "Wrong password.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
hidePasswordModal();
|
$("btn-confirm-send").disabled = true;
|
||||||
|
$("btn-confirm-send").classList.add("text-muted");
|
||||||
|
|
||||||
let tx;
|
let tx;
|
||||||
try {
|
try {
|
||||||
@@ -363,8 +349,15 @@ function init(ctx) {
|
|||||||
decryptedSecret = null;
|
decryptedSecret = null;
|
||||||
const hash = tx ? tx.hash : null;
|
const hash = tx ? tx.hash : null;
|
||||||
txStatus.showError(pendingTx, hash, e.shortMessage || e.message);
|
txStatus.showError(pendingTx, hash, e.shortMessage || e.message);
|
||||||
|
} finally {
|
||||||
|
$("btn-confirm-send").disabled = false;
|
||||||
|
$("btn-confirm-send").classList.remove("text-muted");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("btn-confirm-back").addEventListener("click", () => {
|
||||||
|
showView("send");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { init, show, restore };
|
module.exports = { init, show, restore };
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ function init(_ctx) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const btn = $("btn-delete-wallet-confirm");
|
||||||
|
btn.disabled = true;
|
||||||
|
btn.classList.add("text-muted");
|
||||||
|
|
||||||
const walletIdx = deleteWalletIndex;
|
const walletIdx = deleteWalletIndex;
|
||||||
const wallet = state.wallets[walletIdx];
|
const wallet = state.wallets[walletIdx];
|
||||||
|
|
||||||
@@ -49,6 +53,8 @@ function init(_ctx) {
|
|||||||
} catch (_e) {
|
} catch (_e) {
|
||||||
$("delete-wallet-flash").textContent = "Wrong password.";
|
$("delete-wallet-flash").textContent = "Wrong password.";
|
||||||
$("delete-wallet-flash").classList.remove("hidden");
|
$("delete-wallet-flash").classList.remove("hidden");
|
||||||
|
btn.disabled = false;
|
||||||
|
btn.classList.remove("text-muted");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,10 +43,21 @@ function toAddressHtml(address) {
|
|||||||
if (title) {
|
if (title) {
|
||||||
return (
|
return (
|
||||||
`<div class="flex items-center font-bold">${dot}${escapeHtml(title)}</div>` +
|
`<div class="flex items-center font-bold">${dot}${escapeHtml(title)}</div>` +
|
||||||
`<div class="break-all">${escapeHtml(address)}${extLink}</div>`
|
`<div class="break-all underline decoration-dashed cursor-pointer" data-copy="${escapeHtml(address)}">${escapeHtml(address)}</div>` +
|
||||||
|
extLink
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return `<div class="flex items-center">${dot}<span class="break-all">${escapeHtml(address)}</span>${extLink}</div>`;
|
return `<div class="flex items-center">${dot}<span class="break-all underline decoration-dashed cursor-pointer" data-copy="${escapeHtml(address)}">${escapeHtml(address)}</span>${extLink}</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function blockNumberHtml(blockNumber) {
|
||||||
|
const num = String(blockNumber);
|
||||||
|
const link = `https://etherscan.io/block/${num}`;
|
||||||
|
const extLink = `<a href="${link}" target="_blank" rel="noopener" class="inline-flex items-center">${EXT_ICON}</a>`;
|
||||||
|
return (
|
||||||
|
`<span class="underline decoration-dashed cursor-pointer" data-copy="${escapeHtml(num)}">${escapeHtml(num)}</span>` +
|
||||||
|
extLink
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function txHashHtml(hash) {
|
function txHashHtml(hash) {
|
||||||
@@ -139,7 +150,7 @@ function etherscanTokenLink(address) {
|
|||||||
|
|
||||||
function decodedDetailsHtml(decoded) {
|
function decodedDetailsHtml(decoded) {
|
||||||
if (!decoded || !decoded.details) return "";
|
if (!decoded || !decoded.details) return "";
|
||||||
let html = "";
|
let html = `<div class="border border-border border-dashed p-2 mb-3">`;
|
||||||
if (decoded.name) {
|
if (decoded.name) {
|
||||||
html += `<div class="mb-2"><div class="text-xs text-muted mb-1">Action</div>`;
|
html += `<div class="mb-2"><div class="text-xs text-muted mb-1">Action</div>`;
|
||||||
html += `<div class="font-bold">${escapeHtml(decoded.name)}</div></div>`;
|
html += `<div class="font-bold">${escapeHtml(decoded.name)}</div></div>`;
|
||||||
@@ -164,20 +175,36 @@ function decodedDetailsHtml(decoded) {
|
|||||||
}
|
}
|
||||||
html += `</div>`;
|
html += `</div>`;
|
||||||
}
|
}
|
||||||
|
html += `</div>`;
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderSuccess() {
|
function renderSuccess() {
|
||||||
const d = state.viewData;
|
const d = state.viewData;
|
||||||
if (!d || !d.hash) return;
|
if (!d || !d.hash) return;
|
||||||
$("success-tx-summary").textContent = d.amount + " " + d.symbol;
|
|
||||||
$("success-tx-to").innerHTML = toAddressHtml(d.to);
|
const hasDecoded = d.decoded && d.decoded.details;
|
||||||
$("success-tx-block").textContent = String(d.blockNumber);
|
|
||||||
|
// When decoded details are present, the Amount and To are already
|
||||||
|
// shown inside the decoded well — hide the top-level duplicates.
|
||||||
|
const summarySection = $("success-tx-summary").parentElement;
|
||||||
|
const toSection = $("success-tx-to").parentElement;
|
||||||
|
if (hasDecoded) {
|
||||||
|
summarySection.classList.add("hidden");
|
||||||
|
toSection.classList.add("hidden");
|
||||||
|
} else {
|
||||||
|
summarySection.classList.remove("hidden");
|
||||||
|
toSection.classList.remove("hidden");
|
||||||
|
$("success-tx-summary").textContent = d.amount + " " + d.symbol;
|
||||||
|
$("success-tx-to").innerHTML = toAddressHtml(d.to);
|
||||||
|
}
|
||||||
|
|
||||||
|
$("success-tx-block").innerHTML = blockNumberHtml(d.blockNumber);
|
||||||
$("success-tx-hash").innerHTML = txHashHtml(d.hash);
|
$("success-tx-hash").innerHTML = txHashHtml(d.hash);
|
||||||
|
|
||||||
// Show decoded calldata details if present
|
// Show decoded calldata details if present
|
||||||
const decodedEl = $("success-tx-decoded");
|
const decodedEl = $("success-tx-decoded");
|
||||||
if (decodedEl && d.decoded) {
|
if (decodedEl && hasDecoded) {
|
||||||
decodedEl.innerHTML = decodedDetailsHtml(d.decoded);
|
decodedEl.innerHTML = decodedDetailsHtml(d.decoded);
|
||||||
decodedEl.classList.remove("hidden");
|
decodedEl.classList.remove("hidden");
|
||||||
} else if (decodedEl) {
|
} else if (decodedEl) {
|
||||||
|
|||||||
@@ -445,12 +445,18 @@ function decode(data, toAddress) {
|
|||||||
const maxUint160 = BigInt(
|
const maxUint160 = BigInt(
|
||||||
"0xffffffffffffffffffffffffffffffffffffffff",
|
"0xffffffffffffffffffffffffffffffffffffffff",
|
||||||
);
|
);
|
||||||
const amountStr =
|
const isUnlimited = inputAmount >= maxUint160;
|
||||||
inputAmount >= maxUint160
|
const amountRaw = isUnlimited
|
||||||
? "Unlimited"
|
? "Unlimited"
|
||||||
: formatAmount(inputAmount, inInfo.decimals) +
|
: formatAmount(inputAmount, inInfo.decimals);
|
||||||
(inSymbol ? " " + inSymbol : "");
|
const amountStr = isUnlimited
|
||||||
details.push({ label: "Amount", value: amountStr });
|
? "Unlimited"
|
||||||
|
: amountRaw + (inSymbol ? " " + inSymbol : "");
|
||||||
|
details.push({
|
||||||
|
label: "Amount",
|
||||||
|
value: amountStr,
|
||||||
|
rawValue: amountRaw,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outSymbol) {
|
if (outSymbol) {
|
||||||
|
|||||||
Reference in New Issue
Block a user