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
{{ message }}
Repository navigation
Misleading variable name in TokenAmountField isAllowed validator #451
In TokenAmountField's isAllowed callback, the destructured variable inputDecimals actually holds the integer part of the value (everything before the decimal point), not the decimal part.
const[inputDecimals]=value.toString().split('.')
split('.') returns [integerPart, decimalPart], so index 0 is the integer portion. The subsequent check decimals >= inputDecimals?.length compares the token's allowed decimal places against the integer part's digit count, which does not validate what the name suggests.
Steps to reproduce
Open src/components/sharedComponents/TokenInput/index.tsx, lines 231-238
Read the isAllowed function in TokenAmountField
Expected vs actual behavior
Expected: Variable named inputDecimals should contain the decimal portion of the input value. Actual: It contains the integer portion (text before the dot).
Additional context
Discovered during code review of PR #450. This is pre-existing code, not introduced by that PR. The validation may still pass in practice because NumericFormat's decimalScale prop independently limits decimal input, but the logic and naming are misleading and could cause subtle bugs if the surrounding code changes.
Activity