Drop generated shared source artifact
This commit is contained in:
@@ -1,42 +0,0 @@
|
||||
export const PICO_PER_PEY = 100000000n;
|
||||
export const TX_TYPE_LABELS = {
|
||||
0: "unset",
|
||||
1: "miner",
|
||||
2: "protocol",
|
||||
3: "burn",
|
||||
4: "convert",
|
||||
5: "transfer",
|
||||
6: "stake",
|
||||
7: "create-token",
|
||||
8: "audit",
|
||||
9: "return",
|
||||
10: "rollup"
|
||||
};
|
||||
export function formatAtomic(value, decimals = 8) {
|
||||
const atomic = typeof value === "bigint" ? value : BigInt(value);
|
||||
const negative = atomic < 0n;
|
||||
const abs = negative ? atomic * -1n : atomic;
|
||||
const div = 10n ** BigInt(decimals);
|
||||
const whole = abs / div;
|
||||
const fraction = abs % div;
|
||||
const fractionText = fraction.toString().padStart(decimals, "0").replace(/0+$/, "");
|
||||
return `${negative ? "-" : ""}${whole.toString()}${fractionText ? `.${fractionText}` : ""}`;
|
||||
}
|
||||
export function formatPercent(value) {
|
||||
if (value === null || Number.isNaN(value)) {
|
||||
return "n/a";
|
||||
}
|
||||
return `${value.toFixed(2)}%`;
|
||||
}
|
||||
export function txTypeLabel(type) {
|
||||
if (type === null || type === undefined) {
|
||||
return "unknown";
|
||||
}
|
||||
return TX_TYPE_LABELS[type] ?? `type-${type}`;
|
||||
}
|
||||
export function shortHash(hash, left = 8, right = 8) {
|
||||
if (!hash || hash.length <= left + right) {
|
||||
return hash;
|
||||
}
|
||||
return `${hash.slice(0, left)}...${hash.slice(-right)}`;
|
||||
}
|
||||
Reference in New Issue
Block a user