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

getPastEvents Error Empty outputs array given! #2582

Closed
patitonar opened this issue Mar 26, 2019 · 11 comments
Closed

getPastEvents Error Empty outputs array given! #2582

patitonar opened this issue Mar 26, 2019 · 11 comments
Labels
Bug Addressing a bug

Comments

@patitonar
Copy link

Description

I got this error when getting the events in the following code

await contract.getPastEvents('ValidatorAdded', {fromBlock: 0});

The abi of the event:

    {
      "anonymous": false,
      "inputs": [
        {
          "indexed": true,
          "name": "validator",
          "type": "address"
        }
      ],
      "name": "ValidatorAdded",
      "type": "event"
    }

Error Logs

Error: Empty outputs array given!
    at AbiCoder.decodeParameters (web3-eth-abi.umd.js:59)
    at AbiCoder.decodeLog (web3-eth-abi.umd.js:121)
    at EventLogDecoder.decode (web3-eth-contract.umd.js:228)
    at web3-eth-contract.umd.js:775
    at Array.map (<anonymous>)
    at PastEventLogsMethod.afterExecution (web3-eth-contract.umd.js:774)
    at PastEventLogsMethod._callee$ (web3-core-method.umd.js:99)
    at tryCatch (runtime.js:62)
    at Generator.invoke [as _invoke] (runtime.js:288)
    at Generator.prototype.(:3000/anonymous function) [as next] (http://localhost:3000/static/js/bundle.js:1382:21)
    at asyncGeneratorStep (asyncToGenerator.js:3)
    at _next (asyncToGenerator.js:25)

Versions

  • web3.js: 1.0.0-beta.50
@nivida
Copy link
Contributor

nivida commented Mar 26, 2019

Could you please add the complete example?

@patitonar
Copy link
Author

Created a simple example on this repo https://github.com/patitonar/test-web3-getPastEvents
On master branch using version 1.0.0-beta.50 is failing.
On working-example branch using version 1.0.0-beta.47 is working without errors.

@nivida nivida added Needs Clarification Requires additional input and removed more information needed labels Mar 26, 2019
@nivida
Copy link
Contributor

nivida commented Mar 26, 2019

Will test and if required fix it asap.

@dileepfrog
Copy link

Reproduced this same issue on 1.0.0-beta.50, working on 1.0.0-beta.39

@jamesmorgan
Copy link

jamesmorgan commented Mar 27, 2019

I have also just seen this when updating web3js, previous version 1.0.0-beta-37 - also can confirm this worked as expected on 1.0.0-beta.47

@nivida nivida added Bug Addressing a bug and removed Needs Clarification Requires additional input labels Mar 27, 2019
@nivida
Copy link
Contributor

nivida commented Mar 28, 2019

This got fixed with 2ce2412 and will be released today.

@nivida nivida closed this as completed Mar 28, 2019
@Anaphase
Copy link

I seem to be getting this same error when calling myContract.methods.myMethod(...).send() for a method that has no return value. It appears the transaction does get sent but the .then() never fires and this error is thrown.

I could be missing something though, I'm currently knee deep in upgrading from 1.0.0-beta.34 to 1.0.0-beta.52, which has been a challenge to say the least.

@hqblock
Copy link

hqblock commented Apr 15, 2019

I was having the same error after upgrading to 1.0.0-beta52 and using web3.eth.abi.decodeLog.
The error message shows when the receipt's data field is '0x', and this value is passed to decodeLog for the data argument. When I set the data value to null it works fine.

May I suggest updating web3.eth.abi.decodeLog the same way it was done for EventLogDecoder ?
https://github.com/ethereum/web3.js/blob/2ce2412daea89c3fa90fa2f589617e514602ac40/packages/web3-eth-contract/src/decoders/EventLogDecoder.js#L50-L52

Thanks!

@Anaphase
Copy link

Anaphase commented Apr 15, 2019

@hqblock, good catch! When I update web3.eth.abi.decodeLog with the same change on line 232, I can actually submit my transaction now:

if (data && data !== '0x' && data !== '0x0') { ... }

Note that, in my specific use case, checking for 0x0 was also necessary. I still can't get logs for a contract using web3.eth.contract.getPastEvents (I just get an empty list?) and I think that may also be related to log decoding somehow... still digging around.

UPDATE: the getPastEvents() error I mentioned was unrelated and caused by my own stupidity. However, I'm pretty sure updating web3.eth.abi.decodeLog as @hqblock suggested is a good idea! I'll try to put together a PR. See #2686

@nivida
Copy link
Contributor

nivida commented Apr 16, 2019

The correct if is:

if (data && data !== '0x') {
....
}

0x0 should be handled as 0 or false.

@Anaphase
Copy link

Anaphase commented Apr 16, 2019

@nivida Okay, I figured out what my issue was with decodeLog - it's something different than just the "empty data" check. I will create a separate issue since adding to the comments of this closed issue seems inappropriate.

See: #2695

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

No branches or pull requests

6 participants