You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Type Consistency The function bigNumberToNumber now handles inputs that are falsy by returning 0. However, the function signature does not explicitly state the possible types for bigNumber which can now include undefined or null due to the new check. It's recommended to update the function signature or documentation to reflect this change.
Ensure consistent number conversion methods are used for all account properties
Consider using a consistent method for converting account.total, account.free, and account.reserved to numbers. Currently, Number() is used directly in the calculation of otherNumber, while bigNumberToNumber() is used for transferable and staking. This inconsistency might lead to precision errors or bugs, especially with large numbers. A unified approach using bigNumberToNumber() for all conversions would ensure consistency and potentially avoid bugs related to number precision.
Why: The suggestion addresses a potential bug by ensuring consistent number conversion methods, which is crucial for maintaining precision and avoiding errors, especially with large numbers.
9
Enhancement
Improve type handling in bigNumberToNumber to ensure accurate string conversions
The bigNumberToNumber function should handle different types of inputs more robustly. The current implementation assumes that any non-string input can be directly converted to a string, which might not always be safe or accurate, especially for bigint and number types. Consider checking the type of bigNumber and handling each type appropriately to ensure accurate conversions.
Why: The suggestion enhances the robustness of the bigNumberToNumber function by handling different input types more accurately, which improves code reliability and correctness.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
Small big number bug fix on account details
PR Type
Bug fix
Description
AccountBalancePieChart
by ensuringotherNumber
is correctly passed tobigNumberToNumber
without converting it to a string.bigNumberToNumber
utility function to return 0 if the inputbigNumber
is falsy, preventing potential errors.Changes walkthrough 📝
AccountBalancePieChart.tsx
Fix conversion of `otherNumber` in AccountBalancePieChart
explorer/src/components/Consensus/Account/AccountBalancePieChart.tsx
otherNumber
to a string before passing tobigNumberToNumber
.number.ts
Add falsy check for `bigNumber` in utility function
explorer/src/utils/number.ts
bigNumber
is falsy inbigNumberToNumber
.