Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

1867 - Add network if nonexistent #2424

Merged
merged 2 commits into from
Feb 15, 2022
Merged

Conversation

W3stside
Copy link
Contributor

Closes #1867

Summary

Adds correct network adding logic when chain NOT in MM, fixes loop error and chain info object type (uni related)

Screenies

image

TESTING

  1. remove XDAI/Gnosis Chain from metamask
  2. from ETHEREUM, change to Gnosis Chain
  3. Should see what i screenshotted
  4. Should switch to chain
  5. Cancelling should not loop and log correctly

@W3stside W3stside requested review from a team February 15, 2022 14:17
@github-actions
Copy link
Contributor

CLA Assistant Lite All Contributors have signed the CLA.

@github-actions
Copy link
Contributor

  • 🔭 GP Swap: CoW Protocol v2 Swap UI

})
} catch (error) {
console.error('error adding eth network: ', chainId, info, error)
throw new Error(error?.message)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the only MOD, L34.
open to not using a new error object, just needs to be rethrown.

if (error.code === 4902 && chainId !== undefined) {
const info = CHAIN_INFO[chainId]

// MOD - need to handle these errors, else loops
Copy link
Contributor Author

Choose a reason for hiding this comment

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

L33 - 42 (try/catch) block is the MOD. Without proper error handling this loops

@elena-zh
Copy link

Hey @W3stside , great changes!
The only thing I noticed that it is impossible to cancel a request to add a network in Firefox.
I have added this issue as a comment to #1636 (comment) issue, as it is impossible to cancel change network request either there.

Copy link
Contributor

@alfetopito alfetopito left a comment

Choose a reason for hiding this comment

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

Woah pure magic!

Had no idea this was already there O.O

@W3stside
Copy link
Contributor Author

Woah pure magic!

Had no idea this was already there O.O

My post vacay energy helped me find it 👁️👁️👁️👁️👁️👁️👁️👁️👁️👁️👁️👁️👁️👁️👁️👁️👁️👁️👁️👁️👁️👁️👁️

@W3stside W3stside merged commit e28bfd3 into develop Feb 15, 2022
@W3stside W3stside deleted the add-network-if-not-existant branch February 15, 2022 23:11
@github-actions github-actions bot locked and limited conversation to collaborators Feb 15, 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.

Error when switch to xdai without adding it to MM
3 participants