Skip to content

Commit

Permalink
Merge branch 'fix/sync-extension-fix' into tmp/20241227
Browse files Browse the repository at this point in the history
  • Loading branch information
vvvvvv1vvvvvv committed Dec 27, 2024
2 parents d2f96c7 + b5bd4b5 commit 193cdba
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions apps/mobile/src/utils/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ export const calcMaxPriorityFee = (
useMaxFee: boolean,
) => {
if (target.priority_price && target.priority_price !== null) {
if (target.priority_price > target.price) {
return target.price;
}
return target.priority_price;
}
return target.price;
Expand Down
17 changes: 16 additions & 1 deletion packages/biz-utils/src/isomorphic/biz-number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,28 @@ export const formatNumber = (
return n.toFormat(decimal, format);
};

const Sub_Numbers = '₀₁₂₃₄₅₆₇₈₉';

export const formatPrice = (price: string | number, len = 4) => {
if ((price as number) >= 0.1) {
return formatNumber(price);
}
if ((price as number) < 0.00001) {
if (price.toString().length > 10) {
return Number(price).toExponential(len);
const s = new BigNumber(price).precision(4).toFormat();
const ss = s.replace(/^0.(0*)?(?:.*)/u, (_l, z: string) => {
const zeroLength = z.length;

const sub = `${zeroLength}`
.split('')
.map(x => Sub_Numbers[x as any])
.join('');

const end = s.slice(zeroLength + 2);
return `0.0${sub}${end}`;
});

return ss;
}
return price.toString();
}
Expand Down

0 comments on commit 193cdba

Please sign in to comment.