-
Notifications
You must be signed in to change notification settings - Fork 363
Avoid constant creation of new web3 object #1171
Conversation
ESLint Summary View Full Report
[warning] @typescript-eslint/explicit-module-boundary-types
Report generated by eslint-plus-action |
Travis automatic deployment: |
src/logic/wallets/getWeb3.ts
Outdated
@@ -99,7 +99,6 @@ export const getProviderInfo = async ( | |||
web3Provider: string | Provider, | |||
providerName = 'Wallet', | |||
): Promise<ProviderProps> => { | |||
web3 = new Web3(web3Provider) | |||
const account = await getAccountFrom(web3) |
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.
would it be possible to make it use passed web3 instead of using a global module variable?
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, if it's more explicit it's not a problem. Anyway we are always using a getter to get that web3 instance (from the same file)
Travis automatic deployment: |
Travis automatic deployment: |
Travis automatic deployment: |
Travis automatic deployment: |
Travis automatic deployment: |
Sorry for not saying this earlier: So it was implemented this way because of some weird behaviour in onboard.js when switching providers, I don't remember what exactly it was. The thing that if user changes a provider we need to use it to reinitialise the contracts and stuff. But now it looks like |
Currently we are creating a new web3 object each 3 seconds.
When we query for network info it's enough to check with current web3 instance. Web3 update logic should be handled elsewhere.