-
Notifications
You must be signed in to change notification settings - Fork 396
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
enhance swap quote functionality with error handling and auto refresh #3803
base: main
Are you sure you want to change the base?
Conversation
Ernesto-tha-great
commented
Mar 13, 2025
•
edited
Loading
edited
- Debounce time for updating the swap quote was reduced from 500ms to 300ms.
- Added an error field in the QuoteUpdate type to store error messages.
- Introduced a retry system to handle network failures and transient errors.
- Ensures the user always sees the latest price without manually refreshing.
- Improved readability and maintainability by restructuring the fetchQuote logic
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.
Left some notes! Thanks for contributing these changes!
I have taken the feedback into account and refactored the PR. Does this look better? |
The updated PR still does auto-refreshes but they're also being done on the frontend side, am I reading this right? Probably should stick to one or the other. |
Per Shadowfiend's PR tahowallet#3803 feedback, removed duplicate 10s useInterval (Swap.tsx) and 30s useEffect (useSwapQuote) to rely on backend fetchSwapPrice updates. Dropped unused amountInputHasFocus, fixed TS/ESLint errors (TS6133, TS1005, etc.), and kept PR tahowallet#3803 enhancements (300ms debounce, retries). Tested locally; assumes backend auto-refresh.
Please take a look once more. I have removed the refresh on the FE |
ui/pages/Swap.tsx
Outdated
@@ -466,12 +416,9 @@ export default function Swap(): ReactElement { | |||
priceImpact={quote?.priceDetails?.priceImpact} | |||
isPriceDetailsLoading={isLoadingPriceDetails} | |||
showPriceDetails | |||
// FIXME: Merge master asset list with account balances. |
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.
Is this no longer relevant?
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.
yes. its been fixed
ui/pages/Swap.tsx
Outdated
@@ -357,8 +313,6 @@ export default function Swap(): ReactElement { | |||
sellAsset, | |||
buyAsset, | |||
gasPrice: | |||
// Let's use the gas price from 0x API for Optimism | |||
// to avoid problems with gas price on Optimism Bedrock. |
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.
This feels relevant still.
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.
ill add it back in.
5b7ec01
to
6590482
Compare
6590482
to
a58243f
Compare
All done now. |
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.
This doesn't seem to be auto refreshing quotes anymore?
yes. we removed the auto refresh from the frontend so its being handled on the backend. |
Okay I see that the front end code for auto refresh was removed but I don't see anything in the backend handling that? |
71ea8e6
to
52a3eec
Compare
a1e1bd8
to
9736b34
Compare
@hyphenized @Shadowfiend |
@hyphenized @Shadowfiend bumping this up |