go-ethereum/cmd/mist/assets/ext/ethereum.js/example/event.html

121 lines
3.9 KiB
HTML
Raw Normal View History

2015-01-29 16:05:43 +02:00
<!doctype>
<html>
<head>
<script type="text/javascript" src="js/bignumber.js/bignumber.min.js"></script>
<script type="text/javascript" src="../dist/ethereum.js"></script>
<script type="text/javascript">
var web3 = require('web3');
web3.setProvider(new web3.providers.HttpSyncProvider('http://localhost:8080'));
var desc = [{
"type":"event",
"inputs": [{"name":"a","type":"uint256","indexed":true},{"name":"b","type":"hash256","indexed":false}],
"name":"Event"
}, {
"type":"event",
"inputs": [{"name":"a","type":"uint256","indexed":true},{"name":"b","type":"hash256","indexed":false}],
"name":"Event2"
}, {
"type":"function",
"inputs": [{"name":"a","type":"uint256"}],
"name":"foo",
"outputs": []
}];
var address = '0x01';
var contract = web3.eth.contract(address, desc);
function test1() {
2015-01-31 05:09:48 +02:00
// "{"topic":["0x83c9849c","0xc4d76332"],"address":"0x01"}"
2015-01-29 16:05:43 +02:00
web3.eth.watch(contract).changed(function (res) {
});
};
function test2() {
2015-01-31 05:09:48 +02:00
// "{"topic":["0x83c9849c"],"address":"0x01"}"
2015-01-29 16:05:43 +02:00
web3.eth.watch(contract.Event).changed(function (res) {
});
};
function test3() {
2015-01-31 05:09:48 +02:00
// "{"topic":["0x83c9849c"],"address":"0x01"}"
2015-01-29 16:05:43 +02:00
contract.Event().changed(function (res) {
});
};
2015-01-31 05:09:48 +02:00
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) {
});
};
2015-01-31 17:01:41 +02:00
function test8() {
// "{"topic":["0x83c9849c","000000000000000000000000000000000000000000000000000000000000001e"],"max":100,"address":"0x01"}"
web3.eth.watch(contract.Event, {a: 30}, {max: 100}).changed(function (res) {
2015-01-31 05:09:48 +02:00
2015-01-31 17:01:41 +02:00
});
};
2015-01-29 16:05:43 +02:00
// not valid
2015-01-31 05:09:48 +02:00
// function testX() {
2015-01-29 16:05:43 +02:00
// web3.eth.watch([contract.Event, contract.Event2]).changed(function (res) {
// });
// };
</script>
</head>
<body>
<div>
<button type="button" onClick="test1();">test1</button>
</div>
<div>
<button type="button" onClick="test2();">test2</button>
</div>
<div>
<button type="button" onClick="test3();">test3</button>
</div>
2015-01-31 05:09:48 +02:00
<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>
2015-01-31 17:01:41 +02:00
<div>
<button type="button" onClick="test8();">test8</button>
</div>
2015-01-29 16:05:43 +02:00
</body>
</html>