-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Web3 1.0 instances seem to share state (provider overwritten) #1188
Comments
Note that this issue is blocking The addition of websockets and IPC to Ganache and ganache-cli (formerly TestRPC). |
Looks like it's failing on |
Contract.setProvider = function(provider, accounts) {
// Contract.currentProvider = provider;
core.packageInit(Contract, [provider]);
Contract._ethAccounts = accounts;
}; The signature of |
From what I can tell, I think the design is over-constrained. It seems that you want to be able to do something like: var web3 = new Web3();
web3.setProvider(...);
// compilation steps and/or fetching of ABI go here
var myContract = new web3.eth.Contract(...); And I'd assume that adding I had some fun with |
Yeah, that's not a reliable fix. For some reason it makes the tests pass on this computer, but imported modules are supposed to be cached. The fact that my tests pass makes me feel like I'm relying upon version-specific or undefined behaviour, and I'd rather not rely on it -- so this still blocks me. |
@frozeman I asked around and was told that you'd be the person to ping about this issue. I'm happy to submit a PR w/ the fix, but I don't want to guess too much at what strategy you'd prefer I take. Feel free to ping me on gitter or the Consensys slack if you'd like to discuss. Happy to set up a face-to-face via Zoom as well. |
Shared state was not planned, and I had quite some pains make the contract object inherit the provider. If you can. One up with a fix I’m happy to hear. You can contact me in Gitter and we can have a skype chat on Thursday |
npm ERR! code ELIFECYCLE npm ERR! A complete log of this run can be found in: |
Observed this issue on 1.0-beta.26 - haven't tested other versions.
When I create an instance of web3, use it for a bit, then create a second instance with a different provider, the first instance's provider is overwritten.
I've modified
test/setProvider.js
to demonstrate the issue. These changes are given below as a diff taken against c4c92c3.The text was updated successfully, but these errors were encountered: