Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Fix web3 instance after switching chain #2770

Merged
merged 3 commits into from
Sep 28, 2021

Conversation

dasanra
Copy link
Collaborator

@dasanra dasanra commented Sep 28, 2021

What it solves

Fixes the issue reported in this comment:
#2720 (comment)
It wasn't only related to the create safe step, but in many places we were using a readOnly instance of web3. Most of the cases didn't had issues because it was not used to do queries to the blockchain but just for the unit conversion or parsing. But in those cases where we launch a query to the blockchain it was still initialized with the default chain RPC, so wrong RPC query was send in other chains

How this PR fixes it

We create a new instance of web3ReadOnly for each network, but we cache them as singleton instance in order to avoid creating many new objects

How to test it

Try to create a safe in a chain different than the default one and check that is correctly detected. Also RPC calls can be check in network console, validating that they are done to the correct chain RPC

@dasanra dasanra requested a review from DaniSomoza September 28, 2021 09:28
@github-actions
Copy link

CLA Assistant Lite All Contributors have signed the CLA.

@github-actions
Copy link

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 6 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

@github-actions
Copy link

@github-actions
Copy link

@github-actions
Copy link

@github-actions
Copy link

E2E Tests Failed
Check the results here: https://github.com/gnosis/safe-react-e2e-tests/actions/runs/1281986143

Failed tests:

  • ❌ Add an existing safe Add an existing safe

Copy link
Contributor

@DaniSomoza DaniSomoza left a comment

Choose a reason for hiding this comment

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

Approved!

@dasanra dasanra merged commit b1be4f9 into l2-ux Sep 28, 2021
@dasanra dasanra deleted the feature/fix-web3-instance-after-changing-chain branch September 28, 2021 12:04
@github-actions github-actions bot locked and limited conversation to collaborators Sep 28, 2021
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.

2 participants