-
Notifications
You must be signed in to change notification settings - Fork 31
Fix send token screen should be unaccessible if native token of current application has no balance on account #2136
Conversation
if (!accountCanSendTokensData) { | ||
modal.open(() => ( | ||
<TransactionError | ||
actionButton={ | ||
<PrimaryButton | ||
key="retry" | ||
onClick={() => { | ||
navigation.navigate('Request'); | ||
modal.close(); | ||
}} | ||
title={`${i18next.t('Request')} ${tokenName.toUpperCase()}`} | ||
style={[styles.tryAgainButton]} | ||
/> | ||
} | ||
description={i18next.t('transactions.errors.insufficientFeeDescription', { | ||
message: tokenName.toUpperCase(), | ||
})} | ||
title={i18next.t('transactions.errors.insufficientFee', { | ||
message: tokenName.toUpperCase(), | ||
})} | ||
hideReport | ||
hideIcon | ||
/> | ||
)); |
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.
accountCanSendTokensData
is missing the part of validating that the user has sufficient feeToken available.
Reason is because a user can have other fees apart from the native token(fee token) of that chain but because accountCanSendTokensData
only checks that the user at least has a fee token the above conditional would not cover that case scenario.
To achieve this, useAccountCanSendTokens
can also call the fees endpoint to get the feeTokenId of the chain then with the feeTokenId available, you can then check if the user has the token in their list of token balance meaning useAccountCanSendTokens can also return another value called hasFeeTokenBalance
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.
LGTM
What was the problem?
This PR resolves #2135
How was it solved?
How was it tested?