use txRunner instead of udapp

pull/7/head
yann300 7 years ago
parent e969f57fb6
commit 3b1d055b16
  1. 44
      remix-lib/src/execution/txExecution.js

@ -4,30 +4,48 @@ module.exports = {
/**
* deploy the given contract
*
* @param {String} from - sender address
* @param {String} data - data to send with the transaction ( return of txFormat.buildData(...) ).
* @param {Object} udapp - udapp.
* @param {Function} callback - callback.
* @param {String} value - decimal representation of value.
* @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) {
udapp.runTx({data: data, useCall: false}, (error, txResult) => {
createContract: function (from, data, value, gasLimit, txRunner, callbacks, finalCallback) {
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)
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 {Object} funAbi - abi definition of the function to call.
* @param {Object} udapp - udapp.
* @param {Function} callback - callback.
* @param {String} value - decimal representation of value.
* @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.
*/
callFunction: function (to, data, funAbi, udapp, callback) {
udapp.runTx({to: to, data: data, useCall: funAbi.constant}, (error, txResult) => {
callFunction: function (from, to, data, value, gasLimit, funAbi, txRunner, callbacks, finalCallback) {
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)
callback(error, txResult)
finalCallback(error, txResult)
})
},

Loading…
Cancel
Save