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

1.0.0-beta.46 send transaction, when confirmed throw exception: TypeError: Cannot read property 'anonymous' of undefined #2365

Closed
BigMurry opened this issue Feb 10, 2019 · 9 comments · Fixed by #2392
Labels
Bug Addressing a bug

Comments

@BigMurry
Copy link

Expected behavior

send transaction should work fine.

Actual behavior

Uncaught (in promise) TypeError: Cannot read property 'anonymous' of undefined
    at AllEventsLogDecoder.decode (web3-eth-contract.umd.js:232)
    at AllEventsLogDecoder.decode (web3-eth-contract.umd.js:263)
    at web3-eth-contract.umd.js:627
    at Array.forEach (<anonymous>)
    at SendContractMethod.afterExecution (web3-eth-contract.umd.js:626)
    at TransactionConfirmationWorkflow.handleSuccessState (web3-core-method.umd.js:103)
    at web3-core-method.umd.js:57

Steps to reproduce the behavior

const Web3 = require('web3');
const abi = [...];
const addr = '0x....';
const web3 = new Web3(window.web3.currentProvider);
const contractInstance = new web3.eth.Contract(abi, addr);
const methodArgs = [...];
contractInstance.methods.myMethod(...methodArgs).send({from, value}, (err, txHash) => {
  console.log(txHash);
});

when transaction is confirmed on the blockchain, exception occurred.

Error Logs

Uncaught (in promise) TypeError: Cannot read property 'anonymous' of undefined
    at AllEventsLogDecoder.decode (web3-eth-contract.umd.js:232)
    at AllEventsLogDecoder.decode (web3-eth-contract.umd.js:263)
    at web3-eth-contract.umd.js:627
    at Array.forEach (<anonymous>)
    at SendContractMethod.afterExecution (web3-eth-contract.umd.js:626)
    at TransactionConfirmationWorkflow.handleSuccessState (web3-core-method.umd.js:103)
    at web3-core-method.umd.js:57

code snapshot:

wechatimg168

Versions

Web3.js - 1.0.0-beta.46
Nodejs - v10.14.0
NPM - v6.4.1

@nivida
Copy link
Contributor

nivida commented Feb 10, 2019

Tested it with:

var Web3 = require('../../web3.js/packages/web3/dist/web3.umd.js');
var abi = require('../tokenContractAbi');
var web3 = new Web3(window.web3.currentProvider);

console.log('Version: ', web3.version);

var contract = new web3.eth.Contract(abi, '0x0ff095b6b4d215d91b4c1d7fce025a9d72afff22');

contract.methods.transfer('0x24BBE93E1D5b43233D921C9c73E15e8576bD7Be1', 1000)
  .send({from: '0x9CC9a2c777605Af16872E0997b3Aeb91d96D5D8c'})
  .then(function (receipt) {
    console.log(receipt);
  }).catch(function (error) {
    console.log(error);
  });

and got the following response:
screenshot 2019-02-10 at 12 05 51

Could you reference a gist file or repository here with the contract and your code example?

@BigMurry
Copy link
Author

BigMurry commented Feb 12, 2019

@nivida
when I create the contractInstance, some events' abi is missing from the contractAbi, cause the events came from the other contract.

const contractAbi = [...];
const addr = '0x....';
const contractInstance = new web3.eth.Contract(contractAbi, addr);

Then when transaction is confirmed, it will trigger these methods:

TransactionConfirmationWorkflow -> handleSuccessState -> method.afterExecution -> allEventsLogDecoder.decode

But some events' abi can not found, so that the abiItemModel will be undefined.

I think I found the guilty lines:
https://github.com/ethereum/web3.js/blob/35ebbcacbecc75a6cac033fc648d0091e0235a83/packages/web3-eth-contract/src/decoders/AllEventsLogDecoder.js#L45-L47

if the abiModel.getEventBySignature returns undefined, then in the EventLogDecoder.decode method, abiItemModel will be undefined, then line 46 will throw exception.

https://github.com/ethereum/web3.js/blob/35ebbcacbecc75a6cac033fc648d0091e0235a83/packages/web3-eth-contract/src/decoders/EventLogDecoder.js#L43-L48

So in your test, you should make a transaction that can emit an event from other contract.

@kim-keepcoding
Copy link

Yeah. I'm got this problem as well. Probably something to do with Escrow contract.

@gudcjfdldu
Copy link

I have a similar problem. Is there a way to solve this problem?

@gudcjfdldu
Copy link

Yeah. I'm got this problem as well. Probably something to do with Escrow contract.

Do you know what to do with escrow contract? Did you solve this problem?

@BigMurry
Copy link
Author

@gudcjfdldu This is a web3 bug, if your transaction will trigger another contract event, web3 will trigger this bug.

I've downgraded to 1.0.0-beta.36.

@gudcjfdldu
Copy link

gudcjfdldu commented Feb 18, 2019

@BigMurry i think Version 1.0.0-beta.37 seems to be the most stable.
Currently, web3 works fine in this version.

@nivida
Copy link
Contributor

nivida commented Feb 18, 2019

Thanks all for the additional information. I will fix and release this asap!

@nivida nivida added Bug Addressing a bug and removed more information needed labels Feb 18, 2019
@kagawagao
Copy link
Contributor

can release a new version for this bug fix? @nivida

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

Successfully merging a pull request may close this issue.

5 participants