Skip to content

Commit

Permalink
anonymous events implementation && tests
Browse files Browse the repository at this point in the history
  • Loading branch information
debris committed Apr 22, 2015
1 parent b5eabd8 commit 9f7d6a9
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 14 deletions.
8 changes: 6 additions & 2 deletions dist/web3-light.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/web3-light.js.map

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions dist/web3-light.min.js

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions dist/web3.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/web3.js.map

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions dist/web3.min.js

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions lib/web3/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var SolidityEvent = function (json, address) {
this._params = json.inputs;
this._name = utils.transformToFullName(json);
this._address = address;
this._anonymous = json.anonymous;
};

/**
Expand Down Expand Up @@ -97,9 +98,12 @@ SolidityEvent.prototype.encode = function (indexed, options) {
result[f] = utils.toHex(options[f]);
});

result.address = this._address;
result.topics = [];
result.topics.push('0x' + this.signature());

if (!this._anonymous) {
result.address = this._address;
result.topics.push('0x' + this.signature());
}

var indexedTopics = this._params.filter(function (i) {
return i.indexed === true;
Expand Down
19 changes: 19 additions & 0 deletions test/event.encode.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,25 @@ var tests = [{
'0x0000000000000000000000000000000000000000000000000000000000000001'
]
}
}, {
abi: {
name: 'event1',
inputs: [{
type: 'int',
name: 'a',
indexed: true
}],
anonymous: true
},
indexed: {
a: 1
},
options: {},
expected: {
topics: [
'0x0000000000000000000000000000000000000000000000000000000000000001'
]
}
}];

describe('lib/web3/event', function () {
Expand Down

0 comments on commit 9f7d6a9

Please sign in to comment.