Skip to content
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

feat(suite-native): send form normal fee level validation #14348

Merged
merged 1 commit into from
Sep 19, 2024

Conversation

PeKne
Copy link
Contributor

@PeKne PeKne commented Sep 16, 2024

Description

  • normal fee level is now part of send form validation schema
  • If user selects an send amount X, where (X + normal fee) > available balance form shows error and user can not continue until he lowers the amount

Related Issue

Resolve #13782

Screenshots:

@PeKne PeKne added the mobile Suite Lite issues and PRs label Sep 16, 2024
@PeKne PeKne requested a review from a team as a code owner September 16, 2024 06:26
precomposedFeeLevels,
} = context;

// transaction amount + normal fee has to be lower than account balance
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this comment relevant to the following line? 🤔 It's not obvious at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better comment added in 5189ad1

Comment on lines +46 to +53
const DEFAULT_VALUES = [
{
amount: '',
address: '',
fiat: '',
},
] as const satisfies SendOutputsFormValues['outputs'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

useEffect(() => {
if (watchedFormValues && isValid) debounce(storeFormDraftIfValid);
}, [isValid, storeFormDraftIfValid, watchedFormValues, debounce]);
if (!account) return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to move this at the very beginning of the callback block and change like this?

Suggested change
if (!account) return;
if (!account || !networkFeeInfo) return;

@PeKne PeKne force-pushed the fix/native/normal-fee-send-form-validation branch from 5189ad1 to 0adad27 Compare September 17, 2024 11:50
@PeKne
Copy link
Contributor Author

PeKne commented Sep 17, 2024

@yanascz In the end, the solution utilizes the calculation of send max with the normal fee level, as you suggested. So the normal fee send max amount is calculated right away when the user enters the send form screen and recalculated if the address is changed. Like this, we have a numeric value to compare with the amount, and we don't have to recalculate fees on every change. The solution of calculating send max was inspired by desktop implementation. Hit me up in Slack if you need to clarify anything.

The original Commits were squashed and force-pushed because the new solution conflicted with the original one. Please do the full review again 🙏.

@PeKne PeKne force-pushed the fix/native/normal-fee-send-form-validation branch from 0adad27 to b96ce1d Compare September 17, 2024 11:59
@matejkriz matejkriz self-assigned this Sep 18, 2024
Copy link
Member

@matejkriz matejkriz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 It was hard for me to understand, but after a huddle consultation it makes sense to me now.

@PeKne PeKne merged commit 56a7150 into develop Sep 19, 2024
14 checks passed
@PeKne PeKne deleted the fix/native/normal-fee-send-form-validation branch September 19, 2024 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mobile Suite Lite issues and PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Send coins - fee level unsuficient balance
3 participants