events init
This commit is contained in:
@ -85,6 +85,7 @@ var contract = function (address, desc) {
|
||||
});
|
||||
|
||||
|
||||
// create contract functions
|
||||
abi.filterFunctions(desc).forEach(function (method) {
|
||||
|
||||
var displayName = abi.methodDisplayName(method.name);
|
||||
@ -139,6 +140,31 @@ var contract = function (address, desc) {
|
||||
|
||||
});
|
||||
|
||||
|
||||
// create contract events
|
||||
abi.filterEvents(desc).forEach(function (event) {
|
||||
|
||||
// TODO: rename these methods, cause they are used not only for methods
|
||||
var displayName = abi.methodDisplayName(event.name);
|
||||
var typeName = abi.methodTypeName(event.name);
|
||||
|
||||
var impl = function (options) {
|
||||
var o = options || {};
|
||||
o.address = o.address || address;
|
||||
o.topics = o.topics || [];
|
||||
o.topics.push(abi.methodSignature(event.name));
|
||||
|
||||
return web3.eth.watch(o);
|
||||
};
|
||||
|
||||
if (result[displayName] === undefined) {
|
||||
result[displayName] = impl;
|
||||
}
|
||||
|
||||
result[displayName][typeName] = impl;
|
||||
|
||||
});
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user