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
a5909d82
Commit
a5909d82
authored
Feb 03, 2015
by
Marek Kotewicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parsing events output
parent
1860b3df
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
69 additions
and
13 deletions
+69
-13
ethereum.js
dist/ethereum.js
+32
-4
ethereum.js.map
dist/ethereum.js.map
+4
-4
ethereum.min.js
dist/ethereum.min.js
+1
-1
contract.js
lib/contract.js
+9
-0
event.js
lib/event.js
+19
-3
filter.js
lib/filter.js
+4
-1
No files found.
dist/ethereum.js
View file @
a5909d82
...
...
@@ -391,6 +391,11 @@ var addFunctionsToContract = function (contract, desc, address) {
var
addEventRelatedPropertiesToContract
=
function
(
contract
,
desc
,
address
)
{
contract
.
address
=
address
;
contract
.
_onWatchEventResult
=
function
(
data
)
{
var
matchingEvent
=
event
.
getMatchingEvent
(
utils
.
filterEvents
(
desc
));
var
parser
=
eventImpl
.
outputParser
(
matchingEvent
);
return
parser
(
data
);
};
Object
.
defineProperty
(
contract
,
'topic'
,
{
get
:
function
()
{
...
...
@@ -411,6 +416,10 @@ var addEventsToContract = function (contract, desc, address) {
var
signature
=
abi
.
eventSignatureFromAscii
(
e
.
name
);
var
event
=
eventImpl
.
inputParser
(
address
,
signature
,
e
);
var
o
=
event
.
apply
(
null
,
params
);
o
.
_onWatchEventResult
=
function
(
data
)
{
var
parser
=
eventImpl
.
outputParser
(
e
);
return
parser
(
data
);
};
return
web3
.
eth
.
watch
(
o
);
};
...
...
@@ -571,14 +580,18 @@ var getArgumentsObject = function (inputs, indexed, notIndexed) {
},
{});
};
var
outputParser
=
function
(
event
)
{
return
function
(
output
)
{
var
result
=
{
event
:
utils
.
extractDisplayName
(
event
.
name
),
number
:
output
.
number
number
:
output
.
number
,
args
:
{}
};
if
(
!
output
.
topic
)
{
return
result
;
}
var
indexedOutputs
=
filterInputs
(
event
.
inputs
,
true
);
var
indexedData
=
"0x"
+
output
.
topic
.
slice
(
1
,
output
.
topic
.
length
).
map
(
function
(
topic
)
{
return
topic
.
slice
(
2
);
}).
join
(
""
);
...
...
@@ -593,9 +606,21 @@ var outputParser = function (event) {
};
};
var
getMatchingEvent
=
function
(
events
,
payload
)
{
for
(
var
i
=
0
;
i
<
events
.
length
;
i
++
)
{
var
signature
=
abi
.
eventSignatureFromAscii
(
events
[
i
].
name
);
if
(
signature
===
payload
.
topic
[
0
])
{
return
events
[
i
];
}
}
return
undefined
;
};
module
.
exports
=
{
inputParser
:
inputParser
,
outputParser
:
outputParser
outputParser
:
outputParser
,
getMatchingEvent
:
getMatchingEvent
};
...
...
@@ -638,6 +663,8 @@ var Filter = function(options, impl) {
if
(
options
.
topics
)
{
console
.
warn
(
'"topics" is deprecated, use "topic" instead'
);
}
this
.
_onWatchResult
=
options
.
_onWatchEventResult
;
// evaluate lazy properties
options
=
{
...
...
@@ -673,7 +700,8 @@ Filter.prototype.changed = function(callback) {
Filter
.
prototype
.
trigger
=
function
(
messages
)
{
for
(
var
i
=
0
;
i
<
this
.
callbacks
.
length
;
i
++
)
{
for
(
var
j
=
0
;
j
<
messages
.
length
;
j
++
)
{
this
.
callbacks
[
i
].
call
(
this
,
messages
[
j
]);
var
message
=
this
.
_onWatchResult
?
this
.
_onWatchResult
(
messages
[
j
])
:
messages
[
j
];
this
.
callbacks
[
i
].
call
(
this
,
message
);
}
}
};
...
...
dist/ethereum.js.map
View file @
a5909d82
This diff is collapsed.
Click to expand it.
dist/ethereum.min.js
View file @
a5909d82
This diff is collapsed.
Click to expand it.
lib/contract.js
View file @
a5909d82
...
...
@@ -120,6 +120,11 @@ var addFunctionsToContract = function (contract, desc, address) {
var
addEventRelatedPropertiesToContract
=
function
(
contract
,
desc
,
address
)
{
contract
.
address
=
address
;
contract
.
_onWatchEventResult
=
function
(
data
)
{
var
matchingEvent
=
event
.
getMatchingEvent
(
utils
.
filterEvents
(
desc
));
var
parser
=
eventImpl
.
outputParser
(
matchingEvent
);
return
parser
(
data
);
};
Object
.
defineProperty
(
contract
,
'topic'
,
{
get
:
function
()
{
...
...
@@ -140,6 +145,10 @@ var addEventsToContract = function (contract, desc, address) {
var
signature
=
abi
.
eventSignatureFromAscii
(
e
.
name
);
var
event
=
eventImpl
.
inputParser
(
address
,
signature
,
e
);
var
o
=
event
.
apply
(
null
,
params
);
o
.
_onWatchEventResult
=
function
(
data
)
{
var
parser
=
eventImpl
.
outputParser
(
e
);
return
parser
(
data
);
};
return
web3
.
eth
.
watch
(
o
);
};
...
...
lib/event.js
View file @
a5909d82
...
...
@@ -90,14 +90,18 @@ var getArgumentsObject = function (inputs, indexed, notIndexed) {
},
{});
};
var
outputParser
=
function
(
event
)
{
return
function
(
output
)
{
var
result
=
{
event
:
utils
.
extractDisplayName
(
event
.
name
),
number
:
output
.
number
number
:
output
.
number
,
args
:
{}
};
if
(
!
output
.
topic
)
{
return
result
;
}
var
indexedOutputs
=
filterInputs
(
event
.
inputs
,
true
);
var
indexedData
=
"0x"
+
output
.
topic
.
slice
(
1
,
output
.
topic
.
length
).
map
(
function
(
topic
)
{
return
topic
.
slice
(
2
);
}).
join
(
""
);
...
...
@@ -112,8 +116,20 @@ var outputParser = function (event) {
};
};
var
getMatchingEvent
=
function
(
events
,
payload
)
{
for
(
var
i
=
0
;
i
<
events
.
length
;
i
++
)
{
var
signature
=
abi
.
eventSignatureFromAscii
(
events
[
i
].
name
);
if
(
signature
===
payload
.
topic
[
0
])
{
return
events
[
i
];
}
}
return
undefined
;
};
module
.
exports
=
{
inputParser
:
inputParser
,
outputParser
:
outputParser
outputParser
:
outputParser
,
getMatchingEvent
:
getMatchingEvent
};
lib/filter.js
View file @
a5909d82
...
...
@@ -36,6 +36,8 @@ var Filter = function(options, impl) {
if
(
options
.
topics
)
{
console
.
warn
(
'"topics" is deprecated, use "topic" instead'
);
}
this
.
_onWatchResult
=
options
.
_onWatchEventResult
;
// evaluate lazy properties
options
=
{
...
...
@@ -71,7 +73,8 @@ Filter.prototype.changed = function(callback) {
Filter
.
prototype
.
trigger
=
function
(
messages
)
{
for
(
var
i
=
0
;
i
<
this
.
callbacks
.
length
;
i
++
)
{
for
(
var
j
=
0
;
j
<
messages
.
length
;
j
++
)
{
this
.
callbacks
[
i
].
call
(
this
,
messages
[
j
]);
var
message
=
this
.
_onWatchResult
?
this
.
_onWatchResult
(
messages
[
j
])
:
messages
[
j
];
this
.
callbacks
[
i
].
call
(
this
,
message
);
}
}
};
...
...
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