Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
df17c338
Commit
df17c338
authored
Jan 29, 2015
by
Marek Kotewicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
event example
parent
c8ee08c2
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
162 additions
and
15 deletions
+162
-15
ethereum.js
dist/ethereum.js
+45
-5
ethereum.js.map
dist/ethereum.js.map
+4
-4
ethereum.min.js
dist/ethereum.min.js
+1
-1
balance.html
example/balance.html
+1
-1
event.html
example/event.html
+67
-0
contract.js
lib/contract.js
+11
-3
event.js
lib/event.js
+20
-1
filter.js
lib/filter.js
+13
-0
No files found.
dist/ethereum.js
View file @
df17c338
...
@@ -453,7 +453,7 @@ module.exports = {
...
@@ -453,7 +453,7 @@ module.exports = {
var
web3
=
require
(
'./web3'
);
var
web3
=
require
(
'./web3'
);
var
abi
=
require
(
'./abi'
);
var
abi
=
require
(
'./abi'
);
var
eventImpl
ementation
=
require
(
'./event'
);
var
eventImpl
=
require
(
'./event'
);
var
addFunctionRelatedPropertiesToContract
=
function
(
contract
)
{
var
addFunctionRelatedPropertiesToContract
=
function
(
contract
)
{
...
@@ -558,10 +558,18 @@ var addEventsToContract = function (contract, desc, address) {
...
@@ -558,10 +558,18 @@ var addEventsToContract = function (contract, desc, address) {
var
impl
=
function
()
{
var
impl
=
function
()
{
var
params
=
Array
.
prototype
.
slice
.
call
(
arguments
);
var
params
=
Array
.
prototype
.
slice
.
call
(
arguments
);
var
signature
=
abi
.
methodSignature
(
e
.
name
);
var
signature
=
abi
.
methodSignature
(
e
.
name
);
var
event
Impl
=
eventImplementation
(
address
,
signature
);
var
event
=
eventImpl
(
address
,
signature
);
var
o
=
event
Impl
.
apply
(
null
,
params
);
var
o
=
event
.
apply
(
null
,
params
);
return
web3
.
eth
.
watch
(
o
);
return
web3
.
eth
.
watch
(
o
);
};
};
impl
.
address
=
address
;
Object
.
defineProperty
(
impl
,
'topics'
,
{
get
:
function
()
{
return
[
abi
.
methodSignature
(
e
.
name
)];
}
});
// TODO: rename these methods, cause they are used not only for methods
// TODO: rename these methods, cause they are used not only for methods
var
displayName
=
abi
.
methodDisplayName
(
e
.
name
);
var
displayName
=
abi
.
methodDisplayName
(
e
.
name
);
...
@@ -628,8 +636,27 @@ module.exports = contract;
...
@@ -628,8 +636,27 @@ module.exports = contract;
},{
"./abi"
:
1
,
"./event"
:
3
,
"./web3"
:
8
}],
3
:[
function
(
require
,
module
,
exports
){
},{
"./abi"
:
1
,
"./event"
:
3
,
"./web3"
:
8
}],
3
:[
function
(
require
,
module
,
exports
){
/*
This file is part of ethereum.js.
var
abi
=
require
(
'./abi'
);
ethereum.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ethereum.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file event.js
* @authors:
* Marek Kotewicz <marek@ethdev.com>
* @date 2014
*/
var
implementationOfEvent
=
function
(
address
,
signature
)
{
var
implementationOfEvent
=
function
(
address
,
signature
)
{
...
@@ -645,7 +672,7 @@ var implementationOfEvent = function (address, signature) {
...
@@ -645,7 +672,7 @@ var implementationOfEvent = function (address, signature) {
module
.
exports
=
implementationOfEvent
;
module
.
exports
=
implementationOfEvent
;
},{
"./abi"
:
1
}],
4
:[
function
(
require
,
module
,
exports
){
},{}],
4
:[
function
(
require
,
module
,
exports
){
/*
/*
This file is part of ethereum.js.
This file is part of ethereum.js.
...
@@ -679,6 +706,19 @@ var Filter = function(options, impl) {
...
@@ -679,6 +706,19 @@ var Filter = function(options, impl) {
this
.
impl
=
impl
;
this
.
impl
=
impl
;
this
.
callbacks
=
[];
this
.
callbacks
=
[];
if
(
typeof
options
!==
"string"
)
{
// evaluate lazy properties
options
=
{
to
:
options
.
to
,
topics
:
options
.
topics
,
earliest
:
options
.
earliest
,
latest
:
options
.
latest
,
max
:
options
.
max
,
skip
:
options
.
skip
,
address
:
options
.
address
};
}
this
.
id
=
impl
.
newFilter
(
options
);
this
.
id
=
impl
.
newFilter
(
options
);
web3
.
provider
.
startPolling
({
call
:
impl
.
changed
,
args
:
[
this
.
id
]},
this
.
id
,
this
.
trigger
.
bind
(
this
));
web3
.
provider
.
startPolling
({
call
:
impl
.
changed
,
args
:
[
this
.
id
]},
this
.
id
,
this
.
trigger
.
bind
(
this
));
};
};
...
...
dist/ethereum.js.map
View file @
df17c338
This diff is collapsed.
Click to expand it.
dist/ethereum.min.js
View file @
df17c338
This diff is collapsed.
Click to expand it.
example/balance.html
View file @
df17c338
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
var
originalBalance
=
web3
.
toDecimal
(
balance
);
var
originalBalance
=
web3
.
toDecimal
(
balance
);
document
.
getElementById
(
'original'
).
innerText
=
'original balance: '
+
originalBalance
+
' watching...'
;
document
.
getElementById
(
'original'
).
innerText
=
'original balance: '
+
originalBalance
+
' watching...'
;
web3
.
eth
.
watch
({
a
ltered
:
coinbase
}).
changed
(
function
()
{
web3
.
eth
.
watch
({
a
ddress
:
coinbase
}).
changed
(
function
()
{
balance
=
web3
.
eth
.
balanceAt
(
coinbase
)
balance
=
web3
.
eth
.
balanceAt
(
coinbase
)
var
currentBalance
=
web3
.
toDecimal
(
balance
);
var
currentBalance
=
web3
.
toDecimal
(
balance
);
document
.
getElementById
(
"current"
).
innerText
=
'current: '
+
currentBalance
;
document
.
getElementById
(
"current"
).
innerText
=
'current: '
+
currentBalance
;
...
...
example/event.html
0 → 100644
View file @
df17c338
<
!
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
()
{
web3
.
eth
.
watch
(
contract
).
changed
(
function
(
res
)
{
});
};
function
test2
()
{
web3
.
eth
.
watch
(
contract
.
Event
).
changed
(
function
(
res
)
{
});
};
function
test3
()
{
contract
.
Event
().
changed
(
function
(
res
)
{
});
};
// not valid
// function test4() {
// 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>
</body>
</html>
lib/contract.js
View file @
df17c338
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
var
web3
=
require
(
'./web3'
);
var
web3
=
require
(
'./web3'
);
var
abi
=
require
(
'./abi'
);
var
abi
=
require
(
'./abi'
);
var
eventImpl
ementation
=
require
(
'./event'
);
var
eventImpl
=
require
(
'./event'
);
var
addFunctionRelatedPropertiesToContract
=
function
(
contract
)
{
var
addFunctionRelatedPropertiesToContract
=
function
(
contract
)
{
...
@@ -127,10 +127,18 @@ var addEventsToContract = function (contract, desc, address) {
...
@@ -127,10 +127,18 @@ var addEventsToContract = function (contract, desc, address) {
var
impl
=
function
()
{
var
impl
=
function
()
{
var
params
=
Array
.
prototype
.
slice
.
call
(
arguments
);
var
params
=
Array
.
prototype
.
slice
.
call
(
arguments
);
var
signature
=
abi
.
methodSignature
(
e
.
name
);
var
signature
=
abi
.
methodSignature
(
e
.
name
);
var
event
Impl
=
eventImplementation
(
address
,
signature
);
var
event
=
eventImpl
(
address
,
signature
);
var
o
=
event
Impl
.
apply
(
null
,
params
);
var
o
=
event
.
apply
(
null
,
params
);
return
web3
.
eth
.
watch
(
o
);
return
web3
.
eth
.
watch
(
o
);
};
};
impl
.
address
=
address
;
Object
.
defineProperty
(
impl
,
'topics'
,
{
get
:
function
()
{
return
[
abi
.
methodSignature
(
e
.
name
)];
}
});
// TODO: rename these methods, cause they are used not only for methods
// TODO: rename these methods, cause they are used not only for methods
var
displayName
=
abi
.
methodDisplayName
(
e
.
name
);
var
displayName
=
abi
.
methodDisplayName
(
e
.
name
);
...
...
lib/event.js
View file @
df17c338
/*
This file is part of ethereum.js.
var
abi
=
require
(
'./abi'
);
ethereum.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ethereum.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file event.js
* @authors:
* Marek Kotewicz <marek@ethdev.com>
* @date 2014
*/
var
implementationOfEvent
=
function
(
address
,
signature
)
{
var
implementationOfEvent
=
function
(
address
,
signature
)
{
...
...
lib/filter.js
View file @
df17c338
...
@@ -31,6 +31,19 @@ var Filter = function(options, impl) {
...
@@ -31,6 +31,19 @@ var Filter = function(options, impl) {
this
.
impl
=
impl
;
this
.
impl
=
impl
;
this
.
callbacks
=
[];
this
.
callbacks
=
[];
if
(
typeof
options
!==
"string"
)
{
// evaluate lazy properties
options
=
{
to
:
options
.
to
,
topics
:
options
.
topics
,
earliest
:
options
.
earliest
,
latest
:
options
.
latest
,
max
:
options
.
max
,
skip
:
options
.
skip
,
address
:
options
.
address
};
}
this
.
id
=
impl
.
newFilter
(
options
);
this
.
id
=
impl
.
newFilter
(
options
);
web3
.
provider
.
startPolling
({
call
:
impl
.
changed
,
args
:
[
this
.
id
]},
this
.
id
,
this
.
trigger
.
bind
(
this
));
web3
.
provider
.
startPolling
({
call
:
impl
.
changed
,
args
:
[
this
.
id
]},
this
.
id
,
this
.
trigger
.
bind
(
this
));
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment