Browse Source

common changes in ethereum.js

cl-refactor
Marek Kotewicz 10 years ago
parent
commit
5d55344f3a
  1. 111
      libjsqrc/ethereum.js
  2. 2
      libqethereum/QEthereum.h

111
libjsqrc/ethereum.js

@ -319,6 +319,71 @@ module.exports = AutoProvider;
You should have received a copy of the GNU Lesser General Public License
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file contract.js
* @authors:
* Marek Kotewicz <marek@ethdev.com>
* @date 2014
*/
if ("build" !== 'build') {/*
var web3 = require('./web3'); // jshint ignore:line
*/}
var abi = require('./abi');
var contract = function (address, desc) {
var inputParser = abi.inputParser(desc);
var outputParser = abi.outputParser(desc);
var contract = {};
desc.forEach(function (method) {
contract[method.name] = function () {
var params = Array.prototype.slice.call(arguments);
var parsed = inputParser[method.name].apply(null, params);
var onSuccess = function (result) {
return outputParser[method.name](result);
};
return {
call: function (extra) {
extra = extra || {};
extra.to = address;
extra.data = parsed;
return web3.eth.call(extra).then(onSuccess);
},
transact: function (extra) {
extra = extra || {};
extra.to = address;
extra.data = parsed;
return web3.eth.transact(extra).then(onSuccess);
}
};
};
});
return contract;
};
module.exports = contract;
},{"./abi":1}],4:[function(require,module,exports){
/*
This file is part of ethereum.js.
ethereum.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ethereum.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file httprpc.js
* @authors:
* Marek Kotewicz <marek@ethdev.com>
@ -397,7 +462,7 @@ Object.defineProperty(HttpRpcProvider.prototype, "onmessage", {
module.exports = HttpRpcProvider;
},{}],4:[function(require,module,exports){
},{}],5:[function(require,module,exports){
/*
This file is part of ethereum.js.
@ -422,8 +487,6 @@ module.exports = HttpRpcProvider;
* @date 2014
*/
var abi = require('./abi');
function flattenPromise (obj) {
if (obj instanceof Promise) {
return Promise.resolve(obj);
@ -856,45 +919,10 @@ function messageHandler(data) {
}
}
web3.contract = function (address, desc) {
var inputParser = abi.inputParser(desc);
var outputParser = abi.outputParser(desc);
var contract = {};
desc.forEach(function (method) {
contract[method.name] = function () {
var params = Array.prototype.slice.call(arguments);
var parsed = inputParser[method.name].apply(null, params);
var onSuccess = function (result) {
return outputParser[method.name](result);
};
return {
call: function (extra) {
extra = extra || {};
extra.to = address;
extra.data = parsed;
return web3.eth.call(extra).then(onSuccess);
},
transact: function (extra) {
extra = extra || {};
extra.to = address;
extra.data = parsed;
return web3.eth.transact(extra).then(onSuccess);
}
};
};
});
return contract;
};
module.exports = web3;
},{"./abi":1}],5:[function(require,module,exports){
},{}],6:[function(require,module,exports){
/*
This file is part of ethereum.js.
@ -941,7 +969,7 @@ Object.defineProperty(QtProvider.prototype, "onmessage", {
module.exports = QtProvider;
},{}],6:[function(require,module,exports){
},{}],7:[function(require,module,exports){
/*
This file is part of ethereum.js.
@ -1025,10 +1053,11 @@ web3.providers.WebSocketProvider = require('./lib/websocket');
web3.providers.HttpRpcProvider = require('./lib/httprpc');
web3.providers.QtProvider = require('./lib/qt');
web3.providers.AutoProvider = require('./lib/autoprovider');
web3.contract = require('./lib/contract');
module.exports = web3;
},{"./lib/autoprovider":2,"./lib/httprpc":3,"./lib/main":4,"./lib/qt":5,"./lib/websocket":6}]},{},[])
},{"./lib/autoprovider":2,"./lib/contract":3,"./lib/httprpc":4,"./lib/main":5,"./lib/qt":6,"./lib/websocket":7}]},{},[])
//# sourceMappingURL=ethereum.js.map

2
libqethereum/QEthereum.h

@ -85,7 +85,7 @@ private:
_frame->addToJavaScriptWindowObject("_web3", qweb, QWebFrame::ScriptOwnership); \
_frame->addToJavaScriptWindowObject("env", _env, QWebFrame::QtOwnership); \
_frame->evaluateJavaScript(contentsOfQResource(":/js/es6-promise-2.0.0.js")); \
_frame->evaluateJavaScript(contentsOfQResource(":/js/ethereum.min.js")); \
_frame->evaluateJavaScript(contentsOfQResource(":/js/ethereum.js")); \
_frame->evaluateJavaScript(contentsOfQResource(":/js/setup.js")); \
}

Loading…
Cancel
Save