move dialog ui out of udapp logic

pull/1/head
Iuri Matias 6 years ago committed by yann300
parent 6de3a31d7c
commit d4042d3d93
  1. 22
      src/app/tabs/run-tab.js
  2. 23
      src/recorder.js
  3. 24
      src/universal-dapp-ui.js
  4. 34
      src/universal-dapp.js

@ -452,7 +452,27 @@ function contractDropdown (events, self) {
}
})
},
(error, continueTxExecution, cancelCb) => {
if (error) {
var 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()
}
},
(error, txResult) => {
if (!error) {
var isVM = executionContext.isVM()

@ -1,3 +1,4 @@
var yo = require('yo-yo')
var remixLib = require('remix-lib')
var EventManager = require('./lib/events')
var ethutil = require('ethereumjs-util')
@ -297,7 +298,27 @@ class Recorder {
}
})
},
(error, continueTxExecution, cancelCb) => {
if (error) {
var 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()
}
},
function (err, txResult) {
if (err) {
console.error(err)

@ -181,6 +181,28 @@ UniversalDAppUI.prototype.getCallButton = function (args) {
})
}
var continueCb = (error, continueTxExecution, cancelCb) => {
if (error) {
var 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()
}
}
var outputCb = (decoded) => {
outputOverride.innerHTML = ''
outputOverride.appendChild(decoded)
@ -195,7 +217,7 @@ UniversalDAppUI.prototype.getCallButton = function (args) {
self.udapp._deps.logCallback(`${logMsg}`)
}
if (args.funABI.type === 'fallback') data.dataHex = value
self.udapp.callFunction(args.address, data, args.funABI, confirmationCb, (error, txResult) => {
self.udapp.callFunction(args.address, data, args.funABI, confirmationCb, continueCb, (error, txResult) => {
if (!error) {
var isVM = executionContext.isVM()
if (isVM) {

@ -14,7 +14,6 @@ var executionContext = require('./execution-context')
var globalRegistry = require('./global/registry')
var modalCustom = require('./app/ui/modal-dialog-custom')
var modalDialog = require('./app/ui/modaldialog')
function UniversalDApp () {
this.event = new EventManager()
@ -189,8 +188,8 @@ UniversalDApp.prototype.pendingTransactionsCount = function () {
* @param {String} data - data to send with the transaction ( return of txFormat.buildData(...) ).
* @param {Function} callback - callback.
*/
UniversalDApp.prototype.createContract = function (data, confirmationCb, callback) {
this.runTx({data: data, useCall: false}, confirmationCb, (error, txResult) => {
UniversalDApp.prototype.createContract = function (data, confirmationCb, continueCb, callback) {
this.runTx({data: data, useCall: false}, confirmationCb, continueCb, (error, txResult) => {
// see universaldapp.js line 660 => 700 to check possible values of txResult (error case)
callback(error, txResult)
})
@ -204,8 +203,8 @@ UniversalDApp.prototype.createContract = function (data, confirmationCb, callbac
* @param {Object} funAbi - abi definition of the function to call.
* @param {Function} callback - callback.
*/
UniversalDApp.prototype.callFunction = function (to, data, funAbi, confirmationCb, callback) {
this.runTx({to: to, data: data, useCall: funAbi.constant}, confirmationCb, (error, txResult) => {
UniversalDApp.prototype.callFunction = function (to, data, funAbi, confirmationCb, continueCb, callback) {
this.runTx({to: to, data: data, useCall: funAbi.constant}, confirmationCb, continueCb, (error, txResult) => {
// see universaldapp.js line 660 => 700 to check possible values of txResult (error case)
callback(error, txResult)
})
@ -247,7 +246,7 @@ UniversalDApp.prototype.silentRunTx = function (tx, cb) {
cb)
}
UniversalDApp.prototype.runTx = function (args, confirmationCb, cb) {
UniversalDApp.prototype.runTx = function (args, confirmationCb, continueCb, cb) {
const self = this
async.waterfall([
function getGasLimit (next) {
@ -293,28 +292,7 @@ UniversalDApp.prototype.runTx = function (args, confirmationCb, cb) {
var timestamp = Date.now()
self.event.trigger('initiatingTransaction', [timestamp, tx, payLoad])
self.txRunner.rawRun(tx, confirmationCb,
(error, continueTxExecution, cancelCb) => {
if (error) {
var 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()
}
},
self.txRunner.rawRun(tx, confirmationCb, continueCb,
function (okCb, cancelCb) {
modalCustom.promptPassphrase(null, 'Personal mode is enabled. Please provide passphrase of account ' + tx.from, '', okCb, cancelCb)
},

Loading…
Cancel
Save