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
995861de
Commit
995861de
authored
Jan 31, 2015
by
Marek Kotewicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
event options
parent
600c9dd2
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
104 additions
and
36 deletions
+104
-36
ethereum.js
dist/ethereum.js
+34
-14
ethereum.js.map
dist/ethereum.js.map
+5
-5
ethereum.min.js
dist/ethereum.min.js
+1
-1
contract.js
lib/contract.js
+4
-0
event.js
lib/event.js
+7
-4
filter.js
lib/filter.js
+12
-5
web3.js
lib/web3.js
+10
-4
event.js
test/event.js
+31
-3
No files found.
dist/ethereum.js
View file @
995861de
...
...
@@ -562,7 +562,11 @@ var addEventsToContract = function (contract, desc, address) {
var
o
=
event
.
apply
(
null
,
params
);
return
web3
.
eth
.
watch
(
o
);
};
// this property should be used by eth.filter to check if object is an event
impl
.
_isEvent
=
true
;
// TODO: we can remove address && topic properties, they are not used anymore since we introduced _isEvent
impl
.
address
=
address
;
Object
.
defineProperty
(
impl
,
'topic'
,
{
...
...
@@ -656,13 +660,16 @@ module.exports = contract;
* @date 2014
*/
var
abi
=
require
(
'./abi'
);
var
implementationOfEvent
=
function
(
address
,
signature
)
{
return
function
(
options
)
{
// valid options are 'earliest', 'latest', 'offset' and 'max', as defined for 'eth.watch'
return
function
(
indexed
,
options
)
{
var
o
=
options
||
{};
o
.
address
=
o
.
address
||
address
;
o
.
topic
s
=
o
.
topics
||
[];
o
.
topic
s
.
push
(
signature
);
o
.
address
=
address
;
o
.
topic
=
[];
o
.
topic
.
push
(
signature
);
return
o
;
};
};
...
...
@@ -670,7 +677,7 @@ var implementationOfEvent = function (address, signature) {
module
.
exports
=
implementationOfEvent
;
},{}],
4
:[
function
(
require
,
module
,
exports
){
},{
"./abi"
:
1
}],
4
:[
function
(
require
,
module
,
exports
){
/*
This file is part of ethereum.js.
...
...
@@ -700,16 +707,19 @@ var web3 = require('./web3'); // jshint ignore:line
/// should be used when we want to watch something
/// it's using inner polling mechanism and is notified about changes
var
Filter
=
function
(
options
,
impl
)
{
this
.
impl
=
impl
;
this
.
callbacks
=
[];
/// TODO: change 'options' name cause it may be not the best matching one, since we have events
var
Filter
=
function
(
options
,
indexed
,
impl
)
{
if
(
typeof
options
!==
"string"
)
{
// evaluate lazy properties
if
(
options
.
_isEvent
)
{
return
options
(
indexed
);
}
else
if
(
typeof
options
!==
"string"
)
{
// topics property is deprecated, warn about it!
if
(
options
.
topics
)
{
console
.
warn
(
'"topics" is deprecated, use "topic" instead'
);
}
// evaluate lazy properties
options
=
{
to
:
options
.
to
,
topic
:
options
.
topic
,
...
...
@@ -719,7 +729,11 @@ var Filter = function(options, impl) {
skip
:
options
.
skip
,
address
:
options
.
address
};
}
this
.
impl
=
impl
;
this
.
callbacks
=
[];
this
.
id
=
impl
.
newFilter
(
options
);
web3
.
provider
.
startPolling
({
call
:
impl
.
changed
,
args
:
[
this
.
id
]},
this
.
id
,
this
.
trigger
.
bind
(
this
));
...
...
@@ -1261,8 +1275,11 @@ var web3 = {
return
ret
;
};
},
watch
:
function
(
params
)
{
return
new
web3
.
filter
(
params
,
ethWatch
);
/// @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
)
{
return
new
web3
.
filter
(
filter
,
indexed
,
ethWatch
);
}
},
...
...
@@ -1271,8 +1288,11 @@ var web3 = {
/// shh object prototype
shh
:
{
watch
:
function
(
params
)
{
return
new
web3
.
filter
(
params
,
shhWatch
);
/// @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
)
{
return
new
web3
.
filter
(
filter
,
indexed
,
shhWatch
);
}
},
...
...
dist/ethereum.js.map
View file @
995861de
This diff is collapsed.
Click to expand it.
dist/ethereum.min.js
View file @
995861de
This diff is collapsed.
Click to expand it.
lib/contract.js
View file @
995861de
...
...
@@ -131,7 +131,11 @@ var addEventsToContract = function (contract, desc, address) {
var
o
=
event
.
apply
(
null
,
params
);
return
web3
.
eth
.
watch
(
o
);
};
// this property should be used by eth.filter to check if object is an event
impl
.
_isEvent
=
true
;
// TODO: we can remove address && topic properties, they are not used anymore since we introduced _isEvent
impl
.
address
=
address
;
Object
.
defineProperty
(
impl
,
'topic'
,
{
...
...
lib/event.js
View file @
995861de
...
...
@@ -20,13 +20,16 @@
* @date 2014
*/
var
abi
=
require
(
'./abi'
);
var
implementationOfEvent
=
function
(
address
,
signature
)
{
return
function
(
options
)
{
// valid options are 'earliest', 'latest', 'offset' and 'max', as defined for 'eth.watch'
return
function
(
indexed
,
options
)
{
var
o
=
options
||
{};
o
.
address
=
o
.
address
||
address
;
o
.
topic
s
=
o
.
topics
||
[];
o
.
topic
s
.
push
(
signature
);
o
.
address
=
address
;
o
.
topic
=
[];
o
.
topic
.
push
(
signature
);
return
o
;
};
};
...
...
lib/filter.js
View file @
995861de
...
...
@@ -27,16 +27,19 @@ var web3 = require('./web3'); // jshint ignore:line
/// should be used when we want to watch something
/// it's using inner polling mechanism and is notified about changes
var
Filter
=
function
(
options
,
impl
)
{
this
.
impl
=
impl
;
this
.
callbacks
=
[];
/// TODO: change 'options' name cause it may be not the best matching one, since we have events
var
Filter
=
function
(
options
,
indexed
,
impl
)
{
if
(
typeof
options
!==
"string"
)
{
// evaluate lazy properties
if
(
options
.
_isEvent
)
{
return
options
(
indexed
);
}
else
if
(
typeof
options
!==
"string"
)
{
// topics property is deprecated, warn about it!
if
(
options
.
topics
)
{
console
.
warn
(
'"topics" is deprecated, use "topic" instead'
);
}
// evaluate lazy properties
options
=
{
to
:
options
.
to
,
topic
:
options
.
topic
,
...
...
@@ -46,7 +49,11 @@ var Filter = function(options, impl) {
skip
:
options
.
skip
,
address
:
options
.
address
};
}
this
.
impl
=
impl
;
this
.
callbacks
=
[];
this
.
id
=
impl
.
newFilter
(
options
);
web3
.
provider
.
startPolling
({
call
:
impl
.
changed
,
args
:
[
this
.
id
]},
this
.
id
,
this
.
trigger
.
bind
(
this
));
...
...
lib/web3.js
View file @
995861de
...
...
@@ -278,8 +278,11 @@ var web3 = {
return
ret
;
};
},
watch
:
function
(
params
)
{
return
new
web3
.
filter
(
params
,
ethWatch
);
/// @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
)
{
return
new
web3
.
filter
(
filter
,
indexed
,
ethWatch
);
}
},
...
...
@@ -288,8 +291,11 @@ var web3 = {
/// shh object prototype
shh
:
{
watch
:
function
(
params
)
{
return
new
web3
.
filter
(
params
,
shhWatch
);
/// @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
)
{
return
new
web3
.
filter
(
filter
,
indexed
,
shhWatch
);
}
},
...
...
test/event.js
View file @
995861de
...
...
@@ -2,7 +2,7 @@ var assert = require('assert');
var
event
=
require
(
'../lib/event.js'
);
describe
(
'event'
,
function
()
{
it
(
'should create
filter input object from given
'
,
function
()
{
it
(
'should create
basic filter input object
'
,
function
()
{
// given
var
address
=
'0x012345'
;
...
...
@@ -14,9 +14,37 @@ describe('event', function () {
// then
assert
.
equal
(
result
.
address
,
address
);
assert
.
equal
(
result
.
topic
s
.
length
,
1
);
assert
.
equal
(
result
.
topic
s
[
0
],
signature
);
assert
.
equal
(
result
.
topic
.
length
,
1
);
assert
.
equal
(
result
.
topic
[
0
],
signature
);
});
it
(
'should create basic filter input object'
,
function
()
{
// given
var
address
=
'0x012345'
;
var
signature
=
'0x987654'
;
var
options
=
{
earliest
:
1
,
latest
:
2
,
offset
:
3
,
max
:
4
};
// when
var
impl
=
event
(
address
,
signature
);
var
result
=
impl
({},
options
);
// then
assert
.
equal
(
result
.
address
,
address
);
assert
.
equal
(
result
.
topic
.
length
,
1
);
assert
.
equal
(
result
.
topic
[
0
],
signature
);
assert
.
equal
(
result
.
earliest
,
options
.
earliest
);
assert
.
equal
(
result
.
latest
,
options
.
latest
);
assert
.
equal
(
result
.
offset
,
options
.
offset
);
assert
.
equal
(
result
.
max
,
options
.
max
);
});
});
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