|
|
|
@ -4,20 +4,14 @@ |
|
|
|
|
var $ = require('jquery') |
|
|
|
|
var yo = require('yo-yo') |
|
|
|
|
var ethJSUtil = require('ethereumjs-util') |
|
|
|
|
var Web3 = require('web3') |
|
|
|
|
var BN = ethJSUtil.BN |
|
|
|
|
var helper = require('../../lib/helper') |
|
|
|
|
var copyToClipboard = require('./copy-to-clipboard') |
|
|
|
|
var css = require('../../universal-dapp-styles') |
|
|
|
|
var MultiParamManager = require('./multiParamManager') |
|
|
|
|
var remixLib = require('remix-lib') |
|
|
|
|
var typeConversion = remixLib.execution.typeConversion |
|
|
|
|
var txExecution = remixLib.execution.txExecution |
|
|
|
|
var txFormat = remixLib.execution.txFormat |
|
|
|
|
|
|
|
|
|
var confirmDialog = require('./confirmDialog') |
|
|
|
|
var modalCustom = require('./modal-dialog-custom') |
|
|
|
|
var modalDialog = require('./modaldialog') |
|
|
|
|
var TreeView = require('./TreeView') |
|
|
|
|
|
|
|
|
|
function UniversalDAppUI (udapp, logCallback, executionContext) { |
|
|
|
@ -126,7 +120,7 @@ UniversalDAppUI.prototype.renderInstanceFromABI = function (contractABI, address |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
const calldataInput = yo` |
|
|
|
|
<input class="w-100 m-0" title="The Calldata to send to fallback function of the contract."> |
|
|
|
|
<input id="deployAndRunLLTxCalldata" class="w-100 m-0" title="The Calldata to send to fallback function of the contract."> |
|
|
|
|
` |
|
|
|
|
const llIError = yo` |
|
|
|
|
<label id="deployAndRunLLTxError" class="text-danger"></label> |
|
|
|
@ -201,95 +195,6 @@ UniversalDAppUI.prototype.renderInstanceFromABI = function (contractABI, address |
|
|
|
|
return instance |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
UniversalDAppUI.prototype.confirmationCb = function (network, tx, gasEstimation, continueTxExecution, cancelCb) { |
|
|
|
|
let self = this |
|
|
|
|
if (network.name !== 'Main') { |
|
|
|
|
return continueTxExecution(null) |
|
|
|
|
} |
|
|
|
|
var amount = Web3.utils.fromWei(typeConversion.toInt(tx.value), 'ether') |
|
|
|
|
var content = confirmDialog(tx, amount, gasEstimation, self.udapp, |
|
|
|
|
(gasPrice, cb) => { |
|
|
|
|
let txFeeText, priceStatus |
|
|
|
|
// TODO: this try catch feels like an anti pattern, can/should be
|
|
|
|
|
// removed, but for now keeping the original logic
|
|
|
|
|
try { |
|
|
|
|
var fee = Web3.utils.toBN(tx.gas).mul(Web3.utils.toBN(Web3.utils.toWei(gasPrice.toString(10), 'gwei'))) |
|
|
|
|
txFeeText = ' ' + Web3.utils.fromWei(fee.toString(10), 'ether') + ' Ether' |
|
|
|
|
priceStatus = true |
|
|
|
|
} catch (e) { |
|
|
|
|
txFeeText = ' Please fix this issue before sending any transaction. ' + e.message |
|
|
|
|
priceStatus = false |
|
|
|
|
} |
|
|
|
|
cb(txFeeText, priceStatus) |
|
|
|
|
}, |
|
|
|
|
(cb) => { |
|
|
|
|
self.executionContext.web3().eth.getGasPrice((error, gasPrice) => { |
|
|
|
|
const warnMessage = ' Please fix this issue before sending any transaction. ' |
|
|
|
|
if (error) { |
|
|
|
|
return cb('Unable to retrieve the current network gas price.' + warnMessage + error) |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
var gasPriceValue = Web3.utils.fromWei(gasPrice.toString(10), 'gwei') |
|
|
|
|
cb(null, gasPriceValue) |
|
|
|
|
} catch (e) { |
|
|
|
|
cb(warnMessage + e.message, null, false) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
modalDialog( |
|
|
|
|
'Confirm transaction', |
|
|
|
|
content, |
|
|
|
|
{ label: 'Confirm', |
|
|
|
|
fn: () => { |
|
|
|
|
self.udapp.config.setUnpersistedProperty( |
|
|
|
|
'doNotShowTransactionConfirmationAgain', |
|
|
|
|
content.querySelector('input#confirmsetting').checked |
|
|
|
|
) |
|
|
|
|
// TODO: check if this is check is still valid given the refactor
|
|
|
|
|
if (!content.gasPriceStatus) { |
|
|
|
|
cancelCb('Given gas price is not correct') |
|
|
|
|
} else { |
|
|
|
|
var gasPrice = Web3.utils.toWei(content.querySelector('#gasprice').value, 'gwei') |
|
|
|
|
continueTxExecution(gasPrice) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
label: 'Cancel', |
|
|
|
|
fn: () => { |
|
|
|
|
return cancelCb('Transaction canceled by user.') |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const continueCb = (error, continueTxExecution, cancelCb) => { |
|
|
|
|
if (error) { |
|
|
|
|
const msg = typeof error !== 'string' ? error.message : error |
|
|
|
|
modalDialog( |
|
|
|
|
'Gas estimation failed', |
|
|
|
|
yo` |
|
|
|
|
<div>Gas estimation errored with the following message (see below). |
|
|
|
|
The transaction execution will likely fail. Do you want to force sending? <br>${msg}</div> |
|
|
|
|
`,
|
|
|
|
|
{ |
|
|
|
|
label: 'Send Transaction', |
|
|
|
|
fn: () => continueTxExecution() |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
label: 'Cancel Transaction', |
|
|
|
|
fn: () => cancelCb() |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
} else { |
|
|
|
|
continueTxExecution() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const promptCb = (okCb, cancelCb) => { |
|
|
|
|
modalCustom.promptPassphrase('Passphrase requested', 'Personal mode is enabled. Please provide passphrase of account', '', okCb, cancelCb) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO this is used by renderInstance when a new instance is displayed.
|
|
|
|
|
// this returns a DOM element.
|
|
|
|
|