forked from cerc-io/plugeth
events
This commit is contained in:
parent
80c97ca21b
commit
0b82a05a75
14
dist/ethereum.js
vendored
14
dist/ethereum.js
vendored
@ -580,11 +580,9 @@ var web3 = require('./web3'); // jshint ignore:line
|
|||||||
/// should be used when we want to watch something
|
/// should be used when we want to watch something
|
||||||
/// it's using inner polling mechanism and is notified about changes
|
/// it's using inner polling mechanism and is notified about changes
|
||||||
/// TODO: change 'options' name cause it may be not the best matching one, since we have events
|
/// TODO: change 'options' name cause it may be not the best matching one, since we have events
|
||||||
var Filter = function(options, indexed, impl) {
|
var Filter = function(options, impl) {
|
||||||
|
|
||||||
if (options._isEvent) {
|
if (typeof options !== "string") {
|
||||||
return options(indexed);
|
|
||||||
} else if (typeof options !== "string") {
|
|
||||||
|
|
||||||
// topics property is deprecated, warn about it!
|
// topics property is deprecated, warn about it!
|
||||||
if (options.topics) {
|
if (options.topics) {
|
||||||
@ -1432,7 +1430,10 @@ var web3 = {
|
|||||||
/// @param filter may be a string, object or event
|
/// @param filter may be a string, object or event
|
||||||
/// @param indexed is optional, this may be an object with optional event indexed params
|
/// @param indexed is optional, this may be an object with optional event indexed params
|
||||||
watch: function (filter, indexed) {
|
watch: function (filter, indexed) {
|
||||||
return new web3.filter(filter, indexed, ethWatch);
|
if (filter._isEvent) {
|
||||||
|
return filter(indexed);
|
||||||
|
}
|
||||||
|
return new web3.filter(filter, ethWatch);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1443,9 +1444,8 @@ var web3 = {
|
|||||||
shh: {
|
shh: {
|
||||||
|
|
||||||
/// @param filter may be a string, object or event
|
/// @param filter may be a string, object or event
|
||||||
/// @param indexed is optional, this may be an object with optional event indexed params
|
|
||||||
watch: function (filter, indexed) {
|
watch: function (filter, indexed) {
|
||||||
return new web3.filter(filter, indexed, shhWatch);
|
return new web3.filter(filter, shhWatch);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
6
dist/ethereum.js.map
vendored
6
dist/ethereum.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/ethereum.min.js
vendored
2
dist/ethereum.min.js
vendored
File diff suppressed because one or more lines are too long
@ -27,25 +27,57 @@
|
|||||||
var contract = web3.eth.contract(address, desc);
|
var contract = web3.eth.contract(address, desc);
|
||||||
|
|
||||||
function test1() {
|
function test1() {
|
||||||
|
// "{"topic":["0x83c9849c","0xc4d76332"],"address":"0x01"}"
|
||||||
web3.eth.watch(contract).changed(function (res) {
|
web3.eth.watch(contract).changed(function (res) {
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function test2() {
|
function test2() {
|
||||||
|
// "{"topic":["0x83c9849c"],"address":"0x01"}"
|
||||||
web3.eth.watch(contract.Event).changed(function (res) {
|
web3.eth.watch(contract.Event).changed(function (res) {
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function test3() {
|
function test3() {
|
||||||
|
// "{"topic":["0x83c9849c"],"address":"0x01"}"
|
||||||
contract.Event().changed(function (res) {
|
contract.Event().changed(function (res) {
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function test4() {
|
||||||
|
// "{"topic":["0x83c9849c","0000000000000000000000000000000000000000000000000000000000000045"],"address":"0x01"}"
|
||||||
|
contract.Event({a: 69}).changed(function (res) {
|
||||||
|
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
function test5() {
|
||||||
|
// "{"topic":["0x83c9849c",["0000000000000000000000000000000000000000000000000000000000000045","000000000000000000000000000000000000000000000000000000000000002a"]],"address":"0x01"}"
|
||||||
|
contract.Event({a: [69, 42]}).changed(function (res) {
|
||||||
|
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
function test6() {
|
||||||
|
// "{"topic":["0x83c9849c","000000000000000000000000000000000000000000000000000000000000001e"],"max":100,"address":"0x01"}"
|
||||||
|
contract.Event({a: 30}, {max: 100}).changed(function (res) {
|
||||||
|
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
function test7() {
|
||||||
|
// "{"topic":["0x83c9849c","000000000000000000000000000000000000000000000000000000000000001e"],"address":"0x01"}"
|
||||||
|
web3.eth.watch(contract.Event, {a: 30}).changed(function (res) {
|
||||||
|
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// not valid
|
// not valid
|
||||||
// function test4() {
|
// function testX() {
|
||||||
// web3.eth.watch([contract.Event, contract.Event2]).changed(function (res) {
|
// web3.eth.watch([contract.Event, contract.Event2]).changed(function (res) {
|
||||||
// });
|
// });
|
||||||
// };
|
// };
|
||||||
@ -63,5 +95,17 @@
|
|||||||
<div>
|
<div>
|
||||||
<button type="button" onClick="test3();">test3</button>
|
<button type="button" onClick="test3();">test3</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<button type="button" onClick="test4();">test4</button>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<button type="button" onClick="test5();">test5</button>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<button type="button" onClick="test6();">test6</button>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<button type="button" onClick="test7();">test7</button>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -28,11 +28,9 @@ var web3 = require('./web3'); // jshint ignore:line
|
|||||||
/// should be used when we want to watch something
|
/// should be used when we want to watch something
|
||||||
/// it's using inner polling mechanism and is notified about changes
|
/// it's using inner polling mechanism and is notified about changes
|
||||||
/// TODO: change 'options' name cause it may be not the best matching one, since we have events
|
/// TODO: change 'options' name cause it may be not the best matching one, since we have events
|
||||||
var Filter = function(options, indexed, impl) {
|
var Filter = function(options, impl) {
|
||||||
|
|
||||||
if (options._isEvent) {
|
if (typeof options !== "string") {
|
||||||
return options(indexed);
|
|
||||||
} else if (typeof options !== "string") {
|
|
||||||
|
|
||||||
// topics property is deprecated, warn about it!
|
// topics property is deprecated, warn about it!
|
||||||
if (options.topics) {
|
if (options.topics) {
|
||||||
|
@ -282,7 +282,10 @@ var web3 = {
|
|||||||
/// @param filter may be a string, object or event
|
/// @param filter may be a string, object or event
|
||||||
/// @param indexed is optional, this may be an object with optional event indexed params
|
/// @param indexed is optional, this may be an object with optional event indexed params
|
||||||
watch: function (filter, indexed) {
|
watch: function (filter, indexed) {
|
||||||
return new web3.filter(filter, indexed, ethWatch);
|
if (filter._isEvent) {
|
||||||
|
return filter(indexed);
|
||||||
|
}
|
||||||
|
return new web3.filter(filter, ethWatch);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -293,9 +296,8 @@ var web3 = {
|
|||||||
shh: {
|
shh: {
|
||||||
|
|
||||||
/// @param filter may be a string, object or event
|
/// @param filter may be a string, object or event
|
||||||
/// @param indexed is optional, this may be an object with optional event indexed params
|
|
||||||
watch: function (filter, indexed) {
|
watch: function (filter, indexed) {
|
||||||
return new web3.filter(filter, indexed, shhWatch);
|
return new web3.filter(filter, shhWatch);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user