refactor(suite): optimize how often fees are fetched in send form #15469
+36
−11
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.
!!! WORK IN PROGRESS !!! do not merge yet
This commit introduces a new approach to fetching fees.
Previous state:
Fees for every wallet account were fetched periodically after 10 blocks. This was problematic for various reasons:
New state:
This solution mainly builds on the idea that fees aren't connected to blocks. This link is now removed. There is a dedicated
useFees
hook that is supposed to be called for every route that needs to display fees. The hook is responsible for decision on how often the fee should be fetched (decided manually innetworkToInterval
function). That way all logic behind fee fetching is located in one file. Consequence of this decision is thatupdateFeeInfoThunk
is now "dumb" - it fetches new fees whenever it is called. While this solution is more verbose (useFees
has to be called everywhere fees are needed), I think its explicit relationship improves readability of the code.What needs to be done before this commit is mergeable:
networkToInterval
function.useFees
for every route that needs fees (swap, sell, etc.).useFees
hook to better location so that it can be used insuite-native/module-send/src/screens/SendOutputsScreen.tsx:174
, too.Relates to #15087