Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ff364edd88 |
No files matched your search
@@ -59,9 +59,13 @@ const { notify, runtimeApi, sendMessage } = require("../../shared/browserApi");
|
|||||||
const erc20Iface = new Interface(ERC20_ABI);
|
const erc20Iface = new Interface(ERC20_ABI);
|
||||||
|
|
||||||
// The link opens the explorer of the network with `chainId`, or of the active
|
// The link opens the explorer of the network with `chainId`, or of the active
|
||||||
// network when none is given.
|
// network when none is given. A chain id that names no network has no
|
||||||
|
// explorer, so the address is drawn without a link.
|
||||||
function approvalAddressHtml(address, chainId) {
|
function approvalAddressHtml(address, chainId) {
|
||||||
const title = addressTitle(address, state.wallets);
|
const title = addressTitle(address, state.wallets);
|
||||||
|
if (chainId && !networkByChainId(chainId)) {
|
||||||
|
return renderAddressHtml(address, { title, noLink: true });
|
||||||
|
}
|
||||||
return renderAddressHtml(address, { title, chainId });
|
return renderAddressHtml(address, { title, chainId });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,10 +112,13 @@ function decodedLine(label) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Open the approval screen, with Ethereum Mainnet active and FROM holding
|
// Open the approval screen, with Ethereum Mainnet active and FROM holding
|
||||||
// `tokenBalances` there, for the site's Sepolia transaction sending
|
// `tokenBalances` there, for the site's transaction sending TRANSFER_DATA to
|
||||||
// TRANSFER_DATA to the token. Confirm answers the signed transaction with a
|
// the token, on Sepolia unless `chainId` names another chain. Confirm answers
|
||||||
// failure, which leads to the error screen.
|
// the signed transaction with a failure, which leads to the error screen.
|
||||||
async function showSepoliaTransfer(tokenBalances = []) {
|
async function showSepoliaTransfer(
|
||||||
|
tokenBalances = [],
|
||||||
|
chainId = NETWORKS.sepolia.chainId,
|
||||||
|
) {
|
||||||
globalThis.document = makeDocument();
|
globalThis.document = makeDocument();
|
||||||
globalThis.window = { location: { search: "" }, close: () => {} };
|
globalThis.window = { location: { search: "" }, close: () => {} };
|
||||||
globalThis.chrome.runtime = {
|
globalThis.chrome.runtime = {
|
||||||
@@ -136,7 +139,7 @@ async function showSepoliaTransfer(tokenBalances = []) {
|
|||||||
approvedTx: {
|
approvedTx: {
|
||||||
type: 2,
|
type: 2,
|
||||||
from: FROM,
|
from: FROM,
|
||||||
chainId: NETWORKS.sepolia.chainId,
|
chainId,
|
||||||
nonce: "0x7",
|
nonce: "0x7",
|
||||||
gasLimit: "0x30d40",
|
gasLimit: "0x30d40",
|
||||||
maxPriorityFeePerGas: "0x3b9aca00",
|
maxPriorityFeePerGas: "0x3b9aca00",
|
||||||
@@ -248,3 +251,20 @@ test("every address links to the Sepolia explorer", async () => {
|
|||||||
expect(node(id).innerHTML).not.toContain(NETWORKS.mainnet.explorerUrl);
|
expect(node(id).innerHTML).not.toContain(NETWORKS.mainnet.explorerUrl);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Chain id 1337 names no network here, so it has no explorer to link to.
|
||||||
|
test("a transaction on a chain id that names no network is shown with no address links", async () => {
|
||||||
|
await showSepoliaTransfer([], "0x539");
|
||||||
|
expect(state.currentView).toBe("approve-tx");
|
||||||
|
expect(node("approve-tx-network").textContent).toBe(
|
||||||
|
"Unknown network (chain id 1337)",
|
||||||
|
);
|
||||||
|
expect(node("approve-tx-from").innerHTML).toContain(FROM);
|
||||||
|
for (const id of [
|
||||||
|
"approve-tx-from",
|
||||||
|
"approve-tx-to",
|
||||||
|
"approve-tx-decoded-details",
|
||||||
|
]) {
|
||||||
|
expect(node(id).innerHTML).not.toContain("href=");
|
||||||
|
}
|
||||||
|
});
|
||||||
Reference in new issue
Block a user