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

Uncaught TypeError: Cannot read property '0' of undefined #6

Open
Simoneth opened this issue Jun 27, 2017 · 12 comments
Open

Uncaught TypeError: Cannot read property '0' of undefined #6

Simoneth opened this issue Jun 27, 2017 · 12 comments

Comments

@Simoneth
Copy link

Issue Type

Uncaught TypeError: Cannot read property '0' of undefined
    at http://localhost:8080/app.js:29773:34
    at Array.map (native)
    at Object.decodeEvent (http://localhost:8080/app.js:29772:6)
    at http://localhost:8080/app.js:33803:38
    at Array.map (native)
    at Object.decodeLogs (http://localhost:8080/app.js:33774:19)
    at Object.callback (http://localhost:8080/app.js:33896:35)
    at http://localhost:8080/app.js:6974:25
    at http://localhost:8080/app.js:37588:9
    at chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/scripts/inpage.js:168:7

Description

On a private-network on port 8545 using testrpc and MetaMask when I send coins to another account I get this error

error

Steps to reproduce

On Windows
Prompt1
truffle.cmd init webpack

Prompt2
testrpc

Prompt1
truffle.cmd compile
truffle.cmd migrate
npm run dev

Go to localhost:8080

Versions

  • Node/NPM: Node 8.0 npm 5.0.3
  • Browser: Chrome
@SilentCicero
Copy link
Member

SilentCicero commented Jun 27, 2017

What version of Truffle are you using, can you post anything about how you are using this method?

It's most likely caused by Truffle using decodeEvent with some inputs your feeding it. So it could just be your inputs, or something internally with Truffle, potentially due to a recent update (v3.3 Lemon) I doubt its ethjs-abi however, as we have not changed much in the past while. I'll ping tim. @tcoulter any thoughts?

@tomw1808
Copy link

I am getting the same error, with the truffle-init-webpack project.

Here's the steps I have taken on a clean environment:

npm install -g truffle@beta
npm install -g ethereumjs-testrpc@beta
truffle init webpack
... compile and start testrpc ...
npm run dev

open in chrome inkl Metamask
connect meta-mask to localhost
import one account from testrpc to metamask
transfer a MetaCoin to another account.

Same happens on Firefox without MetaMask in the middle.

I also think it is not really related to ethjs-abi, because as far as I can tell the function where it fails (decodeEvent(...)) has not changed since version 0.0.1. Haven't had the chance to dig deeper yet, any pointers would be helpful though.

Thanks,
Thomas

@Simoneth
Copy link
Author

What version of Truffle are you using, can you post anything about how you are using this method?

I'm using the exact same method as @tomw1808 with Truffle beta.

@anuragverma639
Copy link

I am also getting the same error, with truffle init webpack project.

@Ericxgao
Copy link

I am also getting the same issue with the steps above. This has to do with whether or not I define an event parameter as indexed (removing it fixes the issue).

@SilentCicero
Copy link
Member

SilentCicero commented Jul 13, 2017 via email

@tcoulter
Copy link

I haven't been able to reproduce the issue with the steps provided.

@tomw1808 You gave these steps:

npm install -g truffle@beta
npm install -g ethereumjs-testrpc@beta
truffle init webpack
... compile and start testrpc ...
npm run dev

You didn't list migrating (i.e., deploying) your contracts. Did you perform that step before continuing?

Can you tell me what operating system you guys are using? So far it looks like Windows.

@francescovalentino
Copy link

@tcoulter

Yes, Windows 8.1 64-bit

@tcoulter
Copy link

I've successfully reproduced, but only on Windows. Diagnosing.

@tcoulter
Copy link

I've found the culprit, though I don't understand it.

TL;DR: npm is installing the wrong version of ethjs-abi.

Background:

If you look here, truffle-init-webpack is asking for a version of truffle-contract that's v1.1.6 or above, in which case npm should choose the latest version, which is v1.1.11. Version v1.1.11 fixes the issue above by pinning the expected version of ethjs-abi; however, on Windows, npm choose v1.1.6 of truffle-contract instead of v1.1.11, which installs the incorrect version of ethjs-abi. I don't know why the behavior of npm on Windows and Mac is different, but of course this is software, so c'est la vie.

Solution

I'll bump a version of truffle-init-webpack momentarily that fixes this issue.

Obligatory aside: Note that we're moving away from truffle-init-webpack in favor of Truffle Boxes, which offer a better experience and more options (and a larger set of boxes once we can get new ones rolled out). You should check them out if you haven't already!

@tcoulter
Copy link

This has been fixed. You should now be able to perform the following on Windows with no issue:

truffle init webpack
truffle compile
truffle migrate
npm run dev

You'll be able to use the example application as expected.

Cheers! @SilentCicero, you can close this issue.

@tomw1808
Copy link

Hey @tcoulter sorry the late reply and thanks for fixing it.

OT question: Moving away from truffle-init-webpack and into the truffle boxes is understandable. They are great. But will there be a box that starts with vanilla JS and just implements a basic build environment for javascript? Webpack was pretty convenient to have just that without the hassle of scaffolding for a quick vanilla js Dapp-project for prototyping. Any recommendations on that side?

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

7 participants