Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit 27a8799

Browse files
committed
added eth_serpent, contract separated to another file
1 parent f6ee8e5 commit 27a8799

File tree

7 files changed

+81
-48
lines changed

7 files changed

+81
-48
lines changed

dist/ethereum.js

Lines changed: 8 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ethereum.js.map

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ethereum.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ web3.providers.WebSocketProvider = require('./lib/websocket');
33
web3.providers.HttpRpcProvider = require('./lib/httprpc');
44
web3.providers.QtProvider = require('./lib/qt');
55
web3.providers.AutoProvider = require('./lib/autoprovider');
6+
web3.contract = require('./lib/contract');
67

78
module.exports = web3;

index_qt.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var web3 = require('./lib/main');
22
web3.providers.QtProvider = require('./lib/qt');
3+
web3.contract = require('./lib/contract');
34

45
module.exports = web3;

lib/contract.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
This file is part of ethereum.js.
3+
4+
ethereum.js is free software: you can redistribute it and/or modify
5+
it under the terms of the GNU Lesser General Public License as published by
6+
the Free Software Foundation, either version 3 of the License, or
7+
(at your option) any later version.
8+
9+
ethereum.js is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
GNU Lesser General Public License for more details.
13+
14+
You should have received a copy of the GNU Lesser General Public License
15+
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
/** @file contract.js
18+
* @authors:
19+
* Marek Kotewicz <[email protected]>
20+
* @date 2014
21+
*/
22+
23+
if (process.env.NODE_ENV !== 'build') {
24+
var web3 = require('./web3'); // jshint ignore:line
25+
}
26+
var abi = require('./abi');
27+
28+
var contract = function (address, desc) {
29+
var inputParser = abi.inputParser(desc);
30+
var outputParser = abi.outputParser(desc);
31+
32+
var contract = {};
33+
34+
desc.forEach(function (method) {
35+
contract[method.name] = function () {
36+
var params = Array.prototype.slice.call(arguments);
37+
var parsed = inputParser[method.name].apply(null, params);
38+
39+
var onSuccess = function (result) {
40+
return outputParser[method.name](result);
41+
};
42+
43+
return {
44+
call: function (extra) {
45+
extra = extra || {};
46+
extra.to = address;
47+
extra.data = parsed;
48+
return web3.eth.call(extra).then(onSuccess);
49+
},
50+
transact: function (extra) {
51+
extra = extra || {};
52+
extra.to = address;
53+
extra.data = parsed;
54+
return web3.eth.transact(extra).then(onSuccess);
55+
}
56+
};
57+
};
58+
});
59+
60+
return contract;
61+
};
62+
63+
module.exports = contract;

lib/main.js

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
* @date 2014
2323
*/
2424

25-
var abi = require('./abi');
26-
2725
function flattenPromise (obj) {
2826
if (obj instanceof Promise) {
2927
return Promise.resolve(obj);
@@ -89,7 +87,8 @@ var ethMethods = function () {
8987
{ name: 'uncle', call: uncleCall },
9088
{ name: 'compilers', call: 'eth_compilers' },
9189
{ name: 'lll', call: 'eth_lll' },
92-
{ name: 'solidity', call: 'eth_solidity' }
90+
{ name: 'solidity', call: 'eth_solidity' },
91+
{ name: 'serpent', call: 'eth_serpent' }
9392
];
9493
return methods;
9594
};
@@ -455,40 +454,5 @@ function messageHandler(data) {
455454
}
456455
}
457456

458-
web3.contract = function (address, desc) {
459-
var inputParser = abi.inputParser(desc);
460-
var outputParser = abi.outputParser(desc);
461-
462-
var contract = {};
463-
464-
desc.forEach(function (method) {
465-
contract[method.name] = function () {
466-
var params = Array.prototype.slice.call(arguments);
467-
var parsed = inputParser[method.name].apply(null, params);
468-
469-
var onSuccess = function (result) {
470-
return outputParser[method.name](result);
471-
};
472-
473-
return {
474-
call: function (extra) {
475-
extra = extra || {};
476-
extra.to = address;
477-
extra.data = parsed;
478-
return web3.eth.call(extra).then(onSuccess);
479-
},
480-
transact: function (extra) {
481-
extra = extra || {};
482-
extra.to = address;
483-
extra.data = parsed;
484-
return web3.eth.transact(extra).then(onSuccess);
485-
}
486-
};
487-
};
488-
});
489-
490-
return contract;
491-
};
492-
493457
module.exports = web3;
494458

0 commit comments

Comments
 (0)