Change StakeSubRow input value to use BigInt instead of rounded value#78
Change StakeSubRow input value to use BigInt instead of rounded value#78
Conversation
|
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/equilibriumco/vanilla-stake/BLQbWPFKxmjKB9GvQP1FXGK1EK4A |
| const [stakeAmount, setStakeAmount] = useState(staked?.juiceValue || ""); | ||
| const [stakeAmount, setStakeAmount] = useState( | ||
| staked?.rawJuiceValue | ||
| ? formatUnits(staked.rawJuiceValue, juiceDecimals) |
There was a problem hiding this comment.
Isn't this basically exactly the same as before?
There was a problem hiding this comment.
Oh, but staked.juiceValue truncates the value to 3 decimals?
There was a problem hiding this comment.
Yeah, basically juiceValue is also locale formatted (toLocaleString). Which adds commas/dots accordingly and rounds off to 3 digits.
utils/helpers.ts
Outdated
| return transactionLink; | ||
| } | ||
|
|
||
| export const limitJuiceAmount = (str: string) => { |
There was a problem hiding this comment.
Seems a bit hacky as it is, but seems to work. This said, there could be another feature that would remove spaces (Could be fixable by making the input a number type too btw <input type="number" />:
I tried copypasting my unstaked amount right into the stake box. It didn't work because of the spaces between numbers, so I had to manually remove them.
There was a problem hiding this comment.
Could be fixable by making the input a number type too btw
I believe that is already the case!
But yeah, we can remove spaces here, chrome does it automatically, but others are not that smart!
| disabled={stakePending} | ||
| autoFocus | ||
| size="lg" | ||
| type="number" |
There was a problem hiding this comment.
After banging my head for some time, turns out this was culprit. On non-chromiums if number input gets a non-number, it just gives empty string to target.value but sets the original string in element, so react state and input state would go out of sync. Didn't know if that was even possible :).
muzam1l
left a comment
There was a problem hiding this comment.
LGTM if we wanna show full raw value in input.

Refrences #77