Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Add support for autoRefreshOnNetworkChange deprecation in Metamask #32

Open
SeanJCasey opened this issue Sep 24, 2019 · 2 comments
Open

Comments

@SeanJCasey
Copy link
Contributor

Screen Shot 2019-09-24 at 10 24 14 PM

Metamask is getting rid of the ethereum.autoRefreshOnNetworkChange property, and suggesting that dApps rely on the ethereum.on("networkChange", callback) listener instead.

https://metamask.github.io/metamask-docs/API_Reference/Ethereum_Provider#ethereum.autorefreshonnetworkchange

Being able to force a dApp to reload on network change can be useful when there is logic that relies on the current networkId. In Drizzle, there is also the problem that web3 contracts that are added ad hoc with addContract would be instantiated with only the current network address, and would fail to function on network change.

@cds-amal
Copy link
Member

Thanks for raising this @SeanJCasey.

Metamask is getting rid of the ethereum.autoRefreshOnNetworkChange property, and suggesting that dApps rely on the ethereum.on("networkChange", callback) listener instead.

https://metamask.github.io/metamask-docs/API_Reference/Ethereum_Provider#ethereum.autorefreshonnetworkchange

Yes, Drizzle will have to implement this listener.

Being able to force a dApp to reload on network change can be useful when there is logic that relies on the current networkId. In Drizzle, there is also the problem that web3 contracts that are added ad hoc with addContract would be instantiated with only the current network address, and would fail to function on network change.

These lines of code currently repair the contracts when a network change is detected. Though with the observable model Metamask proposes, we'll have to revisit.

@OnlyOneJMJQ
Copy link
Contributor

Thinking through this it seems like we need a middleware modification to track network changes and update contracts accordingly.

We may also want to consider a unified source of truth around contract info that marries contracts passed in via drizzleOptions with the contracts added via addContract.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants