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

TypeError: Cannot read property 'stopWatching' of undefined #11

Open
wighawag opened this issue Mar 17, 2016 · 1 comment
Open

TypeError: Cannot read property 'stopWatching' of undefined #11

wighawag opened this issue Mar 17, 2016 · 1 comment

Comments

@wighawag
Copy link

Here is a nodejs script that i execute via node script.js

var Web3 = require('web3');
var web3 = new Web3(); 

var EtherSim = require('ethersim'); 
var sim = new EtherSim.init();
web3.setProvider(sim.provider);

//getting bytecode and ABI...

sim.reset();
sim.createAccounts(10, function() {
    sim.setBalance(web3.eth.accounts[0], 123450000, function() {
        web3.eth.getAccounts(function(err, accs) {
            var TestContract = web3.eth.contract(ABI);
            TestContract.new({
                from: web3.eth.accounts[0],
                gas : 3000000,
                data: bytecode
            }, function(err, deployedContract){
                console.log(deployedContract);
                //sim.mine() //should be required to get address?
                var transactionReceipt = web3.eth.getTransactionReceipt(deployedContract.transactionHash);

                console.log(transactionReceipt.contractAddress);
                //sim.reset(); never ends
            });
        });
    }); 
});

I get the following error :

/vagrant/node_modules/web3/lib/web3/contract.js:128
                            filter.stopWatching();
                                  ^

TypeError: Cannot read property 'stopWatching' of undefined
    at Object.callback (/vagrant/node_modules/web3/lib/web3/contract.js:128:35)
    at /vagrant/node_modules/web3/lib/web3/method.js:142:25
    at /vagrant/node_modules/web3/lib/web3/requestmanager.js:89:9
    at /vagrant/node_modules/ethersim/lib/manager.js:60:7
    at Manager.eth_getCode (/vagrant/node_modules/ethersim/lib/manager.js:110:10)
    at Manager.request (/vagrant/node_modules/ethersim/lib/manager.js:64:19)
    at TestProvider.sendAsync (/vagrant/node_modules/ethersim/lib/provider.js:11:23)
    at RequestManager.sendAsync (/vagrant/node_modules/web3/lib/web3/requestmanager.js:80:19)
    at Eth.send [as getCode] (/vagrant/node_modules/web3/lib/web3/method.js:141:42)
    at Object.callback (/vagrant/node_modules/web3/lib/web3/contract.js:122:39)

if I uncomment the last sim.reset() node hang

any idea?

@wighawag
Copy link
Author

Looking at the code it seems a bit wierd that the callback given to Contract creation can be called multiple times (this is web3).
But the problem is not really that. The problem is that after the callback is performed there is this function:
checkForContractAddress
that expect contract._eth.filter to be defined (as a function) but it is undefined

This function is in web3 but maybe ethersim should make sure such filter function is defined?

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

No branches or pull requests

1 participant