Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small big number bug fix on account details #846

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const AccountBalancePieChart: FC<Props> = ({ account }) => {
: 0
const transferable = account ? bigNumberToNumber(account.free) : 0
const staking = account ? bigNumberToNumber(account.reserved) : 0
const other = otherNumber ? bigNumberToNumber(otherNumber.toString()) : 0
const other = otherNumber ? bigNumberToNumber(otherNumber) : 0

const data = [
{
Expand Down
1 change: 1 addition & 0 deletions explorer/src/utils/number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const floatToStringWithDecimals = (value: number, decimals = 4): string =
BigInt(value * 10 ** decimals).toString()

export const bigNumberToNumber = (bigNumber: string | bigint | number, precision = 4): number => {
if (!bigNumber) return 0
if (typeof bigNumber !== 'string') bigNumber = bigNumber.toString()

const number = formatUnits(bigNumber)
Expand Down
Loading