aboutsummaryrefslogtreecommitdiffstats
path: root/lib/event.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/event.js')
-rw-r--r--lib/event.js28
1 files changed, 20 insertions, 8 deletions
diff --git a/lib/event.js b/lib/event.js
index c01fea6ef..efb85b1fc 100644
--- a/lib/event.js
+++ b/lib/event.js
@@ -25,27 +25,36 @@ var utils = require('./utils');
var inputWithName = function (inputs, name) {
var index = utils.findIndex(inputs, function (input) {
- return input.name === name;
+ return input.name === name;
});
+
if (index === -1) {
- console.error('indexed param ' + name + ' not found in the abi');
- return undefined;
+ console.error('indexed paray with name ' + name + ' not found');
+ return undefined;
}
return inputs[index];
};
-var indexedParamsToTopics = function (inputs, indexed) {
- Object.keys(indexed).map(function (key) {
- var inp = inputWithName(key);
+var indexedParamsToTopics = function (event, indexed) {
+ // sort keys?
+ return Object.keys(indexed).map(function (key) {
+ // TODO: simplify this!
+ var parser = abi.inputParser([{
+ name: 'test',
+ inputs: [inputWithName(event.inputs, key)]
+ }]);
+
var value = indexed[key];
if (value instanceof Array) {
-
+ return value.map(function (v) {
+ return parser.test(v);
+ });
}
+ return parser.test(value);
});
};
var implementationOfEvent = function (address, signature, event) {
-
// valid options are 'earliest', 'latest', 'offset' and 'max', as defined for 'eth.watch'
return function (indexed, options) {
@@ -53,6 +62,9 @@ var implementationOfEvent = function (address, signature, event) {
o.address = address;
o.topic = [];
o.topic.push(signature);
+ if (indexed) {
+ o.topic = o.topic.concat(indexedParamsToTopics(event, indexed));
+ }
return o;
};
};