|
|
|
@ -1,7 +1,6 @@ |
|
|
|
|
'use strict' |
|
|
|
|
import { ethers } from 'ethers' |
|
|
|
|
|
|
|
|
|
module.exports = { |
|
|
|
|
/** |
|
|
|
|
* deploy the given contract |
|
|
|
|
* |
|
|
|
@ -16,7 +15,7 @@ module.exports = { |
|
|
|
|
* [personal mode enabled, need password to continue] promptCb (okCb, cancelCb) |
|
|
|
|
* @param {Function} finalCallback - last callback. |
|
|
|
|
*/ |
|
|
|
|
createContract: function (from, data, value, gasLimit, txRunner, callbacks, finalCallback) { |
|
|
|
|
export function createContract (from, data, value, gasLimit, txRunner, callbacks, finalCallback) { |
|
|
|
|
if (!callbacks.confirmationCb || !callbacks.gasEstimationForceSend || !callbacks.promptCb) { |
|
|
|
|
return finalCallback('all the callbacks must have been defined') |
|
|
|
|
} |
|
|
|
@ -25,7 +24,7 @@ module.exports = { |
|
|
|
|
// see universaldapp.js line 660 => 700 to check possible values of txResult (error case)
|
|
|
|
|
finalCallback(error, txResult) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* call the current given contract ! that will create a transaction ! |
|
|
|
@ -42,14 +41,14 @@ module.exports = { |
|
|
|
|
* [personal mode enabled, need password to continue] promptCb (okCb, cancelCb) |
|
|
|
|
* @param {Function} finalCallback - last callback. |
|
|
|
|
*/ |
|
|
|
|
callFunction: function (from, to, data, value, gasLimit, funAbi, txRunner, callbacks, finalCallback) { |
|
|
|
|
export function callFunction (from, to, data, value, gasLimit, funAbi, txRunner, callbacks, finalCallback) { |
|
|
|
|
const useCall = funAbi.stateMutability === 'view' || funAbi.stateMutability === 'pure' || funAbi.constant |
|
|
|
|
const tx = { from, to, data, useCall, value, 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)
|
|
|
|
|
finalCallback(error, txResult) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* check if the vm has errored |
|
|
|
@ -57,7 +56,7 @@ module.exports = { |
|
|
|
|
* @param {Object} txResult - the value returned by the vm |
|
|
|
|
* @return {Object} - { error: true/false, message: DOMNode } |
|
|
|
|
*/ |
|
|
|
|
checkVMError: function (txResult) { |
|
|
|
|
export function checkVMError (txResult) { |
|
|
|
|
const errorCode = { |
|
|
|
|
OUT_OF_GAS: 'out of gas', |
|
|
|
|
STACK_UNDERFLOW: 'stack underflow', |
|
|
|
@ -105,5 +104,5 @@ module.exports = { |
|
|
|
|
ret.message = `${error}${exceptionError}${msg}\tDebug the transaction to get more information.` |
|
|
|
|
return ret |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|