Commit 3b1d055b authored by yann300's avatar yann300

use txRunner instead of udapp

parent e969f57f
...@@ -4,30 +4,48 @@ module.exports = { ...@@ -4,30 +4,48 @@ module.exports = {
/** /**
* deploy the given contract * deploy the given contract
* *
* @param {String} from - sender address
* @param {String} data - data to send with the transaction ( return of txFormat.buildData(...) ). * @param {String} data - data to send with the transaction ( return of txFormat.buildData(...) ).
* @param {Object} udapp - udapp. * @param {String} value - decimal representation of value.
* @param {Function} callback - callback. * @param {String} gasLimit - decimal representation of gas limit.
* @param {Object} txRunner - TxRunner.js instance
* @param {Object} callbacks - { confirmationCb, gasEstimationForceSend, promptCb }
* [validate transaction] confirmationCb (network, tx, gasEstimation, continueTxExecution, cancelCb)
* [transaction failed, force send] gasEstimationForceSend (error, continueTxExecution, cancelCb)
* [personal mode enabled, need password to continue] promptCb (okCb, cancelCb)
* @param {Function} finalCallback - last callback.
*/ */
createContract: function (data, udapp, callback) { createContract: function (from, data, value, gasLimit, txRunner, callbacks, finalCallback) {
udapp.runTx({data: data, useCall: false}, (error, txResult) => { if (!callbacks.confirmationCb || !callbacks.gasEstimationForceSend || !callbacks.promptCb) {
return finalCallback('all the callbacks must have been defined')
}
var tx = { from: from, to: null, data: data, useCall: false, value: value, gasLimit: gasLimit }
txRunner.rawRun(tx, callbacks.confirmationCb, callbacks.gasEstimationForceSend, callbacks.promptCb, (error, txResult) => {
// see universaldapp.js line 660 => 700 to check possible values of txResult (error case) // see universaldapp.js line 660 => 700 to check possible values of txResult (error case)
callback(error, txResult) finalCallback(error, txResult)
}) })
}, },
/** /**
* call the current given contract * call the current given contract ! that will create a transaction !
* *
* @param {String} to - address of the contract to call. * @param {String} from - sender address
* @param {String} to - recipient address
* @param {String} data - data to send with the transaction ( return of txFormat.buildData(...) ). * @param {String} data - data to send with the transaction ( return of txFormat.buildData(...) ).
* @param {Object} funAbi - abi definition of the function to call. * @param {String} value - decimal representation of value.
* @param {Object} udapp - udapp. * @param {String} gasLimit - decimal representation of gas limit.
* @param {Function} callback - callback. * @param {Object} txRunner - TxRunner.js instance
* @param {Object} callbacks - { confirmationCb, gasEstimationForceSend, promptCb }
* [validate transaction] confirmationCb (network, tx, gasEstimation, continueTxExecution, cancelCb)
* [transaction failed, force send] gasEstimationForceSend (error, continueTxExecution, cancelCb)
* [personal mode enabled, need password to continue] promptCb (okCb, cancelCb)
* @param {Function} finalCallback - last callback.
*/ */
callFunction: function (to, data, funAbi, udapp, callback) { callFunction: function (from, to, data, value, gasLimit, funAbi, txRunner, callbacks, finalCallback) {
udapp.runTx({to: to, data: data, useCall: funAbi.constant}, (error, txResult) => { var tx = { from: from, to: to, data: data, useCall: false, value: value, gasLimit: gasLimit }
txRunner.rawRun(tx, callbacks.confirmationCb, callbacks.gasEstimationForceSend, callbacks.promptCb, (error, txResult) => {
// see universaldapp.js line 660 => 700 to check possible values of txResult (error case) // see universaldapp.js line 660 => 700 to check possible values of txResult (error case)
callback(error, txResult) finalCallback(error, txResult)
}) })
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment