fix: rules audit items 1,3,6 (closes #1)
All checks were successful
check / check (push) Successful in 22s
All checks were successful
check / check (push) Successful in 22s
This commit is contained in:
4
RULES.md
4
RULES.md
@@ -17,8 +17,8 @@ contradicts either, the originals govern.
|
|||||||
|
|
||||||
## External Communication
|
## External Communication
|
||||||
|
|
||||||
- [ ] Extension contacts exactly two external services: configured RPC endpoint
|
- [ ] Extension contacts exactly three external services: configured RPC
|
||||||
and CoinDesk price API
|
endpoint, CoinDesk price API, and Blockscout block-explorer API
|
||||||
- [ ] No analytics, telemetry, or tracking
|
- [ ] No analytics, telemetry, or tracking
|
||||||
- [ ] No user-specific data sent except to the configured RPC endpoint
|
- [ ] No user-specific data sent except to the configured RPC endpoint
|
||||||
- [ ] No Infura/Alchemy hard dependency
|
- [ ] No Infura/Alchemy hard dependency
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ function showFlash(msg, duration = 2000) {
|
|||||||
|
|
||||||
function balanceLine(symbol, amount, price, tokenId) {
|
function balanceLine(symbol, amount, price, tokenId) {
|
||||||
const qty = amount.toFixed(4);
|
const qty = amount.toFixed(4);
|
||||||
const usd = price ? formatUsd(amount * price) : "";
|
const usd = price ? formatUsd(amount * price) || " " : " ";
|
||||||
const tokenAttr = tokenId ? ` data-token="${tokenId}"` : "";
|
const tokenAttr = tokenId ? ` data-token="${tokenId}"` : "";
|
||||||
const clickClass = tokenId
|
const clickClass = tokenId
|
||||||
? " cursor-pointer hover:bg-hover balance-row"
|
? " cursor-pointer hover:bg-hover balance-row"
|
||||||
@@ -219,6 +219,41 @@ function formatAddressHtml(address, ensName, maxLen, title) {
|
|||||||
return `<div class="flex items-center">${dot}<span class="break-all">${escapeHtml(displayAddr)}</span></div>`;
|
return `<div class="flex items-center">${dot}<span class="break-all">${escapeHtml(displayAddr)}</span></div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isoDate(timestamp) {
|
||||||
|
const d = new Date(timestamp * 1000);
|
||||||
|
const pad = (n) => String(n).padStart(2, "0");
|
||||||
|
return (
|
||||||
|
d.getFullYear() +
|
||||||
|
"-" +
|
||||||
|
pad(d.getMonth() + 1) +
|
||||||
|
"-" +
|
||||||
|
pad(d.getDate()) +
|
||||||
|
" " +
|
||||||
|
pad(d.getHours()) +
|
||||||
|
":" +
|
||||||
|
pad(d.getMinutes()) +
|
||||||
|
":" +
|
||||||
|
pad(d.getSeconds())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function timeAgo(timestamp) {
|
||||||
|
const seconds = Math.floor(Date.now() / 1000 - timestamp);
|
||||||
|
if (seconds < 60) return seconds + " seconds ago";
|
||||||
|
const minutes = Math.floor(seconds / 60);
|
||||||
|
if (minutes < 60)
|
||||||
|
return minutes + " minute" + (minutes !== 1 ? "s" : "") + " ago";
|
||||||
|
const hours = Math.floor(minutes / 60);
|
||||||
|
if (hours < 24) return hours + " hour" + (hours !== 1 ? "s" : "") + " ago";
|
||||||
|
const days = Math.floor(hours / 24);
|
||||||
|
if (days < 30) return days + " day" + (days !== 1 ? "s" : "") + " ago";
|
||||||
|
const months = Math.floor(days / 30);
|
||||||
|
if (months < 12)
|
||||||
|
return months + " month" + (months !== 1 ? "s" : "") + " ago";
|
||||||
|
const years = Math.floor(days / 365);
|
||||||
|
return years + " year" + (years !== 1 ? "s" : "") + " ago";
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
$,
|
$,
|
||||||
showError,
|
showError,
|
||||||
@@ -233,4 +268,6 @@ module.exports = {
|
|||||||
addressTitle,
|
addressTitle,
|
||||||
formatAddressHtml,
|
formatAddressHtml,
|
||||||
truncateMiddle,
|
truncateMiddle,
|
||||||
|
isoDate,
|
||||||
|
timeAgo,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ const {
|
|||||||
showView,
|
showView,
|
||||||
showFlash,
|
showFlash,
|
||||||
balanceLinesForAddress,
|
balanceLinesForAddress,
|
||||||
|
isoDate,
|
||||||
|
timeAgo,
|
||||||
addressDotHtml,
|
addressDotHtml,
|
||||||
escapeHtml,
|
escapeHtml,
|
||||||
truncateMiddle,
|
truncateMiddle,
|
||||||
@@ -87,41 +89,6 @@ function renderActiveAddress() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function timeAgo(timestamp) {
|
|
||||||
const seconds = Math.floor(Date.now() / 1000 - timestamp);
|
|
||||||
if (seconds < 60) return seconds + " seconds ago";
|
|
||||||
const minutes = Math.floor(seconds / 60);
|
|
||||||
if (minutes < 60)
|
|
||||||
return minutes + " minute" + (minutes !== 1 ? "s" : "") + " ago";
|
|
||||||
const hours = Math.floor(minutes / 60);
|
|
||||||
if (hours < 24) return hours + " hour" + (hours !== 1 ? "s" : "") + " ago";
|
|
||||||
const days = Math.floor(hours / 24);
|
|
||||||
if (days < 30) return days + " day" + (days !== 1 ? "s" : "") + " ago";
|
|
||||||
const months = Math.floor(days / 30);
|
|
||||||
if (months < 12)
|
|
||||||
return months + " month" + (months !== 1 ? "s" : "") + " ago";
|
|
||||||
const years = Math.floor(days / 365);
|
|
||||||
return years + " year" + (years !== 1 ? "s" : "") + " ago";
|
|
||||||
}
|
|
||||||
|
|
||||||
function isoDate(timestamp) {
|
|
||||||
const d = new Date(timestamp * 1000);
|
|
||||||
const pad = (n) => String(n).padStart(2, "0");
|
|
||||||
return (
|
|
||||||
d.getFullYear() +
|
|
||||||
"-" +
|
|
||||||
pad(d.getMonth() + 1) +
|
|
||||||
"-" +
|
|
||||||
pad(d.getDate()) +
|
|
||||||
" " +
|
|
||||||
pad(d.getHours()) +
|
|
||||||
":" +
|
|
||||||
pad(d.getMinutes()) +
|
|
||||||
":" +
|
|
||||||
pad(d.getSeconds())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
let homeTxs = [];
|
let homeTxs = [];
|
||||||
|
|
||||||
function renderHomeTxList(ctx) {
|
function renderHomeTxList(ctx) {
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ const {
|
|||||||
addressDotHtml,
|
addressDotHtml,
|
||||||
addressTitle,
|
addressTitle,
|
||||||
escapeHtml,
|
escapeHtml,
|
||||||
|
isoDate,
|
||||||
|
timeAgo,
|
||||||
} = require("./helpers");
|
} = require("./helpers");
|
||||||
const { state } = require("../../shared/state");
|
const { state } = require("../../shared/state");
|
||||||
const makeBlockie = require("ethereum-blockies-base64");
|
const makeBlockie = require("ethereum-blockies-base64");
|
||||||
@@ -21,41 +23,6 @@ const EXT_ICON =
|
|||||||
|
|
||||||
let ctx;
|
let ctx;
|
||||||
|
|
||||||
function isoDate(timestamp) {
|
|
||||||
const d = new Date(timestamp * 1000);
|
|
||||||
const pad = (n) => String(n).padStart(2, "0");
|
|
||||||
return (
|
|
||||||
d.getFullYear() +
|
|
||||||
"-" +
|
|
||||||
pad(d.getMonth() + 1) +
|
|
||||||
"-" +
|
|
||||||
pad(d.getDate()) +
|
|
||||||
" " +
|
|
||||||
pad(d.getHours()) +
|
|
||||||
":" +
|
|
||||||
pad(d.getMinutes()) +
|
|
||||||
":" +
|
|
||||||
pad(d.getSeconds())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function timeAgo(timestamp) {
|
|
||||||
const seconds = Math.floor(Date.now() / 1000 - timestamp);
|
|
||||||
if (seconds < 60) return seconds + " seconds ago";
|
|
||||||
const minutes = Math.floor(seconds / 60);
|
|
||||||
if (minutes < 60)
|
|
||||||
return minutes + " minute" + (minutes !== 1 ? "s" : "") + " ago";
|
|
||||||
const hours = Math.floor(minutes / 60);
|
|
||||||
if (hours < 24) return hours + " hour" + (hours !== 1 ? "s" : "") + " ago";
|
|
||||||
const days = Math.floor(hours / 24);
|
|
||||||
if (days < 30) return days + " day" + (days !== 1 ? "s" : "") + " ago";
|
|
||||||
const months = Math.floor(days / 30);
|
|
||||||
if (months < 12)
|
|
||||||
return months + " month" + (months !== 1 ? "s" : "") + " ago";
|
|
||||||
const years = Math.floor(days / 365);
|
|
||||||
return years + " year" + (years !== 1 ? "s" : "") + " ago";
|
|
||||||
}
|
|
||||||
|
|
||||||
function copyableHtml(text, extraClass) {
|
function copyableHtml(text, extraClass) {
|
||||||
const cls =
|
const cls =
|
||||||
"underline decoration-dashed cursor-pointer" +
|
"underline decoration-dashed cursor-pointer" +
|
||||||
|
|||||||
Reference in New Issue
Block a user