Skip to content

Commit

Permalink
Merge pull request #3015 from micahriggan/fix/web3-contract-event-name
Browse files Browse the repository at this point in the history
Fix accessing event.name where event is undefined
  • Loading branch information
nivida authored Aug 9, 2019
2 parents 2022b17 + 1683f20 commit 2d0a3f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
services:
- xvfb
language: node_js
node_js:
- "8"
Expand All @@ -12,10 +14,7 @@ addons:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
install:
install:
- npm install
script:
- npm run-script build
Expand Down
8 changes: 4 additions & 4 deletions packages/web3-eth-contract/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,16 +528,16 @@ Contract.prototype._generateEventOptions = function() {
// get the options
var options = (_.isObject(args[args.length - 1])) ? args.pop() : {};

var event = (_.isString(args[0])) ? args[0] : 'allevents';
event = (event.toLowerCase() === 'allevents') ? {
var eventName = (_.isString(args[0])) ? args[0] : 'allevents';
var event = (eventName.toLowerCase() === 'allevents') ? {
name: 'ALLEVENTS',
jsonInterface: this.options.jsonInterface
} : this.options.jsonInterface.find(function (json) {
return (json.type === 'event' && (json.name === event || json.signature === '0x'+ event.replace('0x','')));
return (json.type === 'event' && (json.name === eventName || json.signature === '0x'+ eventName.replace('0x','')));
});

if (!event) {
throw new Error('Event "' + event.name + '" doesn\'t exist in this contract.');
throw new Error('Event "' + eventName + '" doesn\'t exist in this contract.');
}

if (!utils.isAddress(this.options.address)) {
Expand Down

0 comments on commit 2d0a3f3

Please sign in to comment.