aboutsummaryrefslogtreecommitdiffstats
path: root/example/event.html
blob: 23981326814785249d321da16c557efe8bb96d99 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!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() {
            // "{"topic":["0x83c9849c","0xc4d76332"],"address":"0x01"}"
            web3.eth.watch(contract).changed(function (res) {
                
            });
        };

        function test2() {
            // "{"topic":["0x83c9849c"],"address":"0x01"}"
            web3.eth.watch(contract.Event).changed(function (res) {
                
            });
        };

        function test3() {
            // "{"topic":["0x83c9849c"],"address":"0x01"}"
            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
        // function testX() {
        //    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>
        <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>
</html>