-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change StakeSubRow input value to use BigInt instead of rounded value #78
base: main
Are you sure you want to change the base?
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/equilibriumco/vanilla-stake/BLQbWPFKxmjKB9GvQP1FXGK1EK4A |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments :)
const [stakeAmount, setStakeAmount] = useState(staked?.juiceValue || ""); | ||
const [stakeAmount, setStakeAmount] = useState( | ||
staked?.rawJuiceValue | ||
? formatUnits(staked.rawJuiceValue, juiceDecimals) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this basically exactly the same as before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, but staked.juiceValue
truncates the value to 3 decimals?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, basically juiceValue
is also locale formatted (toLocaleString
). Which adds commas/dots accordingly and rounds off to 3 digits.
utils/helpers.ts
Outdated
@@ -36,4 +36,13 @@ export const getTransactionLink = (txHash: string) => { | |||
} | |||
const transactionLink = `${explorerUrl}/tx/${txHash}` | |||
return transactionLink; | |||
} | |||
|
|||
export const limitJuiceAmount = (str: string) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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!
@@ -232,10 +232,9 @@ const StakeSubRow: FC<SubRowProps> = ({ row, type = "make" }) => { | |||
disabled={stakePending} | |||
autoFocus | |||
size="lg" | |||
type="number" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 :).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM if we wanna show full raw value in input.
Refrences #77