Skip to content

Commit

Permalink
Update Number Parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemans committed Mar 17, 2024
1 parent fdfe040 commit f3a7ccd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
2 changes: 1 addition & 1 deletion web/src/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}

.label {
@apply px-1 py-0.5 bg-light-blue-surface dark:bg-dark-blue-surface text-light-blue-primary dark:text-dark-blue-primary rounded-md;
@apply px-1.5 py-0.5 bg-light-blue-surface dark:bg-dark-blue-surface text-light-blue-primary dark:text-dark-blue-primary rounded-md;
}

input[type="checkbox"]:checked + .open-if-checkbox {
Expand Down
3 changes: 2 additions & 1 deletion web/src/txHistory/TransactionEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const TransactionEntry: FC<{ txHash: EtherscanTx }> = ({ txHash }) => {

return (
<div className="p-4 card w-full space-y-3">
<div className="flex justify-between items-center">
<div className="flex justify-between items-center gap-4">
<div>
<a
href={'https://etherscan.io/tx/' + txHash.hash}
Expand All @@ -115,6 +115,7 @@ export const TransactionEntry: FC<{ txHash: EtherscanTx }> = ({ txHash }) => {
<div>
<span className="label label-blue">{actionLabel}</span>
</div>
{/* <div className="grow"></div> */}
{namesLength && (
<div className="text-center">
<div>{namesLength}</div>
Expand Down
42 changes: 20 additions & 22 deletions web/src/utils/formatThousands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,39 @@ export const formatThousands = (value: bigint) => {
return value.toString();
}

if (value < 10_000n) {
return `${(value / 1000n).toString()}k`;
}

if (value < 100_000n) {
return `${(value / 1000n).toString().slice(0, -1)}k`;
return `${(Number(value / 100n) / 10).toPrecision(3).toString()}k`;
}

if (value < 1_000_000n) {
return `${(value / 1000n).toString().slice(0, -2)}k`;
return `${(Number(value / 100n) / 10).toPrecision(3).toString()}k`;
}

if (value < 10_000_000n) {
return `${(value / 1_000_000n).toString()}M`;
return `${Number(value / 10_000n)
.toPrecision(3)
.toString()}M`;
}

if (value < 100_000_000n) {
return `${(value / 1_000_000n).toString().slice(0, -1)}M`;
}
// if (value < 100_000_000n) {
// return `${(value / 1_000_000n).toString().slice(0, -1)}M`;
// }

if (value < 1_000_000_000n) {
return `${(value / 1_000_000n).toString().slice(0, -2)}M`;
}
// if (value < 1_000_000_000n) {
// return `${(value / 1_000_000n).toString().slice(0, -2)}M`;
// }

if (value < 10_000_000_000n) {
return `${(value / 1_000_000_000n).toString()}B`;
}
// if (value < 10_000_000_000n) {
// return `${(value / 1_000_000_000n).toString()}B`;
// }

if (value < 100_000_000_000n) {
return `${(value / 1_000_000_000n).toString().slice(0, -1)}B`;
}
// if (value < 100_000_000_000n) {
// return `${(value / 1_000_000_000n).toString().slice(0, -1)}B`;
// }

if (value < 1_000_000_000_000n) {
return `${(value / 1_000_000_000n).toString().slice(0, -2)}B`;
}
// if (value < 1_000_000_000_000n) {
// return `${(value / 1_000_000_000n).toString().slice(0, -2)}B`;
// }

return value.toString();
};

0 comments on commit f3a7ccd

Please sign in to comment.