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 hidden or 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
Sometimes, when approving a token, the spending cap displayed in the transaction simulation component flickers for a split second. This can also seen when editing the spending cap on the same screen.
In the approve screen, useAssetDetails returns decimals at first as undefined while it's determined asynchronously. Since useApproveTokenSimulation takes decimals as an argument, a default of '0' was set to quiet the type-checker. This default is what provokes the UI flicker.
In the example video below, the token has 4 decimals and the spending cap is 70000 / 10 ** 4 = 7. But while decimals is still undefined, '0' is used in useApproveTokenSimulation to determine the spending cap (dividing the value by 10 to the number of decimals). This amounts to 70000 instead of 7 for a split second, before decimals '4' is returned by useAssetDetails.
The fix for this bug is to let the loading spinner linger a few miliseconds longer while decimals is still undefined.
I've completed the PR template to the best of my ability
I’ve included tests if applicable
I’ve documented my code using JSDoc format if applicable
I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
Pre-merge reviewer checklist
I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
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.
Description
Sometimes, when approving a token, the spending cap displayed in the transaction simulation component flickers for a split second. This can also seen when editing the spending cap on the same screen.
In the approve screen,
useAssetDetails
returnsdecimals
at first asundefined
while it's determined asynchronously. SinceuseApproveTokenSimulation
takesdecimals
as an argument, a default of'0'
was set to quiet the type-checker. This default is what provokes the UI flicker.In the example video below, the token has 4 decimals and the spending cap is 70000 / 10 ** 4 = 7. But while decimals is still
undefined
,'0'
is used inuseApproveTokenSimulation
to determine the spending cap (dividing the value by 10 to the number of decimals). This amounts to70000
instead of7
for a split second, before decimals'4'
is returned byuseAssetDetails
.The fix for this bug is to let the loading spinner linger a few miliseconds longer while decimals is still
undefined
.Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
before.the.bug.happens.mov
After
after.mov
Pre-merge author checklist
Pre-merge reviewer checklist