Closed DouglasHorn closed 9 months ago
The problem here is the so-called max available which is a completely incorrect number (it is 28 and it should be 28800). It gets truncated by the comma.
This is the line that is creating this error (in master branch): https://github.com/telosnetwork/open-block-explorer/blob/master/src/utils/string-utils.ts#L72
export function assetToAmount(asset: string): number {
try {
const qty: string = asset.split(' ')[0];
return parseFloat(qty); // << here is the bug line ("12,345.6789" -> 12)
} catch (error) {
return 0;
}
}
Which is already fixed here (in develop branch): https://github.com/telosnetwork/open-block-explorer/blob/develop/src/utils/string-utils.ts#L72C67-L72C67
export function assetToAmount(asset: string): number {
try {
const qty: string = asset.split(' ')[0];
return parseFloat(qty.replace(/,/g, '')); // remove commas
} catch (error) {
return 0;
}
}
Resolved
Describe the bug A known issue is that OBE is incorrectly calculating the matured REX balance by roughly 99.9% at one place on the page (but not the other). Input sanitation prevents the user from using the interface to unstake. Disabling input sanitation will allow users to unstake.
To Reproduce The display bug is described in https://github.com/telosnetwork/open-block-explorer/issues/685
Login to OBE at explorer.telos.net/account/ with an account that has a matured REX balance > 0 TLOS.
Go to the Unstake Page
The Matured Balance is shown correctly at the top of the page but lower on the same page, directly above the input box, the amount shown is incorrect.
If a value <= the actual matured balance is input the page flags it as an "invalid amount" and prevents the Unstake TLOS button from being unstaked. (UI note: the red lettering on a dark purple background is practically unreadable.)
Screenshots
Proposed Solution The best solution would be to correct the calculated amount of matured REX shown per Issue 685, but that has not been done.
The fastest solution would simply be to remove the error handling on the Unstake button to allow invalid amounts to be attempted. While this risks users getting an error message if they try to unstake an amount greater than their matured balance, that is preferable to not being able to unstake the balance.