Compare commits
11 Commits
feature/sh
...
93565c7196
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
93565c7196 | ||
|
|
71ef08fe85 | ||
|
|
8d230aceb6 | ||
| 6031c3e76c | |||
|
|
436fe22296 | ||
| 82a7db63b5 | |||
| 7c53c48cb1 | |||
| 4d9a8a49b9 | |||
|
|
996003fd79 | ||
|
|
2c9a34aff6 | ||
|
|
173d75c57a |
35
README.md
35
README.md
@@ -213,22 +213,6 @@ create an address with the same visible characters and trick the user into
|
|||||||
sending funds to it. Showing the complete identifier defeats this class of
|
sending funds to it. Showing the complete identifier defeats this class of
|
||||||
attack.
|
attack.
|
||||||
|
|
||||||
#### Clipboard Policy
|
|
||||||
|
|
||||||
AutistMask never clears or overwrites the user's clipboard. When sensitive data
|
|
||||||
such as a private key is copied, it is the user's responsibility to manage their
|
|
||||||
clipboard afterwards. We deliberately avoid auto-clearing the clipboard for two
|
|
||||||
reasons:
|
|
||||||
|
|
||||||
1. **User expectations**: silently modifying the clipboard violates the
|
|
||||||
principle of least surprise. The user initiated the copy and knows the
|
|
||||||
content is sensitive.
|
|
||||||
2. **Data safety**: the user may have copied something else important in the
|
|
||||||
intervening time. A timed clipboard clear would destroy that unrelated data.
|
|
||||||
|
|
||||||
The warning shown before revealing a private key makes it clear that the key is
|
|
||||||
sensitive and that clipboard management is the user's responsibility.
|
|
||||||
|
|
||||||
#### Data Model
|
#### Data Model
|
||||||
|
|
||||||
The core hierarchy is **Wallets → Addresses**:
|
The core hierarchy is **Wallets → Addresses**:
|
||||||
@@ -332,34 +316,15 @@ transitions.
|
|||||||
- Balance list: ETH + tracked ERC-20 tokens (4 decimal places, USD inline).
|
- Balance list: ETH + tracked ERC-20 tokens (4 decimal places, USD inline).
|
||||||
Each balance row is clickable → **AddressToken**
|
Each balance row is clickable → **AddressToken**
|
||||||
- Send / Receive / + Token buttons
|
- Send / Receive / + Token buttons
|
||||||
- "Show private key" button
|
|
||||||
- Transaction list (with ENS resolution for counterparties)
|
- Transaction list (with ENS resolution for counterparties)
|
||||||
- **Transitions**:
|
- **Transitions**:
|
||||||
- Tap balance row → **AddressToken** (for that token)
|
- Tap balance row → **AddressToken** (for that token)
|
||||||
- "Send" → **Send**
|
- "Send" → **Send**
|
||||||
- "Receive" → **Receive**
|
- "Receive" → **Receive**
|
||||||
- "+ Token" → **AddToken**
|
- "+ Token" → **AddToken**
|
||||||
- "Show private key" → **ShowPrivateKey**
|
|
||||||
- Tap transaction row → **TransactionDetail**
|
- Tap transaction row → **TransactionDetail**
|
||||||
- "Back" → **Home**
|
- "Back" → **Home**
|
||||||
|
|
||||||
#### ShowPrivateKey
|
|
||||||
|
|
||||||
- **When**: User clicked "Show private key" on AddressDetail.
|
|
||||||
- **Elements**:
|
|
||||||
- "Back" button
|
|
||||||
- Title: "Display Private Key"
|
|
||||||
- Warning box (lock + money icons) explaining the key controls funds and
|
|
||||||
that the user is responsible for clipboard management
|
|
||||||
- Password input
|
|
||||||
- "Display Private Key" button (with lock + money icons)
|
|
||||||
- After reveal: private key in a read-only well (monospace, select-all),
|
|
||||||
Copy button, Done button
|
|
||||||
- **Transitions**:
|
|
||||||
- "Display Private Key" (correct password) → reveals key in-place
|
|
||||||
- "Copy" → copies key to clipboard
|
|
||||||
- "Done" / "Back" → **AddressDetail** (key cleared from DOM)
|
|
||||||
|
|
||||||
#### AddressToken
|
#### AddressToken
|
||||||
|
|
||||||
- **When**: User clicked a specific token balance on AddressDetail.
|
- **When**: User clicked a specific token balance on AddressDetail.
|
||||||
|
|||||||
@@ -307,15 +307,6 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
<button
|
|
||||||
id="btn-show-private-key"
|
|
||||||
class="border border-border px-2 py-1 hover:bg-fg hover:text-bg cursor-pointer text-xs"
|
|
||||||
>
|
|
||||||
🔒 Show private key
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- transactions -->
|
<!-- transactions -->
|
||||||
<div class="mt-3">
|
<div class="mt-3">
|
||||||
<div class="border-b border-border pb-1 mb-1">
|
<div class="border-b border-border pb-1 mb-1">
|
||||||
@@ -327,77 +318,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- ============ SHOW PRIVATE KEY ============ -->
|
|
||||||
<div id="view-show-private-key" class="view hidden">
|
|
||||||
<button
|
|
||||||
id="btn-show-pk-back"
|
|
||||||
class="border border-border px-2 py-1 hover:bg-fg hover:text-bg cursor-pointer mb-2"
|
|
||||||
>
|
|
||||||
< Back
|
|
||||||
</button>
|
|
||||||
<h2 class="font-bold mb-2">Display Private Key</h2>
|
|
||||||
|
|
||||||
<!-- password prompt section -->
|
|
||||||
<div id="show-pk-prompt">
|
|
||||||
<div
|
|
||||||
class="border border-border border-dashed p-3 mb-3 text-xs"
|
|
||||||
>
|
|
||||||
<p class="mb-1">
|
|
||||||
🔒💰 Your private key controls this
|
|
||||||
address and all its funds. Anyone who has it can
|
|
||||||
spend your tokens.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Do not share it. Do not paste it into websites. If
|
|
||||||
you copy it, you are responsible for clearing your
|
|
||||||
clipboard when you are done.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div class="mb-2">
|
|
||||||
<label class="block mb-1">Password</label>
|
|
||||||
<input
|
|
||||||
type="password"
|
|
||||||
id="show-pk-password"
|
|
||||||
class="border border-border p-1 w-full font-mono text-sm bg-bg text-fg"
|
|
||||||
placeholder="Enter your password"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
id="show-pk-error"
|
|
||||||
class="text-xs mb-2 border border-border border-dashed p-1 hidden"
|
|
||||||
></div>
|
|
||||||
<button
|
|
||||||
id="btn-show-pk-reveal"
|
|
||||||
class="border border-border px-2 py-1 hover:bg-fg hover:text-bg cursor-pointer"
|
|
||||||
>
|
|
||||||
🔒💰 Display Private Key
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- revealed key section -->
|
|
||||||
<div id="show-pk-key-well" class="hidden">
|
|
||||||
<div
|
|
||||||
class="bg-well p-3 mx-1 mb-3 break-all font-mono text-xs select-all"
|
|
||||||
>
|
|
||||||
<span id="show-pk-key-value"></span>
|
|
||||||
</div>
|
|
||||||
<div class="flex gap-2">
|
|
||||||
<button
|
|
||||||
id="btn-show-pk-copy"
|
|
||||||
class="border border-border px-2 py-1 hover:bg-fg hover:text-bg cursor-pointer"
|
|
||||||
>
|
|
||||||
Copy
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
id="btn-show-pk-done"
|
|
||||||
class="border border-border px-2 py-1 hover:bg-fg hover:text-bg cursor-pointer"
|
|
||||||
>
|
|
||||||
Done
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- ============ ADDRESS-TOKEN DETAIL VIEW ============ -->
|
<!-- ============ ADDRESS-TOKEN DETAIL VIEW ============ -->
|
||||||
<div id="view-address-token" class="view hidden">
|
<div id="view-address-token" class="view hidden">
|
||||||
<button
|
<button
|
||||||
@@ -1079,7 +999,12 @@
|
|||||||
class="text-xs"
|
class="text-xs"
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="tx-detail-rawdata-section" class="hidden">
|
</div>
|
||||||
|
<div class="mb-4">
|
||||||
|
<div class="text-xs text-muted mb-1">Transaction hash</div>
|
||||||
|
<div id="tx-detail-hash" class="text-xs break-all"></div>
|
||||||
|
</div>
|
||||||
|
<div id="tx-detail-rawdata-section" class="mb-4 hidden">
|
||||||
<div class="text-xs text-muted mb-1">Raw data</div>
|
<div class="text-xs text-muted mb-1">Raw data</div>
|
||||||
<div
|
<div
|
||||||
id="tx-detail-rawdata"
|
id="tx-detail-rawdata"
|
||||||
@@ -1087,11 +1012,6 @@
|
|||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-4">
|
|
||||||
<div class="text-xs text-muted mb-1">Transaction hash</div>
|
|
||||||
<div id="tx-detail-hash" class="text-xs break-all"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- ============ TRANSACTION APPROVAL ============ -->
|
<!-- ============ TRANSACTION APPROVAL ============ -->
|
||||||
<div id="view-approve-tx" class="view hidden">
|
<div id="view-approve-tx" class="view hidden">
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ const txStatus = require("./views/txStatus");
|
|||||||
const transactionDetail = require("./views/transactionDetail");
|
const transactionDetail = require("./views/transactionDetail");
|
||||||
const receive = require("./views/receive");
|
const receive = require("./views/receive");
|
||||||
const addToken = require("./views/addToken");
|
const addToken = require("./views/addToken");
|
||||||
const showPrivateKey = require("./views/showPrivateKey");
|
|
||||||
const settings = require("./views/settings");
|
const settings = require("./views/settings");
|
||||||
const settingsAddToken = require("./views/settingsAddToken");
|
const settingsAddToken = require("./views/settingsAddToken");
|
||||||
const approval = require("./views/approval");
|
const approval = require("./views/approval");
|
||||||
@@ -57,7 +56,6 @@ const ctx = {
|
|||||||
showAddWalletView: () => addWallet.show(),
|
showAddWalletView: () => addWallet.show(),
|
||||||
showImportKeyView: () => importKey.show(),
|
showImportKeyView: () => importKey.show(),
|
||||||
showAddressDetail: () => addressDetail.show(),
|
showAddressDetail: () => addressDetail.show(),
|
||||||
showPrivateKey: () => showPrivateKey.show(),
|
|
||||||
showAddressToken: () => addressToken.show(),
|
showAddressToken: () => addressToken.show(),
|
||||||
showAddTokenView: () => addToken.show(),
|
showAddTokenView: () => addToken.show(),
|
||||||
showConfirmTx: (txInfo) => confirmTx.show(txInfo),
|
showConfirmTx: (txInfo) => confirmTx.show(txInfo),
|
||||||
@@ -214,7 +212,6 @@ async function init() {
|
|||||||
importKey.init(ctx);
|
importKey.init(ctx);
|
||||||
home.init(ctx);
|
home.init(ctx);
|
||||||
addressDetail.init(ctx);
|
addressDetail.init(ctx);
|
||||||
showPrivateKey.init(ctx);
|
|
||||||
addressToken.init(ctx);
|
addressToken.init(ctx);
|
||||||
send.init(ctx);
|
send.init(ctx);
|
||||||
confirmTx.init(ctx);
|
confirmTx.init(ctx);
|
||||||
|
|||||||
@@ -186,8 +186,12 @@ function renderTransactions(txs) {
|
|||||||
let html = "";
|
let html = "";
|
||||||
let i = 0;
|
let i = 0;
|
||||||
for (const tx of txs) {
|
for (const tx of txs) {
|
||||||
|
// For swap transactions, show the user's own labelled wallet
|
||||||
|
// address instead of the contract address (see issue #55).
|
||||||
const counterparty =
|
const counterparty =
|
||||||
tx.direction === "sent" || tx.direction === "contract"
|
tx.direction === "contract" && tx.directionLabel === "Swap"
|
||||||
|
? tx.from
|
||||||
|
: tx.direction === "sent" || tx.direction === "contract"
|
||||||
? tx.to
|
? tx.to
|
||||||
: tx.from;
|
: tx.from;
|
||||||
const ensName = ensNameMap.get(counterparty) || null;
|
const ensName = ensNameMap.get(counterparty) || null;
|
||||||
@@ -261,10 +265,6 @@ function init(_ctx) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("btn-add-token").addEventListener("click", ctx.showAddTokenView);
|
$("btn-add-token").addEventListener("click", ctx.showAddTokenView);
|
||||||
|
|
||||||
$("btn-show-private-key").addEventListener("click", () => {
|
|
||||||
ctx.showPrivateKey();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { init, show };
|
module.exports = { init, show };
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ function show() {
|
|||||||
|
|
||||||
// Determine token symbol and balance
|
// Determine token symbol and balance
|
||||||
let symbol, amount, price;
|
let symbol, amount, price;
|
||||||
|
const knownToken = TOKEN_BY_ADDRESS.get(tokenId.toLowerCase());
|
||||||
if (tokenId === "ETH") {
|
if (tokenId === "ETH") {
|
||||||
symbol = "ETH";
|
symbol = "ETH";
|
||||||
amount = parseFloat(addr.balance || "0");
|
amount = parseFloat(addr.balance || "0");
|
||||||
@@ -95,7 +96,14 @@ function show() {
|
|||||||
const tb = (addr.tokenBalances || []).find(
|
const tb = (addr.tokenBalances || []).find(
|
||||||
(t) => t.address.toLowerCase() === tokenId.toLowerCase(),
|
(t) => t.address.toLowerCase() === tokenId.toLowerCase(),
|
||||||
);
|
);
|
||||||
symbol = tb ? tb.symbol : "?";
|
const tracked = (state.trackedTokens || []).find(
|
||||||
|
(t) => t.address.toLowerCase() === tokenId.toLowerCase(),
|
||||||
|
);
|
||||||
|
symbol =
|
||||||
|
(tb && tb.symbol) ||
|
||||||
|
(tracked && tracked.symbol) ||
|
||||||
|
(knownToken && knownToken.symbol) ||
|
||||||
|
"?";
|
||||||
amount = tb ? parseFloat(tb.balance || "0") : 0;
|
amount = tb ? parseFloat(tb.balance || "0") : 0;
|
||||||
price = getPrice(symbol);
|
price = getPrice(symbol);
|
||||||
}
|
}
|
||||||
@@ -138,13 +146,32 @@ function show() {
|
|||||||
const tb = (addr.tokenBalances || []).find(
|
const tb = (addr.tokenBalances || []).find(
|
||||||
(t) => t.address.toLowerCase() === tokenId.toLowerCase(),
|
(t) => t.address.toLowerCase() === tokenId.toLowerCase(),
|
||||||
);
|
);
|
||||||
const tokenName = tb && tb.name ? escapeHtml(tb.name) : null;
|
const tracked = (state.trackedTokens || []).find(
|
||||||
const tokenSymbol = tb && tb.symbol ? escapeHtml(tb.symbol) : null;
|
(t) => t.address.toLowerCase() === tokenId.toLowerCase(),
|
||||||
const tokenDecimals = tb && tb.decimals != null ? tb.decimals : null;
|
);
|
||||||
|
const rawName =
|
||||||
|
(tb && tb.name) ||
|
||||||
|
(tracked && tracked.name) ||
|
||||||
|
(knownToken && knownToken.name) ||
|
||||||
|
null;
|
||||||
|
const rawSymbol =
|
||||||
|
(tb && tb.symbol) ||
|
||||||
|
(tracked && tracked.symbol) ||
|
||||||
|
(knownToken && knownToken.symbol) ||
|
||||||
|
null;
|
||||||
|
const tokenName = rawName ? escapeHtml(rawName) : null;
|
||||||
|
const tokenSymbol = rawSymbol ? escapeHtml(rawSymbol) : null;
|
||||||
|
const tokenDecimals =
|
||||||
|
tb && tb.decimals != null
|
||||||
|
? tb.decimals
|
||||||
|
: tracked && tracked.decimals != null
|
||||||
|
? tracked.decimals
|
||||||
|
: knownToken && knownToken.decimals != null
|
||||||
|
? knownToken.decimals
|
||||||
|
: null;
|
||||||
const tokenHolders = tb && tb.holders != null ? tb.holders : null;
|
const tokenHolders = tb && tb.holders != null ? tb.holders : null;
|
||||||
const dot = addressDotHtml(tokenId);
|
const dot = addressDotHtml(tokenId);
|
||||||
const tokenLink = `https://etherscan.io/token/${escapeHtml(tokenId)}`;
|
const tokenLink = `https://etherscan.io/token/${escapeHtml(tokenId)}`;
|
||||||
const knownToken = TOKEN_BY_ADDRESS.get(tokenId.toLowerCase());
|
|
||||||
const projectUrl = knownToken && knownToken.url ? knownToken.url : null;
|
const projectUrl = knownToken && knownToken.url ? knownToken.url : null;
|
||||||
let infoHtml = `<div class="font-bold mb-2">Contract Address</div>`;
|
let infoHtml = `<div class="font-bold mb-2">Contract Address</div>`;
|
||||||
infoHtml +=
|
infoHtml +=
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ const VIEWS = [
|
|||||||
"import-key",
|
"import-key",
|
||||||
"main",
|
"main",
|
||||||
"address",
|
"address",
|
||||||
"show-private-key",
|
|
||||||
"address-token",
|
"address-token",
|
||||||
"send",
|
"send",
|
||||||
"confirm-tx",
|
"confirm-tx",
|
||||||
|
|||||||
@@ -103,8 +103,13 @@ function renderHomeTxList(ctx) {
|
|||||||
let html = "";
|
let html = "";
|
||||||
let i = 0;
|
let i = 0;
|
||||||
for (const tx of homeTxs) {
|
for (const tx of homeTxs) {
|
||||||
|
// For swap transactions, show the user's own labelled wallet
|
||||||
|
// address (the one that initiated the swap) instead of the
|
||||||
|
// contract address which is not useful in the list view.
|
||||||
const counterparty =
|
const counterparty =
|
||||||
tx.direction === "sent" || tx.direction === "contract"
|
tx.direction === "contract" && tx.directionLabel === "Swap"
|
||||||
|
? tx.from
|
||||||
|
: tx.direction === "sent" || tx.direction === "contract"
|
||||||
? tx.to
|
? tx.to
|
||||||
: tx.from;
|
: tx.from;
|
||||||
const dirLabel = tx.directionLabel;
|
const dirLabel = tx.directionLabel;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const {
|
|||||||
const { state, currentAddress } = require("../../shared/state");
|
const { state, currentAddress } = require("../../shared/state");
|
||||||
let ctx;
|
let ctx;
|
||||||
const { getProvider } = require("../../shared/balances");
|
const { getProvider } = require("../../shared/balances");
|
||||||
const { KNOWN_SYMBOLS } = require("../../shared/tokenList");
|
const { KNOWN_SYMBOLS, TOKEN_BY_ADDRESS } = require("../../shared/tokenList");
|
||||||
|
|
||||||
const EXT_ICON =
|
const EXT_ICON =
|
||||||
`<span style="display:inline-block;width:10px;height:10px;margin-left:4px;vertical-align:middle">` +
|
`<span style="display:inline-block;width:10px;height:10px;margin-left:4px;vertical-align:middle">` +
|
||||||
@@ -73,7 +73,15 @@ function updateSendBalance() {
|
|||||||
const tb = (addr.tokenBalances || []).find(
|
const tb = (addr.tokenBalances || []).find(
|
||||||
(t) => t.address.toLowerCase() === token.toLowerCase(),
|
(t) => t.address.toLowerCase() === token.toLowerCase(),
|
||||||
);
|
);
|
||||||
const symbol = tb ? tb.symbol : "?";
|
const knownToken = TOKEN_BY_ADDRESS.get(token.toLowerCase());
|
||||||
|
const tracked = (state.trackedTokens || []).find(
|
||||||
|
(t) => t.address.toLowerCase() === token.toLowerCase(),
|
||||||
|
);
|
||||||
|
const symbol =
|
||||||
|
(tb && tb.symbol) ||
|
||||||
|
(tracked && tracked.symbol) ||
|
||||||
|
(knownToken && knownToken.symbol) ||
|
||||||
|
"?";
|
||||||
const bal = tb ? tb.balance || "0" : "0";
|
const bal = tb ? tb.balance || "0" : "0";
|
||||||
$("send-balance").textContent =
|
$("send-balance").textContent =
|
||||||
"Current balance: " + bal + " " + symbol;
|
"Current balance: " + bal + " " + symbol;
|
||||||
@@ -124,7 +132,15 @@ function init(_ctx) {
|
|||||||
const tb = (addr.tokenBalances || []).find(
|
const tb = (addr.tokenBalances || []).find(
|
||||||
(t) => t.address.toLowerCase() === token.toLowerCase(),
|
(t) => t.address.toLowerCase() === token.toLowerCase(),
|
||||||
);
|
);
|
||||||
tokenSymbol = tb ? tb.symbol : "?";
|
const knownTk = TOKEN_BY_ADDRESS.get(token.toLowerCase());
|
||||||
|
const trackedTk = (state.trackedTokens || []).find(
|
||||||
|
(t) => t.address.toLowerCase() === token.toLowerCase(),
|
||||||
|
);
|
||||||
|
tokenSymbol =
|
||||||
|
(tb && tb.symbol) ||
|
||||||
|
(trackedTk && trackedTk.symbol) ||
|
||||||
|
(knownTk && knownTk.symbol) ||
|
||||||
|
"?";
|
||||||
tokenBalance = tb ? tb.balance || "0" : "0";
|
tokenBalance = tb ? tb.balance || "0" : "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,79 +0,0 @@
|
|||||||
const { $, showView, showFlash, showError, hideError } = require("./helpers");
|
|
||||||
const { state } = require("../../shared/state");
|
|
||||||
const { decryptWithPassword } = require("../../shared/vault");
|
|
||||||
const { getPrivateKeyForAddress } = require("../../shared/wallet");
|
|
||||||
|
|
||||||
let ctx;
|
|
||||||
let revealed = false;
|
|
||||||
|
|
||||||
function show() {
|
|
||||||
revealed = false;
|
|
||||||
$("show-pk-password").value = "";
|
|
||||||
$("show-pk-key-well").classList.add("hidden");
|
|
||||||
$("show-pk-key-value").textContent = "";
|
|
||||||
$("show-pk-prompt").classList.remove("hidden");
|
|
||||||
hideError("show-pk-error");
|
|
||||||
showView("show-private-key");
|
|
||||||
}
|
|
||||||
|
|
||||||
function init(_ctx) {
|
|
||||||
ctx = _ctx;
|
|
||||||
|
|
||||||
$("btn-show-pk-back").addEventListener("click", () => {
|
|
||||||
clearKey();
|
|
||||||
ctx.showAddressDetail();
|
|
||||||
});
|
|
||||||
|
|
||||||
$("btn-show-pk-reveal").addEventListener("click", async () => {
|
|
||||||
const pw = $("show-pk-password").value;
|
|
||||||
if (!pw) {
|
|
||||||
showError("show-pk-error", "Please enter your password.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const wallet = state.wallets[state.selectedWallet];
|
|
||||||
let decryptedSecret;
|
|
||||||
try {
|
|
||||||
decryptedSecret = await decryptWithPassword(
|
|
||||||
wallet.encryptedSecret,
|
|
||||||
pw,
|
|
||||||
);
|
|
||||||
} catch (_e) {
|
|
||||||
showError("show-pk-error", "Wrong password.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const privateKey = getPrivateKeyForAddress(
|
|
||||||
wallet,
|
|
||||||
state.selectedAddress,
|
|
||||||
decryptedSecret,
|
|
||||||
);
|
|
||||||
|
|
||||||
revealed = true;
|
|
||||||
$("show-pk-prompt").classList.add("hidden");
|
|
||||||
$("show-pk-key-well").classList.remove("hidden");
|
|
||||||
$("show-pk-key-value").textContent = privateKey;
|
|
||||||
hideError("show-pk-error");
|
|
||||||
});
|
|
||||||
|
|
||||||
$("btn-show-pk-copy").addEventListener("click", () => {
|
|
||||||
const key = $("show-pk-key-value").textContent;
|
|
||||||
if (key) {
|
|
||||||
navigator.clipboard.writeText(key);
|
|
||||||
showFlash("Copied!");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$("btn-show-pk-done").addEventListener("click", () => {
|
|
||||||
clearKey();
|
|
||||||
ctx.showAddressDetail();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function clearKey() {
|
|
||||||
revealed = false;
|
|
||||||
$("show-pk-key-value").textContent = "";
|
|
||||||
$("show-pk-password").value = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { init, show };
|
|
||||||
@@ -37,11 +37,19 @@ function blockieHtml(address) {
|
|||||||
return `<img src="${src}" width="48" height="48" style="image-rendering:pixelated;border-radius:50%;display:inline-block">`;
|
return `<img src="${src}" width="48" height="48" style="image-rendering:pixelated;border-radius:50%;display:inline-block">`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function etherscanLinkHtml(url) {
|
||||||
|
return (
|
||||||
|
`<a href="${url}" target="_blank" rel="noopener" ` +
|
||||||
|
`class="inline-flex items-center"` +
|
||||||
|
`>${EXT_ICON}</a>`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function txAddressHtml(address, ensName, title) {
|
function txAddressHtml(address, ensName, title) {
|
||||||
const blockie = blockieHtml(address);
|
const blockie = blockieHtml(address);
|
||||||
const dot = addressDotHtml(address);
|
const dot = addressDotHtml(address);
|
||||||
const link = `https://etherscan.io/address/${address}`;
|
const link = `https://etherscan.io/address/${address}`;
|
||||||
const extLink = `<a href="${link}" target="_blank" rel="noopener" class="inline-flex items-center">${EXT_ICON}</a>`;
|
const extLink = etherscanLinkHtml(link);
|
||||||
let html = `<div class="mb-1">${blockie}</div>`;
|
let html = `<div class="mb-1">${blockie}</div>`;
|
||||||
if (title) {
|
if (title) {
|
||||||
html += `<div class="font-bold">${escapeHtml(title)}</div>`;
|
html += `<div class="font-bold">${escapeHtml(title)}</div>`;
|
||||||
@@ -50,10 +58,10 @@ function txAddressHtml(address, ensName, title) {
|
|||||||
html +=
|
html +=
|
||||||
`<div class="flex items-center">${dot}` +
|
`<div class="flex items-center">${dot}` +
|
||||||
copyableHtml(ensName, "") +
|
copyableHtml(ensName, "") +
|
||||||
extLink +
|
|
||||||
`</div>` +
|
`</div>` +
|
||||||
`<div class="break-all">` +
|
`<div class="flex items-center">${dot}` +
|
||||||
copyableHtml(address, "break-all") +
|
copyableHtml(address, "break-all") +
|
||||||
|
extLink +
|
||||||
`</div>`;
|
`</div>`;
|
||||||
} else {
|
} else {
|
||||||
html +=
|
html +=
|
||||||
@@ -67,7 +75,7 @@ function txAddressHtml(address, ensName, title) {
|
|||||||
|
|
||||||
function txHashHtml(hash) {
|
function txHashHtml(hash) {
|
||||||
const link = `https://etherscan.io/tx/${hash}`;
|
const link = `https://etherscan.io/tx/${hash}`;
|
||||||
const extLink = `<a href="${link}" target="_blank" rel="noopener" class="inline-flex items-center">${EXT_ICON}</a>`;
|
const extLink = etherscanLinkHtml(link);
|
||||||
return copyableHtml(hash, "break-all") + extLink;
|
return copyableHtml(hash, "break-all") + extLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,9 +101,6 @@ function show(tx) {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
render();
|
render();
|
||||||
if (tx.isContractCall || tx.direction === "contract") {
|
|
||||||
loadCalldata(tx.hash, tx.to);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function render() {
|
function render() {
|
||||||
@@ -144,9 +149,15 @@ function render() {
|
|||||||
if (headingEl) headingEl.textContent = "Transaction";
|
if (headingEl) headingEl.textContent = "Transaction";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide calldata section by default; loadCalldata will show it if needed
|
// Hide calldata and raw data sections; re-fetch if this is a contract call
|
||||||
const calldataSection = $("tx-detail-calldata-section");
|
const calldataSection = $("tx-detail-calldata-section");
|
||||||
if (calldataSection) calldataSection.classList.add("hidden");
|
if (calldataSection) calldataSection.classList.add("hidden");
|
||||||
|
const rawDataSection = $("tx-detail-rawdata-section");
|
||||||
|
if (rawDataSection) rawDataSection.classList.add("hidden");
|
||||||
|
|
||||||
|
if (tx.isContractCall || tx.direction === "contract") {
|
||||||
|
loadCalldata(tx.hash, tx.to);
|
||||||
|
}
|
||||||
|
|
||||||
$("tx-detail-time").textContent =
|
$("tx-detail-time").textContent =
|
||||||
isoDate(tx.timestamp) + " (" + timeAgo(tx.timestamp) + ")";
|
isoDate(tx.timestamp) + " (" + timeAgo(tx.timestamp) + ")";
|
||||||
@@ -193,9 +204,20 @@ async function loadCalldata(txHash, toAddress) {
|
|||||||
for (const d of decoded.details || []) {
|
for (const d of decoded.details || []) {
|
||||||
detailsHtml += `<div class="mb-2">`;
|
detailsHtml += `<div class="mb-2">`;
|
||||||
detailsHtml += `<div class="text-muted">${escapeHtml(d.label)}</div>`;
|
detailsHtml += `<div class="text-muted">${escapeHtml(d.label)}</div>`;
|
||||||
if (d.address) {
|
if (d.address && d.isToken) {
|
||||||
|
// Token entry: show symbol on its own line, then dot + address + Etherscan link
|
||||||
const dot = addressDotHtml(d.address);
|
const dot = addressDotHtml(d.address);
|
||||||
detailsHtml += `<div>${dot}${copyableHtml(d.value, "break-all")}</div>`;
|
const tokenSymbol = d.value.match(/^(\S+)\s*\(/)?.[1];
|
||||||
|
if (tokenSymbol) {
|
||||||
|
detailsHtml += `<div class="font-bold">${escapeHtml(tokenSymbol)}</div>`;
|
||||||
|
}
|
||||||
|
const etherscanUrl = `https://etherscan.io/token/${d.address}`;
|
||||||
|
detailsHtml += `<div class="flex items-center">${dot}${copyableHtml(d.address, "break-all")}${etherscanLinkHtml(etherscanUrl)}</div>`;
|
||||||
|
} else if (d.address) {
|
||||||
|
// Protocol/contract entry: show name + Etherscan link
|
||||||
|
const dot = addressDotHtml(d.address);
|
||||||
|
const etherscanUrl = `https://etherscan.io/address/${d.address}`;
|
||||||
|
detailsHtml += `<div class="flex items-center">${dot}${copyableHtml(d.value, "break-all")}${etherscanLinkHtml(etherscanUrl)}</div>`;
|
||||||
} else {
|
} else {
|
||||||
detailsHtml += `<div class="font-bold">${escapeHtml(d.value)}</div>`;
|
detailsHtml += `<div class="font-bold">${escapeHtml(d.value)}</div>`;
|
||||||
}
|
}
|
||||||
@@ -219,13 +241,16 @@ async function loadCalldata(txHash, toAddress) {
|
|||||||
|
|
||||||
section.classList.remove("hidden");
|
section.classList.remove("hidden");
|
||||||
|
|
||||||
// Bind copy handlers for new elements
|
// Bind copy handlers for new elements (including raw data now outside section)
|
||||||
section.querySelectorAll("[data-copy]").forEach((el) => {
|
const copyTargets = [section, rawSection].filter(Boolean);
|
||||||
|
for (const container of copyTargets) {
|
||||||
|
container.querySelectorAll("[data-copy]").forEach((el) => {
|
||||||
el.onclick = () => {
|
el.onclick = () => {
|
||||||
navigator.clipboard.writeText(el.dataset.copy);
|
navigator.clipboard.writeText(el.dataset.copy);
|
||||||
showFlash("Copied!");
|
showFlash("Copied!");
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.errorf("loadCalldata failed:", e.message);
|
log.errorf("loadCalldata failed:", e.message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ async function fetchTokenBalances(address, blockscoutUrl, trackedTokens) {
|
|||||||
|
|
||||||
balances.push({
|
balances.push({
|
||||||
address: item.token.address_hash,
|
address: item.token.address_hash,
|
||||||
|
name: item.token.name || "",
|
||||||
symbol: item.token.symbol || "???",
|
symbol: item.token.symbol || "???",
|
||||||
decimals: decimals,
|
decimals: decimals,
|
||||||
balance: bal,
|
balance: bal,
|
||||||
|
|||||||
@@ -41,18 +41,6 @@ function getSignerForAddress(walletData, addrIndex, decryptedSecret) {
|
|||||||
return new Wallet(decryptedSecret);
|
return new Wallet(decryptedSecret);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPrivateKeyForAddress(walletData, addrIndex, decryptedSecret) {
|
|
||||||
if (walletData.type === "hd") {
|
|
||||||
const node = HDNodeWallet.fromPhrase(
|
|
||||||
decryptedSecret,
|
|
||||||
"",
|
|
||||||
BIP44_ETH_PATH,
|
|
||||||
);
|
|
||||||
return node.deriveChild(addrIndex).privateKey;
|
|
||||||
}
|
|
||||||
return decryptedSecret;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isValidMnemonic(mnemonic) {
|
function isValidMnemonic(mnemonic) {
|
||||||
return Mnemonic.isValidMnemonic(mnemonic);
|
return Mnemonic.isValidMnemonic(mnemonic);
|
||||||
}
|
}
|
||||||
@@ -63,6 +51,5 @@ module.exports = {
|
|||||||
hdWalletFromMnemonic,
|
hdWalletFromMnemonic,
|
||||||
addressFromPrivateKey,
|
addressFromPrivateKey,
|
||||||
getSignerForAddress,
|
getSignerForAddress,
|
||||||
getPrivateKeyForAddress,
|
|
||||||
isValidMnemonic,
|
isValidMnemonic,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user