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
375ca542
Commit
375ca542
authored
Jan 22, 2015
by
Marek Kotewicz
Browse files
Options
Browse Files
Download
Plain Diff
Merge commit '8e3ba3a4285cc7e902a018196b3849df56944dd0' into natspec
parents
d6a92b18
0202b05a
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
88 additions
and
66 deletions
+88
-66
ethereum.js
dist/ethereum.js
+42
-31
ethereum.js.map
dist/ethereum.js.map
+2
-2
ethereum.min.js
dist/ethereum.min.js
+1
-1
contract.html
example/contract.html
+1
-1
contract.js
lib/contract.js
+42
-31
No files found.
dist/ethereum.js
View file @
375ca542
...
...
@@ -447,18 +447,20 @@ var abi = require('./abi');
*
* var myContract = web3.eth.contract('0x0123123121', abi); // creation of contract object
*
* myContract.myMethod('this is test string param for call').call(); // myMethod call
* myContract.myMethod('this is test string param for transact').transact() // myMethod transact
* myContract.myMethod('this is test string param for call'); // myMethod call (implicit, default)
* myContract.myMethod('this is test string param for call').call(); // myMethod call (explicit)
* myContract.transact().myMethod('this is test string param for transact'); // myMethod transact
*
* @param address - address of the contract, which should be called
* @param desc - abi json description of the contract, which is being created
* @returns contract object
*/
var
contract
=
function
(
address
,
desc
)
{
var
contract
=
function
contract
(
address
,
desc
)
{
var
inputParser
=
abi
.
inputParser
(
desc
);
var
outputParser
=
abi
.
outputParser
(
desc
);
var
contrac
t
=
{};
var
resul
t
=
{};
desc
.
forEach
(
function
(
method
)
{
...
...
@@ -467,44 +469,53 @@ var contract = function (address, desc) {
var
impl
=
function
()
{
var
params
=
Array
.
prototype
.
slice
.
call
(
arguments
);
var
parsed
=
inputParser
[
displayName
][
typeName
].
apply
(
null
,
params
);
var
signature
=
abi
.
methodSignature
(
method
.
name
);
var
parsed
=
inputParser
[
displayName
][
typeName
].
apply
(
null
,
params
);
return
{
call
:
function
(
extra
)
{
extra
=
extra
||
{};
extra
.
to
=
address
;
extra
.
data
=
signature
+
parsed
;
var
result
=
web3
.
eth
.
call
(
extra
);
return
outputParser
[
displayName
][
typeName
](
result
);
},
transact
:
function
(
extra
)
{
extra
=
extra
||
{};
extra
.
to
=
address
;
extra
.
data
=
signature
+
parsed
;
/// it's used by natspec.js
/// TODO: figure a better way to solve this
web3
.
_currentContractAbi
=
desc
;
web3
.
_currentContractAddress
=
address
;
var
result
=
web3
.
eth
.
transact
(
extra
);
return
outputParser
[
displayName
][
typeName
](
result
);
}
};
var
options
=
contract
.
_options
||
{};
options
.
to
=
address
;
options
.
data
=
signature
+
parsed
;
var
output
=
""
;
if
(
contract
.
_isTransact
)
{
// it's used byt natspec.js
// TODO: figure out better way to solve this
web3
.
_currentContractAbi
=
desc
;
web3
.
_currentContractAddress
=
address
;
output
=
web3
.
eth
.
transact
(
options
);
}
else
{
output
=
web3
.
eth
.
call
(
options
);
}
return
outputParser
[
displayName
][
typeName
](
output
);
};
if
(
contrac
t
[
displayName
]
===
undefined
)
{
contrac
t
[
displayName
]
=
impl
;
if
(
resul
t
[
displayName
]
===
undefined
)
{
resul
t
[
displayName
]
=
impl
;
}
contract
[
displayName
][
typeName
]
=
impl
;
result
[
displayName
][
typeName
]
=
impl
;
});
return
result
;
};
var
transact
=
function
(
options
)
{
contract
.
_isTransact
=
true
;
contract
.
_options
=
options
;
return
contract
;
};
var
call
=
function
(
options
)
{
contract
.
_isTransact
=
false
;
contract
.
_options
=
options
;
return
contract
;
};
contract
.
transact
=
transact
;
contract
.
call
=
call
;
module
.
exports
=
contract
;
...
...
dist/ethereum.js.map
View file @
375ca542
This diff is collapsed.
Click to expand it.
dist/ethereum.min.js
View file @
375ca542
This diff is collapsed.
Click to expand it.
example/contract.html
View file @
375ca542
...
...
@@ -53,7 +53,7 @@
var
param
=
parseInt
(
document
.
getElementById
(
'value'
).
value
);
// call the contract
var
res
=
contract
.
multiply
(
param
)
.
call
()
;
var
res
=
contract
.
multiply
(
param
);
document
.
getElementById
(
'result'
).
innerText
=
res
[
0
];
}
...
...
lib/contract.js
View file @
375ca542
...
...
@@ -36,18 +36,20 @@ var abi = require('./abi');
*
* var myContract = web3.eth.contract('0x0123123121', abi); // creation of contract object
*
* myContract.myMethod('this is test string param for call').call(); // myMethod call
* myContract.myMethod('this is test string param for transact').transact() // myMethod transact
* myContract.myMethod('this is test string param for call'); // myMethod call (implicit, default)
* myContract.myMethod('this is test string param for call').call(); // myMethod call (explicit)
* myContract.transact().myMethod('this is test string param for transact'); // myMethod transact
*
* @param address - address of the contract, which should be called
* @param desc - abi json description of the contract, which is being created
* @returns contract object
*/
var
contract
=
function
(
address
,
desc
)
{
var
contract
=
function
contract
(
address
,
desc
)
{
var
inputParser
=
abi
.
inputParser
(
desc
);
var
outputParser
=
abi
.
outputParser
(
desc
);
var
contrac
t
=
{};
var
resul
t
=
{};
desc
.
forEach
(
function
(
method
)
{
...
...
@@ -56,43 +58,52 @@ var contract = function (address, desc) {
var
impl
=
function
()
{
var
params
=
Array
.
prototype
.
slice
.
call
(
arguments
);
var
parsed
=
inputParser
[
displayName
][
typeName
].
apply
(
null
,
params
);
var
signature
=
abi
.
methodSignature
(
method
.
name
);
var
parsed
=
inputParser
[
displayName
][
typeName
].
apply
(
null
,
params
);
var
options
=
contract
.
_options
||
{};
options
.
to
=
address
;
options
.
data
=
signature
+
parsed
;
var
output
=
""
;
if
(
contract
.
_isTransact
)
{
// it's used byt natspec.js
// TODO: figure out better way to solve this
web3
.
_currentContractAbi
=
desc
;
web3
.
_currentContractAddress
=
address
;
output
=
web3
.
eth
.
transact
(
options
);
}
else
{
output
=
web3
.
eth
.
call
(
options
);
}
return
{
call
:
function
(
extra
)
{
extra
=
extra
||
{};
extra
.
to
=
address
;
extra
.
data
=
signature
+
parsed
;
var
result
=
web3
.
eth
.
call
(
extra
);
return
outputParser
[
displayName
][
typeName
](
result
);
},
transact
:
function
(
extra
)
{
extra
=
extra
||
{};
extra
.
to
=
address
;
extra
.
data
=
signature
+
parsed
;
/// it's used by natspec.js
/// TODO: figure a better way to solve this
web3
.
_currentContractAbi
=
desc
;
web3
.
_currentContractAddress
=
address
;
var
result
=
web3
.
eth
.
transact
(
extra
);
return
outputParser
[
displayName
][
typeName
](
result
);
}
};
return
outputParser
[
displayName
][
typeName
](
output
);
};
if
(
contrac
t
[
displayName
]
===
undefined
)
{
contrac
t
[
displayName
]
=
impl
;
if
(
resul
t
[
displayName
]
===
undefined
)
{
resul
t
[
displayName
]
=
impl
;
}
contract
[
displayName
][
typeName
]
=
impl
;
result
[
displayName
][
typeName
]
=
impl
;
});
return
result
;
};
var
transact
=
function
(
options
)
{
contract
.
_isTransact
=
true
;
contract
.
_options
=
options
;
return
contract
;
};
var
call
=
function
(
options
)
{
contract
.
_isTransact
=
false
;
contract
.
_options
=
options
;
return
contract
;
};
contract
.
transact
=
transact
;
contract
.
call
=
call
;
module
.
exports
=
contract
;
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