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

fix: Handle timeout error in safe creation #1293

Merged
merged 3 commits into from
Dec 5, 2022
Merged

Conversation

usame-algan
Copy link
Member

What it solves

Resolves #1291

How this PR fixes it

  • Timeout errors thrown by ethers do not contain a receipt so we should handle it as an optional type

Other changes

  • Removes receipt from TxEvent.PROCESSED and TxEvent.REVERTED as it was not used

How to test it

  1. Create a new safe
  2. Set the gas fee too low in your wallet and submit
  3. Wait for 6.5 minutes OR reload the page and wait for 6.5 minutes
  4. Observe a timeout error
  5. Observe that the Cancel and Retry button is visible

Screenshots

Screenshot 2022-11-30 at 18 19 13

@github-actions
Copy link

github-actions bot commented Nov 30, 2022

Branch preview

✅ Deploy successful!

https://fix-safe-creation-error--webcore.review-web-core.5afe.dev

@@ -11,7 +11,7 @@ import ContractErrorCodes from '@/services/contracts/ContractErrorCodes'
import { sameAddress } from '@/utils/addresses'

const isContractError = <T extends EthersError>(error: T): error is T & { reason: keyof typeof ContractErrorCodes } => {
return Object.keys(ContractErrorCodes).includes(error.reason)
return Object.keys(ContractErrorCodes).includes(error.reason!)
Copy link
Member Author

@usame-algan usame-algan Nov 30, 2022

Choose a reason for hiding this comment

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

I didn't bother with this as it will be removed with #1285 Actually not so we should handle it better.

Copy link
Member

Choose a reason for hiding this comment

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

I would suggest something along the lines of:

  const isEthersError = <T extends Error | EthersError>(error: T): error is EthersError

Copy link
Member Author

Choose a reason for hiding this comment

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

Why does the function need to handle Error and EthersError if it is only used in one place? I think we should rework EthersError in general. Ethers v6 will add proper error types but for the time being I would suggest opting for a more simple solution e.g.

const isContractError = (error: EthersError) => {
  if (!error.reason) return false

  return Object.keys(ContractErrorCodes).includes(error.reason)
}

Copy link
Member

Choose a reason for hiding this comment

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

The reasoning behind the union was because a standard error could be caught. Let's keep your solution and adjust the type as suggested in the future.

@github-actions
Copy link

github-actions bot commented Nov 30, 2022

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

Copy link
Member

@iamacook iamacook left a comment

Choose a reason for hiding this comment

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

Appears to work well but there are failing tests.

@@ -11,7 +11,7 @@ import ContractErrorCodes from '@/services/contracts/ContractErrorCodes'
import { sameAddress } from '@/utils/addresses'

const isContractError = <T extends EthersError>(error: T): error is T & { reason: keyof typeof ContractErrorCodes } => {
return Object.keys(ContractErrorCodes).includes(error.reason)
return Object.keys(ContractErrorCodes).includes(error.reason!)
Copy link
Member

Choose a reason for hiding this comment

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

I would suggest something along the lines of:

  const isEthersError = <T extends Error | EthersError>(error: T): error is EthersError

@github-actions
Copy link

github-actions bot commented Dec 1, 2022

CLA Assistant Lite All Contributors have signed the CLA.

@francovenica
Copy link
Contributor

The error is there.
image

@usame-algan usame-algan merged commit 6162cfd into dev Dec 5, 2022
@usame-algan usame-algan deleted the fix-safe-creation-error branch December 5, 2022 22:06
@github-actions github-actions bot locked and limited conversation to collaborators Dec 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

There is no "Cancel", "retry" button when Code 800: Safe creation failed appears in console
3 participants