Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

myContract.MyEvent() doesn't accept filter options #1170

Closed
1 task done
pstuermlinger opened this issue Aug 4, 2018 · 1 comment
Closed
1 task done

myContract.MyEvent() doesn't accept filter options #1170

pstuermlinger opened this issue Aug 4, 2018 · 1 comment

Comments

@pstuermlinger
Copy link


Issue

let myFilter = myContract.MyEvent({ fromBlock: x, toBlock: y }) doesn't work as both properties stay undefined when I inspect myFilter.

According to this issue it should work.

Steps to Reproduce

Setup a filter of your choice and try to set options 'fromBlock' and 'toBlock'.
Example:

let myFilter = myContractInstance.MyEvent({
  fromBlock: 0,
  toBlock: 100
}).get((error, logs) => {
    if (error) console.log(error)

    console.log('logs:', logs.length)
    myFilter.stopWatching()
  })
})

Expected Behavior

Both properties should be set in myFilter.options and hence, the filter should return ALL occurrences of that event within the given blocks.

Actual Results

Both properties are undefined. The filter returns only the latest occurrence of that event.

Environment

  • Operating System: Linux Mint 18.2 64-bit
  • Ethereum client: Metamask + Ganache 1.2.1
  • Truffle version (truffle version): v4.1.13
  • node version (node --version): v8.11.3
  • npm version (npm --version): 6.2.0
@pstuermlinger pstuermlinger changed the title myContract.myEvent() doesn't accept filter options myContract.MyEvent() doesn't accept filter options Aug 4, 2018
@cgewecke
Copy link
Contributor

cgewecke commented Aug 5, 2018

@Haggins We're migrating to Web3 1.0 with Truffle V5 and it looks the filter implementation there is more reliable - have had good luck with the .getPastEvents method and we have some tests and example usage for that here

You can install a pre-release of V5 by running:

npm install truffle@next

Usage notes are are available at #1129 (See the Web3 1.0 section). NB: Web3 1.0 comes with a few breaking changes.

Hope you don't mind but closing because we won't be making any further improvements to truffle-contract for V4 and this appears to work expected for V5.

@cgewecke cgewecke closed this as completed Aug 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants