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
Possible Bug The variable otherNumber is used but not defined or imported in this file. Ensure that otherNumber is properly declared and available in this scope.
Code Improvement The check for bigNumber being falsy should also handle cases where bigNumber might be an invalid number format. Consider adding more robust validation or error handling for different types of input.
Ensure bigNumberToNumber handles only expected types by adding a type check
Add a type check for bigNumber in the bigNumberToNumber function to ensure it handles only expected types (string, bigint, or number). This prevents potential runtime errors when unexpected types are passed.
-if (typeof bigNumber !== 'string') bigNumber = bigNumber.toString()+if (['string', 'bigint', 'number'].includes(typeof bigNumber)) {+ bigNumber = bigNumber.toString()+} else {+ throw new TypeError('bigNumberToNumber expects a string, bigint, or number');+}
Suggestion importance[1-10]: 9
Why: Adding a type check for bigNumber ensures that the function handles only expected types, preventing potential runtime errors and improving the reliability of the function. This is a significant improvement in terms of type safety.
9
Possible bug
Add a validation check for otherNumber to ensure it's a valid number before conversion
Consider checking if otherNumber is not only truthy but also a valid number before converting it using bigNumberToNumber. This ensures that the conversion function does not receive unexpected types or values.
-const other = otherNumber ? bigNumberToNumber(otherNumber) : 0+const other = typeof otherNumber === 'number' && !isNaN(otherNumber) ? bigNumberToNumber(otherNumber) : 0
Suggestion importance[1-10]: 8
Why: The suggestion adds a validation check to ensure otherNumber is a valid number before conversion, which can prevent potential runtime errors and improve code robustness.
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
Sync with prod to fix small account detaisl bug
PR Type
Bug fix
Description
AccountBalancePieChart
by correcting the conversion ofotherNumber
to a big number.bigNumberToNumber
function to return 0 if the inputbigNumber
is falsy, preventing potential errors.Changes walkthrough 📝
AccountBalancePieChart.tsx
Fix big number conversion in AccountBalancePieChart
explorer/src/components/Consensus/Account/AccountBalancePieChart.tsx
otherNumber
to a big number.number.ts
Add falsy check for bigNumber conversion
explorer/src/utils/number.ts
bigNumber
is falsy.