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
842b8cf3
Commit
842b8cf3
authored
Jan 29, 2015
by
Marek Kotewicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
event.js
parent
61e8ae2f
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
106 additions
and
10 deletions
+106
-10
ethereum.js
dist/ethereum.js
+15
-3
ethereum.js.map
dist/ethereum.js.map
+2
-2
ethereum.min.js
dist/ethereum.min.js
+1
-1
contract.html
example/contract.html
+1
-0
natspec_contract.html
example/natspec_contract.html
+1
-0
contract.js
lib/contract.js
+15
-3
event.js
lib/event.js
+16
-0
eth.contract.js
test/eth.contract.js
+30
-1
eth.event.js
test/eth.event.js
+0
-0
event.js
test/event.js
+25
-0
No files found.
dist/ethereum.js
View file @
842b8cf3
...
...
@@ -451,7 +451,7 @@ module.exports = {
* @date 2014
*/
var
web3
=
require
(
'./web3'
);
// jshint ignore:line
var
web3
=
require
(
'./web3'
);
var
abi
=
require
(
'./abi'
);
/**
...
...
@@ -493,7 +493,17 @@ var contract = function (address, desc) {
var
inputParser
=
abi
.
inputParser
(
desc
);
var
outputParser
=
abi
.
outputParser
(
desc
);
var
result
=
{};
var
result
=
{
address
:
address
,
};
Object
.
defineProperty
(
result
,
'topics'
,
{
get
:
function
()
{
return
abi
.
filterEvents
(
desc
).
map
(
function
(
event
)
{
return
abi
.
methodSignature
(
event
.
name
);
});
}
});
result
.
call
=
function
(
options
)
{
result
.
_isTransact
=
false
;
...
...
@@ -579,11 +589,13 @@ var contract = function (address, desc) {
var
displayName
=
abi
.
methodDisplayName
(
event
.
name
);
var
typeName
=
abi
.
methodTypeName
(
event
.
name
);
var
impl
=
function
(
options
)
{
var
signature
=
abi
.
methodSignature
(
event
.
name
);
var
o
=
options
||
{};
o
.
address
=
o
.
address
||
address
;
o
.
topics
=
o
.
topics
||
[];
o
.
topics
.
push
(
abi
.
methodSignature
(
event
.
name
)
);
o
.
topics
.
push
(
signature
);
return
web3
.
eth
.
watch
(
o
);
};
...
...
dist/ethereum.js.map
View file @
842b8cf3
This diff is collapsed.
Click to expand it.
dist/ethereum.min.js
View file @
842b8cf3
This diff is collapsed.
Click to expand it.
example/contract.html
View file @
842b8cf3
...
...
@@ -20,6 +20,7 @@
// contract description, this will be autogenerated somehow
var
desc
=
[{
"name"
:
"multiply(uint256)"
,
"type"
:
"function"
,
"inputs"
:
[
{
"name"
:
"a"
,
...
...
example/natspec_contract.html
View file @
842b8cf3
...
...
@@ -21,6 +21,7 @@
// contract description, this will be autogenerated somehow
var
desc
=
[{
"name"
:
"multiply(uint256)"
,
"type"
:
"function"
,
"inputs"
:
[
{
"name"
:
"a"
,
...
...
lib/contract.js
View file @
842b8cf3
...
...
@@ -20,7 +20,7 @@
* @date 2014
*/
var
web3
=
require
(
'./web3'
);
// jshint ignore:line
var
web3
=
require
(
'./web3'
);
var
abi
=
require
(
'./abi'
);
/**
...
...
@@ -62,7 +62,17 @@ var contract = function (address, desc) {
var
inputParser
=
abi
.
inputParser
(
desc
);
var
outputParser
=
abi
.
outputParser
(
desc
);
var
result
=
{};
var
result
=
{
address
:
address
,
};
Object
.
defineProperty
(
result
,
'topics'
,
{
get
:
function
()
{
return
abi
.
filterEvents
(
desc
).
map
(
function
(
event
)
{
return
abi
.
methodSignature
(
event
.
name
);
});
}
});
result
.
call
=
function
(
options
)
{
result
.
_isTransact
=
false
;
...
...
@@ -148,11 +158,13 @@ var contract = function (address, desc) {
var
displayName
=
abi
.
methodDisplayName
(
event
.
name
);
var
typeName
=
abi
.
methodTypeName
(
event
.
name
);
var
impl
=
function
(
options
)
{
var
signature
=
abi
.
methodSignature
(
event
.
name
);
var
o
=
options
||
{};
o
.
address
=
o
.
address
||
address
;
o
.
topics
=
o
.
topics
||
[];
o
.
topics
.
push
(
abi
.
methodSignature
(
event
.
name
)
);
o
.
topics
.
push
(
signature
);
return
web3
.
eth
.
watch
(
o
);
};
...
...
lib/event.js
0 → 100644
View file @
842b8cf3
var
abi
=
require
(
'./abi'
);
var
implementationOfEvent
=
function
(
event
,
address
,
signature
)
{
return
function
(
options
)
{
var
o
=
options
||
{};
o
.
address
=
o
.
address
||
address
;
o
.
topics
=
o
.
topics
||
[];
o
.
topics
.
push
(
signature
);
return
o
;
};
};
module
.
exports
=
implementationOfEvent
;
test/eth.contract.js
View file @
842b8cf3
...
...
@@ -146,7 +146,6 @@ describe('contract', function() {
// given
var
description
=
[{
"name"
:
"test(uint256)"
,
"type"
:
"event"
,
"inputs"
:
[{
"name"
:
"a"
,
"type"
:
"uint256"
...
...
@@ -168,5 +167,35 @@ describe('contract', function() {
assert
.
equal
(
'undefined'
,
typeof
con
.
test
);
});
it
(
'should create contract with one event'
,
function
()
{
// given
var
description
=
[{
"name"
:
"test"
,
"type"
:
"event"
,
"inputs"
:
[{
"name"
:
"a"
,
"type"
:
"uint256"
}
],
"outputs"
:
[
{
"name"
:
"d"
,
"type"
:
"uint256"
}
]
}];
// when
var
con
=
contract
(
null
,
description
);
// then
assert
.
equal
(
'function'
,
typeof
con
.
test
);
assert
.
equal
(
'function'
,
typeof
con
.
test
[
'uint256'
]);
});
});
test/eth.event.js
deleted
100644 → 0
View file @
61e8ae2f
test/event.js
0 → 100644
View file @
842b8cf3
var
assert
=
require
(
'assert'
);
var
event
=
require
(
'../lib/event.js'
);
describe
(
'event'
,
function
()
{
it
(
'should create filter input object from given'
,
function
()
{
// given
var
address
=
'0x012345'
;
var
signature
=
'0x987654'
;
var
e
=
{
name
:
'test'
,
type
:
'event'
,
};
// when
var
impl
=
event
(
e
,
address
,
signature
);
var
result
=
impl
();
// then
assert
.
equal
(
result
.
address
,
address
);
assert
.
equal
(
result
.
topics
.
length
,
1
);
assert
.
equal
(
result
.
topics
[
0
],
signature
);
});
});
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