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

CP-9831: better error message handling for swap #2214

Merged
merged 9 commits into from
Jan 31, 2025
Merged

CP-9831: better error message handling for swap #2214

merged 9 commits into from
Jan 31, 2025

Conversation

atn4z7
Copy link
Collaborator

@atn4z7 atn4z7 commented Jan 31, 2025

Description

Ticket: CP-9831

  • when swapping:

    • show actual errors instead of the standard Swap failed! Please try again. message:
      • cannot build tx
      • cannot fetch allowance
      • cannot fetch spender
      • missing param
      • network not supported
      • swap tx failed
      • approval tx failed
    • log error (original error included) to sentry
  • when fetching rates:

    • display error message from paraswap
    • log error (original error included) to sentry
  • other changes:

    • use typed contract interface (ERC20__factory)

Screenshots/Videos

cannotBuildTx

cannotFetchAllowance

cannotFetchSpender

missingParam

networkNotSupported

swapTxFailed

approvalTxFailed

get rate error

Testing

Please make sure swapping is working normally and error message is displayed accordingly

Checklist

Please check all that apply (if applicable)

  • I have performed a self-review of my code
  • I have verified the code works
  • I have added/updated necessary unit tests
  • I have updated the documentation

@atn4z7 atn4z7 changed the title CP-9831: better error message logging for swap CP-9831: better error message handling for swap Jan 31, 2025
if (approveError) {
throw approveError
if (!approvalTxHash || approvalTxError) {
throw swapError.approvalTxFailed(approvalTxError)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think there can be a case where there is no error but tx hash will be empty. the approvalTxFailed() does accept null /undefined error.

Copy link
Contributor

@ruijialin-avalabs ruijialin-avalabs left a comment

Choose a reason for hiding this comment

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

🔥

@atn4z7 atn4z7 merged commit ac12ea1 into main Jan 31, 2025
4 checks passed
@atn4z7 atn4z7 deleted the improve-swap branch January 31, 2025 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants