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

JSONRPCProvider breaks if network is "any" #1484

Closed
dmihal opened this issue Apr 19, 2021 · 3 comments
Closed

JSONRPCProvider breaks if network is "any" #1484

dmihal opened this issue Apr 19, 2021 · 3 comments
Labels
bug Verified to be an issue. fixed/complete This Bug is fixed or Enhancement is complete and published.

Comments

@dmihal
Copy link

dmihal commented Apr 19, 2021

I believe #1371 has introduced a bug regarding using Web3Provider with "any" network.

If a provider is constructed:

const library = new Web3Provider(provider, 'any')

Then the BaseProvider will query the network inside the constructor.

// If network is any, this Provider allows the underlying
// network to change dynamically, and we auto-detect the
// current network
defineReadOnly(this, "anyNetwork", (network === "any"));
if (this.anyNetwork) { network = this.detectNetwork(); }

However, this will fail, because the JSONRPCSigner doesn't set _eventLoopCache until after super()

super(networkOrReady);
this._eventLoopCache = { };

And the following error is thrown:

Uncaught TypeError: Cannot read property 'detectNetwork' of undefined
    at Web3Provider.detectNetwork (json-rpc-provider.ts:331)
    at new BaseProvider (base-provider.ts:487)
    at new JsonRpcProvider (json-rpc-provider.ts:308)
    at new Web3Provider (web3-provider.ts:119)
@dmihal dmihal added the investigate Under investigation and may be a bug. label Apr 19, 2021
@ricmoo ricmoo added on-deck This Enhancement or Bug is currently being worked on. bug Verified to be an issue. and removed investigate Under investigation and may be a bug. labels Apr 20, 2021
@ricmoo
Copy link
Member

ricmoo commented Apr 20, 2021

I've confirmed and reproduced this, and will get to it ASAP.

Thanks! :)

@ricmoo
Copy link
Member

ricmoo commented Apr 20, 2021

This has been addressed in 5.1.3. Can you try it out and let me know?

Thanks! :)

@ricmoo ricmoo added fixed/complete This Bug is fixed or Enhancement is complete and published. and removed on-deck This Enhancement or Bug is currently being worked on. labels Apr 20, 2021
@dmihal
Copy link
Author

dmihal commented Apr 23, 2021

5.1.3 seems to be working for me, thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified to be an issue. fixed/complete This Bug is fixed or Enhancement is complete and published.
Projects
None yet
Development

No branches or pull requests

2 participants