-
Notifications
You must be signed in to change notification settings - Fork 16
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
fix(minifront): #1598: display non-native-fee-warning per account #1614
Conversation
|
That can be confusing for users because not every asset can be an alt fee asset |
@Valentine1898 do I get it right that, if user has TestUSD (non-alt token) and, let's say, AltUSD (some alt token), and the source token is TestUSD, the fees will still be paid in AltUSD, if the amount is enough to cover the fees? |
Yes, that's right |
@Valentine1898 @TalDerei I implemented the checks for alt token balances before showing the NonNativeFeeWarning, mainly copied the logic from Right now, |
to simulate gas prices, add this code block inside the block processor and resync, then check updated
|
@VanishMax |
Please rebase on main, I'll review later today |
@Valentine1898 Updated demo where I added TestUSD to the alt tokens in IndexedDB and showing 3 cases:
Kapture.2024-08-02.at.15.24.54.mp4 |
these seem like the proper expected cases to me 👍 |
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.
); | ||
}; | ||
|
||
export const useShouldRender = (balancesResponses: BalancesResponse[] = [], amount: number) => { | ||
// Finds the alt tokens in the user's account balances that can be used for fees | ||
const hasAltToken = ( |
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.
can we combine hasStakingToken
and hasAltToken
into hasTokenBalance?
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.
refactored the code now + removed useShouldRender
since there's no need in it after creating hasTokenBalance
return false; | ||
} | ||
|
||
const sourceAddressIndex = getAddressIndex.optional()(account)?.account ?? 0; |
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.
why do we have a default value for source here?
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.
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.
no need, just removed it
* required. | ||
* Renders a non-native fee warning if | ||
* 1. the user does not have any balance (in the selected account) of the staking token to use for fees | ||
* 2. user has alt token balances to pay for the fees |
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.
"The user does not have sufficient balances in alternative tokens to cover the fees."
Closes #1598
Checks if user has UM token in the same account as the selected source token
Kapture.2024-08-01.at.14.24.00.mp4