trufflesuite / truffle-artifactor

A contract packager for Ethereum and Javascript (formerly ether-pudding)
MIT License
253 stars 54 forks source link

Contract events/filters #2

Closed tymat closed 9 years ago

tymat commented 9 years ago

Pudding seems to overwrite the event/filter functionality of web3.

https://github.com/ethereum/wiki/wiki/JavaScript-API#contract-events

Given the following code in Solidity:

event Refund(address _u, uint _a, uint _g);

The event/filter from web3 seems to be absent.

node> refundWatcherInstance.Refund()
TypeError: undefined is not a function
tcoulter commented 9 years ago

Hmm, I'll have to take a closer look at events within the contract abstraction. Thanks for the report.

tcoulter commented 9 years ago

This might be relevent: https://github.com/ethereum/web3.js/commit/9da4645acbf8a98f61152b82778ab02d67df6016

Check web3's commit history. If they published 0.8.1 to npm before fixing events (the commit above) that could be the cause of the issue.

tymat commented 9 years ago

Yep. Might be good to version lock pudding until web3 is stable.

node> web3.version
{ api: '0.8.1', ....
ethers commented 9 years ago

as of Truffle 0.10 (I don't use pudding standalone) my observation is that pudding is converting events to promises. could the fix be around these lines? https://github.com/ConsenSys/ether-pudding/blob/master/src/pudding.coffee#L119

tymat commented 9 years ago

Pudding does a promisifyAll on web3 which breaks the events.

tcoulter commented 9 years ago

Pudding does a promisifyAll on web3 which breaks the events.

Not on all of web3, but just on your contract. But yes, it shouldn't do that. It should instead inspect the abi and only promisify abi functions. Anyone want to take a crack at fixing it that way?